Changed filter function in xosTable to allow filtering on boolean values represented by 0,1 values
diff --git a/views/ngXosLib/xosHelpers/src/services/helpers/ui/comparator.service.js b/views/ngXosLib/xosHelpers/src/services/helpers/ui/comparator.service.js
new file mode 100644
index 0000000..d6978a4
--- /dev/null
+++ b/views/ngXosLib/xosHelpers/src/services/helpers/ui/comparator.service.js
@@ -0,0 +1,51 @@
+(function() {
+ 'use strict';
+
+ /**
+ * @ngdoc service
+ * @name xos.uiComponents.Comparato
+ * @description This factory define a function that replace the native angular.filter comparator. It is done to allow the comparation between (0|1) values with booleans.
+ **/
+
+ angular
+ .module('xos.uiComponents')
+ .factory('Comparator', comparator);
+
+ function comparator() {
+
+ return function(actual, expected){
+ if (angular.isUndefined(actual)) {
+ // No substring matching against `undefined`
+ return false;
+ }
+ if ((actual === null) || (expected === null)) {
+ // No substring matching against `null`; only match against `null`
+ return actual === expected;
+ }
+ if (angular.isObject(expected) || (angular.isObject(actual))){
+ return angular.equals(expected, actual);
+ }
+
+ if(_.isBoolean(actual) || _.isBoolean(expected)){
+ if(actual === 0 || actual === 1){
+ actual = !!actual;
+ }
+ return angular.equals(expected, actual);
+ }
+
+ if(!angular.isString(actual) || !angular.isString(expected)){
+ if(angular.isDefined(actual.toString) && angular.isDefined(expected.toString)){
+ actual = actual.toString();
+ expected = expected.toString();
+ }
+ else {
+ return actual === expected;
+ }
+ }
+
+ actual = actual.toLowerCase() + '';
+ expected = expected.toLowerCase() + '';
+ return actual.indexOf(expected) !== -1;
+ };
+ }
+})();
diff --git a/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/table/table.component.js b/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/table/table.component.js
index 7911b7a..371f46c 100644
--- a/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/table/table.component.js
+++ b/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/table/table.component.js
@@ -387,7 +387,7 @@
</tr>
</tbody>
<tbody>
- <tr ng-repeat="item in vm.data | filter:vm.query | orderBy:vm.orderBy:vm.reverse | pagination:vm.currentPage * vm.config.pagination.pageSize | limitTo: (vm.config.pagination.pageSize || vm.data.length) track by $index">
+ <tr ng-repeat="item in vm.data | filter:vm.query:vm.comparator | orderBy:vm.orderBy:vm.reverse | pagination:vm.currentPage * vm.config.pagination.pageSize | limitTo: (vm.config.pagination.pageSize || vm.data.length) track by $index">
<td ng-repeat="col in vm.columns" link-wrapper>
<span ng-if="!col.type">{{item[col.prop]}}</span>
<span ng-if="col.type === 'boolean'">
@@ -448,7 +448,9 @@
`,
bindToController: true,
controllerAs: 'vm',
- controller: function(_, $scope){
+ controller: function(_, $scope, Comparator){
+
+ this.comparator = Comparator;
this.loader = true;