CORD-467: Enable ordering on xosForm Fields
Change-Id: I77979b56f7996315b4405b065c4e1e55b68cb6c3
diff --git a/dist/xosUiComponents.js b/dist/xosUiComponents.js
index 80de789..0384480 100644
--- a/dist/xosUiComponents.js
+++ b/dist/xosUiComponents.js
@@ -28,6 +28,8 @@
angular.module('xos.uiComponents', ['chart.js', 'RecursionHelper', 'dndLists']);
})();
+//# sourceMappingURL=../maps/ui_components/ui-components.module.js.map
+
'use strict';
/**
@@ -233,7 +235,7 @@
// build form structure
// TODO move in a pure function for testing purposes
- props.forEach(function (p, i) {
+ props.forEach(function (p) {
_this.formConfig.fields[p] = {
label: LabelFormatter.format(p).replace(':', ''),
type: XosFormHelpers._getFieldFormat(item[p])
@@ -247,6 +249,8 @@
}]
});
})();
+//# sourceMappingURL=../../../maps/ui_components/smartComponents/smartTable/smartTable.component.js.map
+
'use strict';
/**
@@ -492,6 +496,8 @@
}]
});
})();
+//# sourceMappingURL=../../../maps/ui_components/smartComponents/smartPie/smartPie.component.js.map
+
'use strict';
/**
@@ -586,6 +592,8 @@
}
});
})();
+//# sourceMappingURL=../../../maps/ui_components/dumbComponents/validation/validation.component.js.map
+
'use strict';
/**
@@ -1016,106 +1024,8 @@
};
});
})();
-'use strict';
+//# sourceMappingURL=../../../maps/ui_components/dumbComponents/table/table.component.js.map
-/**
- * © OpenCORD
- *
- * Visit http://guide.xosproject.org/devguide/addview/ for more information
- *
- * Created by teone on 4/15/16.
- */
-
-(function () {
- 'use strict';
-
- angular.module('xos.uiComponents')
-
- /**
- * @ngdoc directive
- * @name xos.uiComponents.directive:xosPagination
- * @restrict E
- * @description The xos-table directive
- * @param {Number} pageSize Number of elements per page
- * @param {Number} totalElements Number of total elements in the collection
- * @param {Function} change The callback to be triggered on page change.
- * * @element ANY
- * @scope
- * @example
- <example module="samplePagination">
- <file name="index.html">
- <div ng-controller="SampleCtrl1 as vm">
- <xos-pagination
- page-size="vm.pageSize"
- total-elements="vm.totalElements"
- change="vm.change">
- </xos-pagination>
- </div>
- </file>
- <file name="script.js">
- angular.module('samplePagination', ['xos.uiComponents'])
- .controller('SampleCtrl1', function(){
- this.pageSize = 10;
- this.totalElements = 35;
- this.change = (pageNumber) => {
- console.log(pageNumber);
- }
- });
- </file>
- </example>
- **/
-
- .component('xosPagination', {
- restrict: 'E',
- bindings: {
- pageSize: '=',
- totalElements: '=',
- change: '='
- },
- template: '\n <div class="row" ng-if="vm.pageList.length > 1">\n <div class="col-xs-12 text-center">\n <ul class="pagination">\n <li\n ng-click="vm.goToPage(vm.currentPage - 1)"\n ng-class="{disabled: vm.currentPage == 0}">\n <a href="" aria-label="Previous">\n <span aria-hidden="true">«</span>\n </a>\n </li>\n <li ng-repeat="i in vm.pageList" ng-class="{active: i === vm.currentPage}">\n <a href="" ng-click="vm.goToPage(i)">{{i + 1}}</a>\n </li>\n <li\n ng-click="vm.goToPage(vm.currentPage + 1)"\n ng-class="{disabled: vm.currentPage == vm.pages - 1}">\n <a href="" aria-label="Next">\n <span aria-hidden="true">»</span>\n </a>\n </li>\n </ul>\n </div>\n </div>\n ',
- bindToController: true,
- controllerAs: 'vm',
- controller: ["$scope", function controller($scope) {
- var _this = this;
-
- this.currentPage = 0;
-
- this.goToPage = function (n) {
- if (n < 0 || n === _this.pages) {
- return;
- }
- _this.currentPage = n;
- _this.change(n);
- };
-
- this.createPages = function (pages) {
- var arr = [];
- for (var i = 0; i < pages; i++) {
- arr.push(i);
- }
- return arr;
- };
-
- // watch for data changes
- $scope.$watch(function () {
- return _this.totalElements;
- }, function () {
- if (_this.totalElements) {
- _this.pages = Math.ceil(_this.totalElements / _this.pageSize);
- _this.pageList = _this.createPages(_this.pages);
- }
- });
- }]
- }).filter('pagination', function () {
- return function (input, start) {
- if (!input || !angular.isArray(input)) {
- return input;
- }
- start = parseInt(start, 10);
- return input.slice(start);
- };
- });
-})();
'use strict';
/**
@@ -1181,8 +1091,7 @@
* @requires xos.uiComponents.XosFormHelpers
* @requires xos.helpers._
* @example
-
- Autogenerated form
+ Autogenerated form
<example module="sampleForm">
<file name="script.js">
angular.module('sampleForm', ['xos.uiComponents'])
@@ -1368,11 +1277,115 @@
}
var diff = _.difference(Object.keys(model), _this.excludedField);
var modelField = XosFormHelpers.parseModelField(diff);
- _this.formField = XosFormHelpers.buildFormStructure(modelField, _this.config.fields, model);
+ _this.formField = XosFormHelpers.buildFormStructure(modelField, _this.config.fields, model, _this.config.order);
});
}]
});
})();
+//# sourceMappingURL=../../../maps/ui_components/dumbComponents/form/form.component.js.map
+
+'use strict';
+
+/**
+ * © OpenCORD
+ *
+ * Visit http://guide.xosproject.org/devguide/addview/ for more information
+ *
+ * Created by teone on 4/15/16.
+ */
+
+(function () {
+ 'use strict';
+
+ angular.module('xos.uiComponents')
+
+ /**
+ * @ngdoc directive
+ * @name xos.uiComponents.directive:xosPagination
+ * @restrict E
+ * @description The xos-table directive
+ * @param {Number} pageSize Number of elements per page
+ * @param {Number} totalElements Number of total elements in the collection
+ * @param {Function} change The callback to be triggered on page change.
+ * * @element ANY
+ * @scope
+ * @example
+ <example module="samplePagination">
+ <file name="index.html">
+ <div ng-controller="SampleCtrl1 as vm">
+ <xos-pagination
+ page-size="vm.pageSize"
+ total-elements="vm.totalElements"
+ change="vm.change">
+ </xos-pagination>
+ </div>
+ </file>
+ <file name="script.js">
+ angular.module('samplePagination', ['xos.uiComponents'])
+ .controller('SampleCtrl1', function(){
+ this.pageSize = 10;
+ this.totalElements = 35;
+ this.change = (pageNumber) => {
+ console.log(pageNumber);
+ }
+ });
+ </file>
+ </example>
+ **/
+
+ .component('xosPagination', {
+ restrict: 'E',
+ bindings: {
+ pageSize: '=',
+ totalElements: '=',
+ change: '='
+ },
+ template: '\n <div class="row" ng-if="vm.pageList.length > 1">\n <div class="col-xs-12 text-center">\n <ul class="pagination">\n <li\n ng-click="vm.goToPage(vm.currentPage - 1)"\n ng-class="{disabled: vm.currentPage == 0}">\n <a href="" aria-label="Previous">\n <span aria-hidden="true">«</span>\n </a>\n </li>\n <li ng-repeat="i in vm.pageList" ng-class="{active: i === vm.currentPage}">\n <a href="" ng-click="vm.goToPage(i)">{{i + 1}}</a>\n </li>\n <li\n ng-click="vm.goToPage(vm.currentPage + 1)"\n ng-class="{disabled: vm.currentPage == vm.pages - 1}">\n <a href="" aria-label="Next">\n <span aria-hidden="true">»</span>\n </a>\n </li>\n </ul>\n </div>\n </div>\n ',
+ bindToController: true,
+ controllerAs: 'vm',
+ controller: ["$scope", function controller($scope) {
+ var _this = this;
+
+ this.currentPage = 0;
+
+ this.goToPage = function (n) {
+ if (n < 0 || n === _this.pages) {
+ return;
+ }
+ _this.currentPage = n;
+ _this.change(n);
+ };
+
+ this.createPages = function (pages) {
+ var arr = [];
+ for (var i = 0; i < pages; i++) {
+ arr.push(i);
+ }
+ return arr;
+ };
+
+ // watch for data changes
+ $scope.$watch(function () {
+ return _this.totalElements;
+ }, function () {
+ if (_this.totalElements) {
+ _this.pages = Math.ceil(_this.totalElements / _this.pageSize);
+ _this.pageList = _this.createPages(_this.pages);
+ }
+ });
+ }]
+ }).filter('pagination', function () {
+ return function (input, start) {
+ if (!input || !angular.isArray(input)) {
+ return input;
+ }
+ start = parseInt(start, 10);
+ return input.slice(start);
+ };
+ });
+})();
+//# sourceMappingURL=../../../maps/ui_components/dumbComponents/pagination/pagination.component.js.map
+
'use strict';
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
@@ -1606,6 +1619,8 @@
};
});
})();
+//# sourceMappingURL=../../../maps/ui_components/dumbComponents/field/field.component.js.map
+
'use strict';
/**
@@ -1741,6 +1756,8 @@
}]
});
})();
+//# sourceMappingURL=../../../maps/ui_components/dumbComponents/alert/alert.component.js.map
+
'use strict';
(function () {
@@ -1813,7 +1830,7 @@
* - _formatByUppercase
* - _capitalize
* - replace multiple space with a single one
- * - append `:` at the end
+ * - append `:` at the end
* <br/>
* Eg: `this_string` will became `This string:`<br/>
* Eg: `thisString` will became `This string:`
@@ -1839,6 +1856,8 @@
};
}
})();
+//# sourceMappingURL=../../../maps/services/helpers/ui/label_formatter.service.js.map
+
'use strict';
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
@@ -1936,14 +1955,22 @@
* ```
**/
- this.buildFormStructure = function (modelField, customField, model) {
+ this.buildFormStructure = function (modelField, customField, model, order) {
+
+ var orderedForm = {};
modelField = angular.extend(modelField, customField);
customField = customField || {};
- return _.reduce(Object.keys(modelField), function (form, f) {
+ if (order) {
+ _.each(order, function (key) {
+ orderedForm[key] = {};
+ });
+ }
- form[f] = {
+ _.each(Object.keys(modelField), function (f) {
+
+ orderedForm[f] = {
label: customField[f] && customField[f].label ? customField[f].label + ':' : LabelFormatter.format(f),
type: customField[f] && customField[f].type ? customField[f].type : _this._getFieldFormat(model[f]),
validators: customField[f] && customField[f].validators ? customField[f].validators : {},
@@ -1951,21 +1978,21 @@
};
if (customField[f] && customField[f].options) {
- form[f].options = customField[f].options;
+ orderedForm[f].options = customField[f].options;
}
if (customField[f] && customField[f].properties) {
- form[f].properties = customField[f].properties;
+ orderedForm[f].properties = customField[f].properties;
}
- if (form[f].type === 'date') {
+ if (orderedForm[f].type === 'date') {
model[f] = new Date(model[f]);
}
- if (form[f].type === 'number') {
+ if (orderedForm[f].type === 'number') {
model[f] = parseInt(model[f], 10);
}
+ });
- return form;
- }, {});
+ return orderedForm;
};
/**
@@ -1997,6 +2024,8 @@
};
}]);
})();
+//# sourceMappingURL=../../../maps/services/helpers/ui/form.helpers.js.map
+
'use strict';
(function () {
@@ -2093,6 +2122,8 @@
};
}
})();
+//# sourceMappingURL=../../../maps/services/helpers/ui/comparator.service.js.map
+
'use strict';
(function () {
@@ -2134,6 +2165,8 @@
$resourceProvider.defaults.stripTrailingSlashes = false;
}
})();
+//# sourceMappingURL=maps/xosHelpers.module.js.map
+
'use strict';
(function () {
@@ -2149,6 +2182,8 @@
return $resource('/api/service/vsg/');
}]);
})();
+//# sourceMappingURL=../../maps/services/rest/vSG.js.map
+
'use strict';
(function () {
@@ -2166,6 +2201,8 @@
});
}]);
})();
+//# sourceMappingURL=../../maps/services/rest/vOLT.js.map
+
'use strict';
(function () {
@@ -2189,6 +2226,8 @@
return $resource('/api/utility/logout/');
}]);
})();
+//# sourceMappingURL=../../maps/services/rest/Utility.js.map
+
'use strict';
(function () {
@@ -2206,6 +2245,8 @@
});
}]);
})();
+//# sourceMappingURL=../../maps/services/rest/Users.js.map
+
'use strict';
(function () {
@@ -2223,6 +2264,8 @@
});
}]);
})();
+//# sourceMappingURL=../../maps/services/rest/Truckroll.js.map
+
'use strict';
(function () {
@@ -2240,6 +2283,8 @@
});
}]);
})();
+//# sourceMappingURL=../../maps/services/rest/Tenant.js.map
+
'use strict';
(function () {
@@ -2389,6 +2434,8 @@
});
}]);
})();
+//# sourceMappingURL=../../maps/services/rest/Subscribers.js.map
+
'use strict';
(function () {
@@ -2426,6 +2473,8 @@
};
}]);
})();
+//# sourceMappingURL=../../maps/services/rest/Slices_plus.js.map
+
'use strict';
(function () {
@@ -2443,6 +2492,8 @@
});
}]);
})();
+//# sourceMappingURL=../../maps/services/rest/Slices.js.map
+
'use strict';
(function () {
@@ -2460,6 +2511,8 @@
});
}]);
})();
+//# sourceMappingURL=../../maps/services/rest/Sites.js.map
+
'use strict';
(function () {
@@ -2477,6 +2530,8 @@
});
}]);
})();
+//# sourceMappingURL=../../maps/services/rest/Services.js.map
+
'use strict';
(function () {
@@ -2492,6 +2547,8 @@
return $resource('/api/service/onos/');
}]);
})();
+//# sourceMappingURL=../../maps/services/rest/ONOS-Services.js.map
+
'use strict';
(function () {
@@ -2507,6 +2564,8 @@
return $resource('/api/tenant/onos/app/');
}]);
})();
+//# sourceMappingURL=../../maps/services/rest/ONOS-Apps.js.map
+
'use strict';
(function () {
@@ -2524,6 +2583,8 @@
});
}]);
})();
+//# sourceMappingURL=../../maps/services/rest/Nodes.js.map
+
'use strict';
(function () {
@@ -2541,6 +2602,8 @@
});
}]);
})();
+//# sourceMappingURL=../../maps/services/rest/Networkstemplates.js.map
+
'use strict';
(function () {
@@ -2558,6 +2621,8 @@
});
}]);
})();
+//# sourceMappingURL=../../maps/services/rest/Networks.js.map
+
'use strict';
(function () {
@@ -2583,6 +2648,8 @@
};
}]);
})();
+//# sourceMappingURL=../../maps/services/rest/Me.js.map
+
'use strict';
(function () {
@@ -2600,6 +2667,8 @@
});
}]);
})();
+//# sourceMappingURL=../../maps/services/rest/Instances.js.map
+
'use strict';
(function () {
@@ -2617,6 +2686,8 @@
});
}]);
})();
+//# sourceMappingURL=../../maps/services/rest/Images.js.map
+
'use strict';
(function () {
@@ -2634,6 +2705,8 @@
});
}]);
})();
+//# sourceMappingURL=../../maps/services/rest/Flavors.js.map
+
'use strict';
(function () {
@@ -2649,6 +2722,8 @@
return $resource('/api/service/exampleservice/');
}]);
})();
+//# sourceMappingURL=../../maps/services/rest/Example.js.map
+
'use strict';
(function () {
@@ -2666,6 +2741,8 @@
});
}]);
})();
+//# sourceMappingURL=../../maps/services/rest/Deployments.js.map
+
'use strict';
(function () {
@@ -2697,6 +2774,8 @@
return r;
}]);
})();
+//# sourceMappingURL=../../maps/services/rest/Dashboards.js.map
+
'use strict';
(function () {
@@ -2857,6 +2936,8 @@
};
}]);
})();
+//# sourceMappingURL=../../maps/services/helpers/user-prefs.service.js.map
+
'use strict';
(function () {
@@ -2898,6 +2979,8 @@
};
}]);
})();
+//# sourceMappingURL=../maps/services/service_graph.service.js.map
+
'use strict';
/* eslint-disable angular/ng_window_service*/
@@ -2957,6 +3040,8 @@
};
}]);
})();
+//# sourceMappingURL=../maps/services/notification.service.js.map
+
'use strict';
(function () {
@@ -2981,6 +3066,8 @@
};
}
})();
+//# sourceMappingURL=../maps/services/noHyperlinks.interceptor.js.map
+
'use strict';
// TODO write tests for log
@@ -3040,6 +3127,8 @@
return $delegate;
}]);
}]);
+//# sourceMappingURL=../maps/services/log.decorator.js.map
+
'use strict';
(function () {
@@ -3065,6 +3154,8 @@
};
}
})();
+//# sourceMappingURL=../maps/services/csrfToken.interceptor.js.map
+
/**
* @ngdoc overview
* @name ngXosLib
@@ -3078,4 +3169,5 @@
* ## Issues
* Please report issues at https://jira.opencord.org
**/
-"use strict";
\ No newline at end of file
+"use strict";
+//# sourceMappingURL=maps/index.ngdoc.js.map