Added linting rules to ngXosLib and cleaned code
diff --git a/views/ngXosLib/xosHelpers/src/services/helpers/ui/form.helpers.js b/views/ngXosLib/xosHelpers/src/services/helpers/ui/form.helpers.js
index bc6a503..0a9d3ec 100644
--- a/views/ngXosLib/xosHelpers/src/services/helpers/ui/form.helpers.js
+++ b/views/ngXosLib/xosHelpers/src/services/helpers/ui/form.helpers.js
@@ -60,7 +60,7 @@
}
// if null return string
- if(typeof value === 'string' || value === null){
+ if(angular.isString(value) || value === null){
return 'text';
}
diff --git a/views/ngXosLib/xosHelpers/src/services/helpers/user-prefs.service.js b/views/ngXosLib/xosHelpers/src/services/helpers/user-prefs.service.js
index 27edf7f..7bf8ae1 100644
--- a/views/ngXosLib/xosHelpers/src/services/helpers/user-prefs.service.js
+++ b/views/ngXosLib/xosHelpers/src/services/helpers/user-prefs.service.js
@@ -23,7 +23,7 @@
.service('XosUserPrefs', function($cookies){
- let userPrefs = $cookies.get('xosUserPrefs') ? JSON.parse($cookies.get('xosUserPrefs')) : {};
+ let userPrefs = $cookies.get('xosUserPrefs') ? angular.fromJson($cookies.get('xosUserPrefs')) : {};
/**
* @ngdoc method
@@ -34,7 +34,7 @@
* @returns {object} The user preferences
**/
this.getAll = () => {
- userPrefs = $cookies.get('xosUserPrefs') ? JSON.parse($cookies.get('xosUserPrefs')) : {};
+ userPrefs = $cookies.get('xosUserPrefs') ? angular.fromJson($cookies.get('xosUserPrefs')) : {};
return userPrefs;
};
@@ -47,7 +47,7 @@
* @param {object} prefs The user preferences
**/
this.setAll = (prefs) => {
- $cookies.put('xosUserPrefs', JSON.stringify(prefs));
+ $cookies.put('xosUserPrefs', angular.toJson(prefs));
};
/**
diff --git a/views/ngXosLib/xosHelpers/src/services/log.decorator.js b/views/ngXosLib/xosHelpers/src/services/log.decorator.js
index b8c5297..e6bd621 100644
--- a/views/ngXosLib/xosHelpers/src/services/log.decorator.js
+++ b/views/ngXosLib/xosHelpers/src/services/log.decorator.js
@@ -1,5 +1,7 @@
// TODO write tests for log
+/* eslint-disable angular/ng_window_service*/
+
angular.module('xos.helpers')
.config([ '$provide', function( $provide )
{
@@ -11,7 +13,7 @@
const isLogEnabled = () => {
return window.location.href.indexOf('debug=true') >= 0;
- }
+ };
// Save the original $log.debug()
let logFn = $delegate.log;
let infoFn = $delegate.info;
@@ -34,7 +36,7 @@
args[0] = `[${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}] ${args[0]}`;
// HACK awfull fix for angular mock implementation whithin jasmine test failing issue
- if (typeof $delegate.reset === 'function' && !($delegate.debug.logs instanceof Array)) {
+ if (angular.isFunction($delegate.reset) && !($delegate.debug.logs instanceof Array)) {
// if we are within the mock and did not reset yet, we call it to avoid issue
// console.log('mock log impl fix to avoid logs array not existing...');
$delegate.reset();
diff --git a/views/ngXosLib/xosHelpers/src/services/notification.service.js b/views/ngXosLib/xosHelpers/src/services/notification.service.js
index e190451..9a1598e 100644
--- a/views/ngXosLib/xosHelpers/src/services/notification.service.js
+++ b/views/ngXosLib/xosHelpers/src/services/notification.service.js
@@ -1,3 +1,4 @@
+/* eslint-disable angular/ng_window_service*/
(function() {
'use strict';
diff --git a/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/form/form.component.js b/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/form/form.component.js
index ca6d7d8..1706483 100644
--- a/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/form/form.component.js
+++ b/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/form/form.component.js
@@ -253,22 +253,16 @@
this.excludedField = this.excludedField.concat(this.config.exclude);
}
-
this.formField = [];
+
$scope.$watch(() => this.config, ()=> {
-
-
-
if(!this.ngModel){
return;
}
let diff = _.difference(Object.keys(this.ngModel), this.excludedField);
let modelField = XosFormHelpers.parseModelField(diff);
this.formField = XosFormHelpers.buildFormStructure(modelField, this.config.fields, this.ngModel);
-
-
- } ,true);
-
+ }, true);
$scope.$watch(() => this.ngModel, (model) => {
// empty from old stuff
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 6092f42..94e2ab3 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
@@ -388,7 +388,7 @@
</tbody>
<tbody>
<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>
+ <td ng-repeat="col in vm.columns" xos-link-wrapper>
<span ng-if="!col.type">{{item[col.prop]}}</span>
<span ng-if="col.type === 'boolean'">
<i class="glyphicon"
@@ -534,7 +534,7 @@
}
})
// TODO test
- .directive('linkWrapper', function() {
+ .directive('xosLinkWrapper', function() {
return {
restrict: 'A',
transclude: true,
diff --git a/views/ngXosLib/xosHelpers/src/ui_components/smartComponents/smartTable/smartTable.component.js b/views/ngXosLib/xosHelpers/src/ui_components/smartComponents/smartTable/smartTable.component.js
index 08844f6..622952f 100644
--- a/views/ngXosLib/xosHelpers/src/ui_components/smartComponents/smartTable/smartTable.component.js
+++ b/views/ngXosLib/xosHelpers/src/ui_components/smartComponents/smartTable/smartTable.component.js
@@ -242,7 +242,7 @@
prop: p
};
- if(typeof item[p] !== 'string' && typeof item[p] !== 'undefined'){
+ if(angular.isString(item[p]) && typeof item[p] !== 'undefined'){
fieldConfig.type = typeof item[p];
}
diff --git a/views/ngXosLib/xosHelpers/src/xosHelpers.module.js b/views/ngXosLib/xosHelpers/src/xosHelpers.module.js
index fe246a6..3d534b9 100644
--- a/views/ngXosLib/xosHelpers/src/xosHelpers.module.js
+++ b/views/ngXosLib/xosHelpers/src/xosHelpers.module.js
@@ -1,6 +1,8 @@
(function() {
'use strict';
-
+
+ /* eslint-disable angular/ng_module_name */
+
angular.module('bugSnag', []).factory('$exceptionHandler', function () {
return function (exception, cause) {
if( window.Bugsnag ){
@@ -12,6 +14,8 @@
};
});
+ /* eslint-enable angular/ng_module_name */
+
/**
* @ngdoc overview
* @name xos.helpers