From c5f0d37b4491fa8c18972e515df869e73fde0b88 Mon Sep 17 00:00:00 2001 From: Siva Kumar Bavanasi Date: Fri, 5 Aug 2016 13:52:52 +0530 Subject: [PATCH] Closes-bug: #1609728 - Backtrace is displayed instead of error message when 'route' is left unfilled under Route aggregates UT Results: Web-Controller PhantomJS 1.9.8 (Mac OS X 0.0.0): Executed 376 of 376 SUCCESS (2 mins 45.839 secs / 2 mins 35.515 secs) Change-Id: I84e52e9088cf52b8565350b6cc31b7c09348c81b (cherry picked from commit ee01294b8e56eb0ffaea8d422285efd5797603e5) --- .../ui/js/models/routeAggregateModel.js | 6 ++++++ .../ui/js/models/rtAggregateRoutesModel.js | 13 +++++++++++++ .../ui/js/views/routeAggregateEditView.js | 8 +++++--- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/webroot/config/networking/routeaggregate/ui/js/models/routeAggregateModel.js b/webroot/config/networking/routeaggregate/ui/js/models/routeAggregateModel.js index 27582b936..95bdb9095 100644 --- a/webroot/config/networking/routeaggregate/ui/js/models/routeAggregateModel.js +++ b/webroot/config/networking/routeaggregate/ui/js/models/routeAggregateModel.js @@ -72,6 +72,12 @@ define([ ctwu.getPermissionsValidation() ]; + validations.push({ + key : "routes", + type : cowc.OBJECT_TYPE_COLLECTION, + getValidation : "rtAggregateRoutesValidation" + }); + if (this.isDeepValid(validations)) { attr = this.model().attributes; newRouteAggregateData = $.extend(true, {}, attr); diff --git a/webroot/config/networking/routeaggregate/ui/js/models/rtAggregateRoutesModel.js b/webroot/config/networking/routeaggregate/ui/js/models/rtAggregateRoutesModel.js index 6a62a9a6d..5384c152f 100644 --- a/webroot/config/networking/routeaggregate/ui/js/models/rtAggregateRoutesModel.js +++ b/webroot/config/networking/routeaggregate/ui/js/models/rtAggregateRoutesModel.js @@ -23,6 +23,19 @@ define([ attrErrorObj[attr + cowc.ERROR_SUFFIX_ID] = (isValid == true) ? false : isValid; errors.set(attrErrorObj); + }, + + validations: { + rtAggregateRoutesValidation: { + route: function(value, attr, finalObj) { + var route = getValueByJsonPath(finalObj, "route", ""), + routeArry = route.split("/"); + if(routeArry.length !== 2 || (!isIPv4(routeArry[0]) && + !isIPv6(routeArry[0]))) { + return "Enter valid IPv4 or IPv6 Prefix"; + } + } + } } }); diff --git a/webroot/config/networking/routeaggregate/ui/js/views/routeAggregateEditView.js b/webroot/config/networking/routeaggregate/ui/js/views/routeAggregateEditView.js index 40b46894e..7435e546f 100644 --- a/webroot/config/networking/routeaggregate/ui/js/views/routeAggregateEditView.js +++ b/webroot/config/networking/routeaggregate/ui/js/views/routeAggregateEditView.js @@ -59,7 +59,7 @@ define([ false); Knockback.applyBindings(self.model, document.getElementById(modalId)); - kbValidation.bind(self); + kbValidation.bind(self, {collection:self.model.model().attributes.routes}); //permissions ctwu.bindPermissionsValidation(self); }, null, true @@ -138,14 +138,16 @@ define([ viewConfig: { path: "routes", collection: "routes", + validation: + "rtAggregateRoutesValidation", templateId: cowc.TMP_EDITABLE_GRID_ACTION_VIEW, columns: [{ elementId: "route", - name: "Routes", + name: "Route Prefix", view: "FormInputView", width: 350, viewConfig: { - placeholder: "Enter Route", + placeholder: "xxx.xxx.xxx.xxx/xx", width: 350, path: "route", templateId: cowc.TMPL_EDITABLE_GRID_INPUT_VIEW,