bastion 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +8 -8
  2. data/Gruntfile.js +7 -0
  3. data/app/assets/javascripts/bastion/auth/auth.module.js +3 -4
  4. data/app/assets/javascripts/bastion/bastion.module.js +3 -3
  5. data/app/assets/javascripts/bastion/components/bst-alerts.directive.js +1 -1
  6. data/app/assets/javascripts/bastion/components/bst-dropdown.directive.js +1 -1
  7. data/app/assets/javascripts/bastion/components/bst-edit.directive.js +27 -27
  8. data/app/assets/javascripts/bastion/components/bst-flyout.directive.js +1 -1
  9. data/app/assets/javascripts/bastion/components/bst-form-buttons.directive.js +1 -1
  10. data/app/assets/javascripts/bastion/components/bst-infinite-scroll.directive.js +12 -10
  11. data/app/assets/javascripts/bastion/components/bst-menu.directive.js +4 -4
  12. data/app/assets/javascripts/bastion/components/bst-modal.directive.js +2 -2
  13. data/app/assets/javascripts/bastion/components/bst-table.directive.js +18 -16
  14. data/app/assets/javascripts/bastion/components/formatters/boolean-to-yes-no.filter.js +3 -3
  15. data/app/assets/javascripts/bastion/components/nutupane-table.directive.js +12 -10
  16. data/app/assets/javascripts/bastion/components/nutupane.factory.js +12 -11
  17. data/app/assets/javascripts/bastion/components/page-title.directive.js +5 -3
  18. data/app/assets/javascripts/bastion/components/page-title.service.js +3 -1
  19. data/app/assets/javascripts/bastion/components/path-selector.directive.js +27 -27
  20. data/app/assets/javascripts/bastion/components/typeahead-empty.directive.js +2 -3
  21. data/app/assets/javascripts/bastion/features/bst-feature-flag.directive.js +1 -1
  22. data/app/assets/javascripts/bastion/features/feature-flag.service.js +3 -3
  23. data/app/assets/javascripts/bastion/menu/menu-expander.service.js +2 -2
  24. data/bastion.js +1 -0
  25. data/grunt/eslint.js +10 -0
  26. data/lib/bastion/version.rb +1 -1
  27. data/package.json +4 -1
  28. metadata +3 -2
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZjkzYzNhMmUxNGIwYTA0NWRjOWRhNjI1MGU1ZGE3ZDc2NTQyMTIyYQ==
4
+ NmU2ZTZkYTg5N2EwNmM1NTI5YTQyOTk3Yjg1NzY3NDQ3OWU5ZjlkYQ==
5
5
  data.tar.gz: !binary |-
6
- YTNhMTE1NzdhOGIzNDZmNGJhNmU0MThmZTU1MDhlNzQwMjM2NmVmMA==
6
+ ZTdkMTRkN2M0NTdkZjNhOGI3ZDg0MmJmYmUzNWRiNWUyMmM5ZmJjMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZmMwZjRlN2E1NDNkYzUxYWVjOTRlZWVhZDc4M2JjYjVmOGNjYWMwOWFhYTZm
10
- OTkwM2ViYzYxMzE2YjdmOTAxNWIxNjVjZTNjMzk2NGVmNTNmNDFhZDcxNTVm
11
- YTYyMmFjN2EwOThkNjMxM2Q0ZWE0NDRjOGU0MWQ4YzI1ZTgwZWI=
9
+ YjBiNjdiNWE2ZmU3ODJhOTNiNzU4MWNhMDI0Y2U5OGI2ZTJjMjJiMWNlZDlh
10
+ NmFhYzc5MmMyZjI5NmNhNWQ1MzZhYThmY2EwZmM5ZGMxNDY2ZDUzOGUyZmU1
11
+ MTY0YTdjYWQ1MmY2MmI3NTBjYTAwZjY1MjM5NTgxMDIwYzA5NjM=
12
12
  data.tar.gz: !binary |-
13
- NTkxYmRhZWZhNmQ1YjRhN2M0NzI2M2YxZGE2YWMwNjEyZjc5OWU4MTY2Mzhj
14
- YzEwMjlhZWFkZGVjZTFlN2NkN2Q5OTRlM2U0YWYwNDAwZWI1YTRlOGUzZTBh
15
- N2JiZWRmYzI1Njk3NmQ1MDhjOTgxZmQ1ZjZmZGNiOWI1MTg0YjM=
13
+ ZDU1MzA3ZjRhNGJkMzk3Y2U0ODc2MTZkNzExYmQyYTE0NTJlMjgwYzQ1YTUw
14
+ M2IzOGMwNDdmMTVlZGNhM2UxYjZmMTJmZDAwNjYxNGE4ZjM4NjQ5YTM5ODdm
15
+ YWZiNTNkZjIwNjM0NzQ3OTIwOGIwZGU0NDY3MDFkNDE0NjBjYWU=
data/Gruntfile.js CHANGED
@@ -15,4 +15,11 @@ module.exports = function (grunt) {
15
15
  var bastion = require('./bastion.js');
16
16
 
17
17
  bastion(grunt);
18
+
19
+ grunt.registerTask('ci', [
20
+ 'eslint',
21
+ 'jshint',
22
+ 'htmlhint',
23
+ 'karma:ci'
24
+ ]);
18
25
  };
@@ -48,10 +48,9 @@ angular.module('Bastion.auth').config(['$httpProvider', '$provide',
48
48
  message = translate('You are not authorized to perform this action.');
49
49
  response.data.errors = [message];
50
50
  response.data.displayMessage = message;
51
- return $q.reject(response);
52
- } else {
53
- return $q.reject(response);
54
51
  }
52
+
53
+ return $q.reject(response);
55
54
  }
56
55
  };
57
56
  }]
@@ -76,7 +75,7 @@ angular.module('Bastion.auth').run(['$rootScope', '$window', 'Authorization',
76
75
  function ($rootScope, $window, Authorization) {
77
76
  $rootScope.$on('$stateChangeStart', function (event, toState) {
78
77
  var permission = toState.permission;
79
- if (permission !== false && (permission === undefined || Authorization.denied(permission))) {
78
+ if (permission !== false && (angular.isUndefined(permission) || Authorization.denied(permission))) {
80
79
  $window.location.href = '/katello/403';
81
80
  }
82
81
  });
@@ -47,7 +47,7 @@ angular.module('Bastion').config(
47
47
 
48
48
  $httpProvider.defaults.headers.common = {
49
49
  Accept: 'application/json, text/plain, version=2; */*',
50
- 'X-CSRF-TOKEN': $('meta[name=csrf-token]').attr('content')
50
+ 'X-CSRF-TOKEN': angular.element('meta[name=csrf-token]').attr('content')
51
51
  };
52
52
 
53
53
  $urlRouterProvider.rule(function ($injector, $location) {
@@ -81,7 +81,7 @@ angular.module('Bastion').config(
81
81
  return {
82
82
  request: function (config) {
83
83
  if (config.url.indexOf('.html') !== -1) {
84
- if ($templateCache.get(config.url) === undefined) {
84
+ if (angular.isUndefined($templateCache.get(config.url))) {
85
85
  config.url = '/' + config.url;
86
86
  }
87
87
  }
@@ -138,7 +138,7 @@ angular.module('Bastion').run(['$rootScope', '$state', '$stateParams', 'gettextC
138
138
  };
139
139
 
140
140
  $rootScope.stateIncludes = function (state, params) {
141
- if (params !== undefined) {
141
+ if (angular.isDefined(params)) {
142
142
  angular.forEach(params, function (value, key) {
143
143
  params[key] = value.toString();
144
144
  });
@@ -40,7 +40,7 @@ angular.module('Bastion.components').directive('bstAlerts', function () {
40
40
  scope.types = ['success', 'info', 'warning', 'danger'];
41
41
 
42
42
  function handleMessages(type, messages) {
43
- scope.alerts[type] = messages;
43
+ scope.alerts[type] = messages;
44
44
  }
45
45
 
46
46
  scope.$watch('successMessages', function (messages) {
@@ -11,7 +11,7 @@ angular.module('Bastion.components').directive('bstDropdown', function () {
11
11
  restrict: 'EA',
12
12
  replace: true,
13
13
  scope: {
14
- 'dropdown' : '=bstDropdown'
14
+ 'dropdown': '=bstDropdown'
15
15
  },
16
16
  templateUrl: 'components/views/bst-dropdown.html',
17
17
 
@@ -37,6 +37,27 @@ angular.module('Bastion.components')
37
37
  .controller('BstEditController', ['$scope', '$filter', function ($scope, $filter) {
38
38
  var previousValue;
39
39
 
40
+ function handleAction(action) {
41
+ $scope.editMode = false;
42
+ $scope.workingMode = true;
43
+
44
+ if (angular.isDefined(action) && action.hasOwnProperty('then')) {
45
+ action.then(
46
+ function () {
47
+ $scope.updateDisplay($scope.model);
48
+ $scope.workingMode = false;
49
+ },
50
+ function () {
51
+ $scope.workingMode = false;
52
+ $scope.editMode = true;
53
+ }
54
+ );
55
+
56
+ } else {
57
+ $scope.workingMode = false;
58
+ }
59
+ }
60
+
40
61
  $scope.edit = function () {
41
62
  var options;
42
63
 
@@ -44,11 +65,11 @@ angular.module('Bastion.components')
44
65
  $scope.editMode = true;
45
66
  previousValue = $scope.model;
46
67
 
47
- if ($scope.handleOptions !== undefined) {
68
+ if (angular.isDefined($scope.handleOptions)) {
48
69
  options = $scope.handleOptions();
49
70
  }
50
71
 
51
- if (options !== undefined) {
72
+ if (angular.isDefined(options)) {
52
73
  if (options.hasOwnProperty('then')) {
53
74
  $scope.workingMode = true;
54
75
  $scope.editMode = false;
@@ -93,27 +114,6 @@ angular.module('Bastion.components')
93
114
  handleAction(action);
94
115
  };
95
116
 
96
- function handleAction(action) {
97
- $scope.editMode = false;
98
- $scope.workingMode = true;
99
-
100
- if (action !== undefined && action.hasOwnProperty('then')) {
101
- action.then(
102
- function () {
103
- $scope.updateDisplay($scope.model);
104
- $scope.workingMode = false;
105
- },
106
- function () {
107
- $scope.workingMode = false;
108
- $scope.editMode = true;
109
- }
110
- );
111
-
112
- } else {
113
- $scope.workingMode = false;
114
- }
115
- }
116
-
117
117
  $scope.cancel = function () {
118
118
  $scope.editMode = false;
119
119
  $scope.disableSave = false;
@@ -132,7 +132,7 @@ angular.module('Bastion.components')
132
132
 
133
133
  handleDelete = $scope.handleDelete({ value: $scope.model });
134
134
 
135
- if (handleDelete !== undefined && handleDelete.hasOwnProperty('then')) {
135
+ if (angular.isDefined(handleDelete) && handleDelete.hasOwnProperty('then')) {
136
136
 
137
137
  handleDelete.then(
138
138
  function () {
@@ -169,7 +169,7 @@ angular.module('Bastion.components')
169
169
  // Watch the model and displayed values for changes
170
170
  // and update the displayed value accordingly.
171
171
  $scope.$watch('model + displayValue', function (newValue) {
172
- if (newValue !== undefined) {
172
+ if (angular.isDefined(newValue)) {
173
173
  $scope.updateDisplay($scope.model);
174
174
  }
175
175
  });
@@ -255,7 +255,7 @@ angular.module('Bastion.components')
255
255
  },
256
256
  templateUrl: 'components/views/bst-edit-select.html',
257
257
  compile: function (element, attrs) {
258
- var optionsFormat = attrs['optionsFormat'];
258
+ var optionsFormat = attrs.optionsFormat;
259
259
  if (optionsFormat) {
260
260
  element.find('select').attr('ng-options', optionsFormat);
261
261
  }
@@ -341,7 +341,7 @@ angular.module('Bastion.components')
341
341
 
342
342
  handleAdd = $scope.handleAdd(value);
343
343
 
344
- if (handleAdd !== undefined && handleAdd.hasOwnProperty('then')) {
344
+ if (angular.isDefined(handleAdd) && handleAdd.hasOwnProperty('then')) {
345
345
 
346
346
  handleAdd.then(
347
347
  function () {
@@ -12,7 +12,7 @@ angular.module('Bastion.components').directive('bstFlyout', function () {
12
12
  restrict: 'EA',
13
13
  replace: true,
14
14
  scope: {
15
- 'flyout' : '=bstFlyout'
15
+ 'flyout': '=bstFlyout'
16
16
  },
17
17
  templateUrl: 'components/views/bst-flyout.html'
18
18
  };
@@ -38,7 +38,7 @@ angular.module('Bastion.components').directive('bstFormButtons', function () {
38
38
  },
39
39
  link: function (scope, iElement, iAttrs, controller) {
40
40
 
41
- if (scope.working === undefined) {
41
+ if (angular.isUndefined(scope.working)) {
42
42
  scope.working = false;
43
43
  }
44
44
 
@@ -38,7 +38,8 @@ angular.module('Bastion.components').directive('bstInfiniteScroll', [function ()
38
38
  },
39
39
  controller: function ($scope, $element) {
40
40
 
41
- var result, raw = $element[0];
41
+ var result, getScrollHeight, isPromise, loadUntilScroll,
42
+ raw = $element[0];
42
43
 
43
44
  $element.bind('scroll', function () {
44
45
  var sliderPosition = raw.scrollTop + raw.offsetHeight;
@@ -47,24 +48,25 @@ angular.module('Bastion.components').directive('bstInfiniteScroll', [function ()
47
48
  }
48
49
  });
49
50
 
50
- var getScrollHeight = function () {
51
+ getScrollHeight = function () {
51
52
  var scrollHeight = 0;
52
53
  $element.children().each(function () {
53
- scrollHeight = scrollHeight + $(this).get(0).scrollHeight;
54
+ scrollHeight = scrollHeight + angular.element(this).get(0).scrollHeight;
54
55
  });
55
56
  return scrollHeight;
56
57
  };
57
58
 
58
- var isPromise = function (promise) {
59
+ isPromise = function (promise) {
59
60
  return promise && promise.hasOwnProperty('then');
60
61
  };
61
62
 
62
- var loadUntilScroll = function () {
63
- var result;
63
+ loadUntilScroll = function () {
64
+ var loadResult;
65
+
64
66
  if (getScrollHeight() < $element.height()) {
65
- result = $scope.loadMoreFunction();
66
- if (isPromise(result)) {
67
- result.then(function () {
67
+ loadResult = $scope.loadMoreFunction();
68
+ if (isPromise(loadResult)) {
69
+ loadResult.then(function () {
68
70
  if (getScrollHeight() < $element.height()) {
69
71
  loadUntilScroll();
70
72
  }
@@ -73,7 +75,7 @@ angular.module('Bastion.components').directive('bstInfiniteScroll', [function ()
73
75
  }
74
76
  };
75
77
 
76
- if (!$scope.skipInitialLoad && ($scope.data === undefined || $scope.data.length === 0)) {
78
+ if (!$scope.skipInitialLoad && (angular.isUndefined($scope.data) || $scope.data.length === 0)) {
77
79
  result = $scope.loadMoreFunction();
78
80
  if (isPromise(result)) {
79
81
  result.then(loadUntilScroll);
@@ -13,7 +13,7 @@ angular.module('Bastion.components').directive('bstMenu', ['$window', function (
13
13
  replace: true,
14
14
  scope: {
15
15
  'menu': '=bstMenu',
16
- 'compact' : '@'
16
+ 'compact': '@'
17
17
  },
18
18
  templateUrl: 'components/views/bst-menu.html',
19
19
  controller: ['$scope', function ($scope) {
@@ -38,11 +38,11 @@ angular.module('Bastion.components').directive('bstMenu', ['$window', function (
38
38
  link: function (scope, element, attrs) {
39
39
  var elementOriginalOffset;
40
40
 
41
- if (attrs.compact !== undefined) {
42
- elementOriginalOffset = $(element).offset().top;
41
+ if (angular.isDefined(attrs.compact)) {
42
+ elementOriginalOffset = angular.element(element).offset().top;
43
43
 
44
44
  angular.element($window).bind('scroll', function () {
45
- var windowScrollTop = $($window).scrollTop();
45
+ var windowScrollTop = angular.element($window).scrollTop();
46
46
 
47
47
  if (windowScrollTop > elementOriginalOffset + 2) {
48
48
  element.parent().addClass('compact');
@@ -43,8 +43,8 @@ angular.module('Bastion.components').directive('bstModal',
43
43
 
44
44
  modalController = ['$scope', '$modalInstance', 'model', function ($scope, $modalInstance, model) {
45
45
  $scope[scope.modelName] = model;
46
- $scope['modalHeader'] = scope.modalHeader;
47
- $scope['modalBody'] = scope.modalBody;
46
+ $scope.modalHeader = scope.modalHeader;
47
+ $scope.modalBody = scope.modalBody;
48
48
 
49
49
  $scope.ok = function () {
50
50
  $modalInstance.close();
@@ -112,16 +112,16 @@ angular.module('Bastion.components')
112
112
  scope: true,
113
113
  controller: 'BstTableHeadController',
114
114
  compile: function (tElement, tAttrs) {
115
- if (tAttrs.rowSelect !== undefined) {
115
+ if (angular.isDefined(tAttrs.rowSelect)) {
116
116
  tElement.prepend(rowSelectTemplate());
117
- } else if (tAttrs.rowChoice !== undefined) {
117
+ } else if (angular.isDefined(tAttrs.rowChoice)) {
118
118
  tElement.prepend(rowChoiceTemplate());
119
119
  }
120
120
 
121
121
  return function (scope, element, attrs, bstTableController) {
122
- if (tAttrs.rowSelect !== undefined) {
122
+ if (angular.isDefined(tAttrs.rowSelect)) {
123
123
  scope.table.rowSelect = true;
124
- } else if (tAttrs.rowChoice !== undefined) {
124
+ } else if (angular.isDefined(tAttrs.rowChoice)) {
125
125
  scope.table.rowChoice = true;
126
126
  }
127
127
 
@@ -156,19 +156,21 @@ angular.module('Bastion.components')
156
156
  controller: ['$scope', function ($scope) {
157
157
  $scope.column = { show: true };
158
158
  }],
159
- compile: function (element, attributes) {
160
- if (attributes.hasOwnProperty("sortable")) {
161
- var newElement = angular.element(sortIconTemplate);
162
- newElement.find('.sort-icon').before(element.html());
159
+ compile: function (tElement, tAttributes) {
160
+ var newElement;
161
+
162
+ if (tAttributes.hasOwnProperty("sortable")) {
163
+ newElement = angular.element(sortIconTemplate);
164
+ newElement.find('.sort-icon').before(tElement.html());
163
165
  newElement.addClass('sortable');
164
- newElement.addClass(element.attr('class'));
165
- element.replaceWith(newElement);
166
+ newElement.addClass(tElement.attr('class'));
167
+ tElement.replaceWith(newElement);
166
168
  }
167
169
  return function (scope, element, attributes, bstTableHeadController) {
168
170
  if (attributes.hasOwnProperty("sortable")) {
169
171
  $compile(element)(scope);
170
172
  }
171
- scope.column.id = attributes["bstTableColumn"];
173
+ scope.column.id = attributes.bstTableColumn;
172
174
  bstTableHeadController.addColumn(scope.column);
173
175
 
174
176
  scope.$watch('column.show', function (show) {
@@ -202,7 +204,7 @@ angular.module('Bastion.components')
202
204
 
203
205
  activeRowTemplate = function (activeTest) {
204
206
  return '<i class="fa fa-chevron-right selected-icon" ' +
205
- 'ng-show="' + activeTest + ' "></i>';
207
+ 'ng-show="' + activeTest + ' "></i>';
206
208
  };
207
209
 
208
210
  return {
@@ -212,19 +214,19 @@ angular.module('Bastion.components')
212
214
  controller: 'BstTableRowController',
213
215
  compile: function (tElement, tAttrs) {
214
216
 
215
- if (tAttrs.activeRow !== undefined) {
217
+ if (angular.isDefined(tAttrs.activeRow)) {
216
218
  tElement.find('td:first-child').append(activeRowTemplate(tAttrs.activeRow));
217
219
  }
218
220
 
219
- if (tAttrs.rowSelect !== undefined) {
221
+ if (angular.isDefined(tAttrs.rowSelect)) {
220
222
  tElement.prepend(rowSelectTemplate(tAttrs.rowSelect));
221
223
  }
222
224
 
223
- if (tAttrs.rowChoice !== undefined) {
225
+ if (angular.isDefined(tAttrs.rowChoice)) {
224
226
  tElement.prepend(rowChoiceTemplate(tAttrs.rowChoice));
225
227
  }
226
228
 
227
- if (tAttrs.activeRow !== undefined) {
229
+ if (angular.isDefined(tAttrs.activeRow)) {
228
230
  tElement.find('td').attr('ng-class', '{ "active-row": ' + tAttrs.activeRow + ' }');
229
231
  }
230
232
 
@@ -25,10 +25,10 @@ angular.module('Bastion.components.formatters').filter('booleanToYesNo', ['trans
25
25
  yesValue = yesValue || translate("Yes");
26
26
  noValue = noValue || translate("No");
27
27
 
28
- if (boolValue !== '' && boolValue !== null && boolValue !== undefined) {
28
+ if (boolValue !== '' && boolValue !== null && angular.isDefined(boolValue)) {
29
29
  return (boolValue === true) ? yesValue : noValue;
30
- } else {
31
- return "";
32
30
  }
31
+
32
+ return "";
33
33
  };
34
34
  }]);
@@ -16,16 +16,9 @@ angular.module('Bastion.components').directive('nutupaneTable', ['$compile', '$w
16
16
  var originalTable, clonedTable, clonedThs,
17
17
  windowElement = angular.element($window);
18
18
 
19
- scope.$on("$stateChangeSuccess", function (event, newState, newParams, oldState) {
20
- // Only clone the table if the collapsed value changed or it's the first time.
21
- if (newState.collapsed !== oldState.collapsed || !oldState.name) {
22
- buildTable();
23
- } else {
24
- element.find("table:not(.cloned-nutupane-table)").find('thead').hide();
25
- }
26
- });
27
-
28
19
  function buildTable() {
20
+ var rowSelect;
21
+
29
22
  element.find('.cloned-nutupane-table').remove();
30
23
 
31
24
  originalTable = element.find('table');
@@ -42,7 +35,7 @@ angular.module('Bastion.components').directive('nutupaneTable', ['$compile', '$w
42
35
  $compile(element.find('.cloned-nutupane-table'))(scope);
43
36
 
44
37
  // Need to remove duplicate row-select created by second $compile
45
- var rowSelect = element.find(".row-select")[0];
38
+ rowSelect = element.find(".row-select")[0];
46
39
  if (rowSelect) {
47
40
  angular.element(rowSelect).remove();
48
41
  }
@@ -69,6 +62,15 @@ angular.module('Bastion.components').directive('nutupaneTable', ['$compile', '$w
69
62
  });
70
63
  }
71
64
 
65
+ scope.$on("$stateChangeSuccess", function (event, newState, newParams, oldState) {
66
+ // Only clone the table if the collapsed value changed or it's the first time.
67
+ if (newState.collapsed !== oldState.collapsed || !oldState.name) {
68
+ buildTable();
69
+ } else {
70
+ element.find("table:not(.cloned-nutupane-table)").find('thead').hide();
71
+ }
72
+ });
73
+
72
74
  buildTable();
73
75
  }
74
76
  };
@@ -116,10 +116,11 @@ angular.module('Bastion.components').factory('Nutupane',
116
116
  };
117
117
 
118
118
  self.table.autocomplete = function (term) {
119
- var data, promise, params;
119
+ var data, promise, localParams;
120
+
120
121
  if (resource.autocomplete) {
121
- params = self.getParams();
122
- params.search = term;
122
+ localParams = self.getParams();
123
+ localParams.search = term;
123
124
  data = resource.autocomplete(params);
124
125
  } else {
125
126
  data = self.table.fetchAutocomplete(term);
@@ -127,13 +128,12 @@ angular.module('Bastion.components').factory('Nutupane',
127
128
 
128
129
  promise = data.$promise;
129
130
  if (promise) {
130
- return promise.then(function (data) {
131
- return self.table.transformScopedSearch(data);
131
+ return promise.then(function (response) {
132
+ return self.table.transformScopedSearch(response);
132
133
  });
133
134
  }
134
- else {
135
- return data;
136
- }
135
+
136
+ return data;
137
137
  };
138
138
 
139
139
  self.table.transformScopedSearch = function (results) {
@@ -292,7 +292,7 @@ angular.module('Bastion.components').factory('Nutupane',
292
292
  self.table.nextPage = function () {
293
293
  var table = self.table;
294
294
  if (table.working || !table.hasMore()) {
295
- return;
295
+ return false;
296
296
  }
297
297
  return self.query();
298
298
  };
@@ -300,12 +300,13 @@ angular.module('Bastion.components').factory('Nutupane',
300
300
  self.table.hasMore = function () {
301
301
  var length = self.table.rows.length,
302
302
  subtotal = self.table.resource.subtotal,
303
- hasMore = false;
303
+ hasMore = false,
304
+ justBegun;
304
305
 
305
306
  if (!subtotal) {
306
307
  hasMore = false;
307
308
  } else {
308
- var justBegun = (length === 0 && subtotal !== 0);
309
+ justBegun = (length === 0 && subtotal !== 0);
309
310
  hasMore = (length < subtotal) || justBegun;
310
311
  }
311
312
  return hasMore;
@@ -33,18 +33,20 @@ angular.module('Bastion.components').directive('pageTitle', ['PageTitle', functi
33
33
  var title;
34
34
 
35
35
  return function (scope, iElem, iAttrs, ngModel) {
36
+ var unbind;
37
+
36
38
  transclude(scope, function (clone) {
37
39
  title = clone.text();
38
40
  });
39
41
 
40
42
  if (ngModel) {
41
- var unbind = scope.$watch(function () {
43
+ unbind = scope.$watch(function () {
42
44
  return ngModel.$viewValue;
43
45
  }, function (model) {
44
46
  unbind();
45
47
  if (model.hasOwnProperty('$promise')) {
46
- model.$promise.then(function (model) {
47
- scope[scope.modelName] = model;
48
+ model.$promise.then(function (data) {
49
+ scope[scope.modelName] = data;
48
50
  PageTitle.setTitle(title, scope);
49
51
  });
50
52
  } else {
@@ -26,8 +26,10 @@ angular.module('Bastion.components').service('PageTitle', ['$window', '$interpol
26
26
  this.titles = [];
27
27
 
28
28
  this.setTitle = function (title, locals) {
29
+ var interpolated;
30
+
29
31
  if (title) {
30
- var interpolated = $interpolate(title);
32
+ interpolated = $interpolate(title);
31
33
 
32
34
  $window.document.title = interpolated(locals);
33
35
  this.titles.push($window.document.title);
@@ -36,7 +36,32 @@ angular.module('Bastion.components').directive('pathSelector',
36
36
  templateUrl: 'components/views/path-selector.html',
37
37
  link: function (scope, element, attrs, ngModel) {
38
38
  var activeItemId, convertPathObjects, selectionRequired;
39
- selectionRequired = attrs['selectionRequired'] ? attrs['selectionRequired'] === 'true' : true;
39
+ selectionRequired = attrs.selectionRequired ? attrs.selectionRequired === 'true' : true;
40
+
41
+ function forEachItem(callback) {
42
+ angular.forEach(scope.paths, function (path) {
43
+ angular.forEach(path, function (item) {
44
+ callback(item);
45
+ });
46
+ });
47
+ }
48
+
49
+ function selectById(id) {
50
+ forEachItem(function (item) {
51
+ if (item.id === id) {
52
+ ngModel.$setViewValue(item);
53
+ item.selected = true;
54
+ }
55
+ });
56
+ }
57
+
58
+ function unselectActive() {
59
+ forEachItem(function (item) {
60
+ if (item.id === activeItemId) {
61
+ item.selected = false;
62
+ }
63
+ });
64
+ }
40
65
 
41
66
  scope.itemChanged = function (item) {
42
67
  if (item && scope.mode === 'singleSelect') {
@@ -52,7 +77,7 @@ angular.module('Bastion.components').directive('pathSelector',
52
77
 
53
78
  convertPathObjects = function (paths) {
54
79
  if (scope.pathAttribute) {
55
- paths = _.pluck(paths, scope.pathAttribute);
80
+ paths = _.pluck(paths, scope.pathAttribute);
56
81
  }
57
82
  return paths;
58
83
  };
@@ -79,31 +104,6 @@ angular.module('Bastion.components').directive('pathSelector',
79
104
  item.disabled = disable;
80
105
  });
81
106
  });
82
-
83
- function selectById(id) {
84
- forEachItem(function (item) {
85
- if (item.id === id) {
86
- ngModel.$setViewValue(item);
87
- item.selected = true;
88
- }
89
- });
90
- }
91
-
92
- function unselectActive() {
93
- forEachItem(function (item) {
94
- if (item.id === activeItemId) {
95
- item.selected = false;
96
- }
97
- });
98
- }
99
-
100
- function forEachItem(callback) {
101
- angular.forEach(scope.paths, function (path) {
102
- angular.forEach(path, function (item) {
103
- callback(item);
104
- });
105
- });
106
- }
107
107
  }
108
108
  };
109
109
  });
@@ -30,10 +30,9 @@ angular.module('Bastion.components').directive('typeaheadEmpty', function () {
30
30
  require: 'ngModel',
31
31
  link: function (scope, element, attrs, modelCtrl) {
32
32
  element.bind('focus', function () {
33
- if (modelCtrl.$viewValue === undefined || modelCtrl.$viewValue === '') {
33
+ if (angular.isUndefined(modelCtrl.$viewValue) || modelCtrl.$viewValue === '') {
34
34
  modelCtrl.$setViewValue(' ');
35
- }
36
- else {
35
+ } else {
37
36
  modelCtrl.$setViewValue(modelCtrl.$viewValue);
38
37
  }
39
38
  });
@@ -44,7 +44,7 @@
44
44
  scope: true,
45
45
  link: function (scope, element, attrs) {
46
46
  attrs.ngIf = function () {
47
- return FeatureFlag.featureEnabled(attrs['bstFeatureFlag']);
47
+ return FeatureFlag.featureEnabled(attrs.bstFeatureFlag);
48
48
  };
49
49
 
50
50
  ngIf.link.apply(ngIf, arguments);
@@ -48,7 +48,7 @@
48
48
  * @returns {Boolean}
49
49
  */
50
50
  this.featureEnabled = function (flag) {
51
- return (featureFlags[flag] === undefined) ? true : featureFlags[flag].enabled;
51
+ return angular.isUndefined(featureFlags[flag]) ? true : featureFlags[flag].enabled;
52
52
  };
53
53
 
54
54
  /**
@@ -83,9 +83,9 @@
83
83
  this.addStates = function (feature, states) {
84
84
  feature = featureFlags[feature];
85
85
 
86
- if (feature === undefined) {
86
+ if (angular.isUndefined(feature)) {
87
87
  feature = {states: []};
88
- } else if (feature.states === undefined) {
88
+ } else if (angular.isUndefined(undefined)) {
89
89
  feature.states = [];
90
90
  }
91
91
 
@@ -34,9 +34,9 @@ angular.module('Bastion.menu').service('MenuExpander', [function () {
34
34
  this.getMenu = function (menuName) {
35
35
  if (this.menu.hasOwnProperty(menuName)) {
36
36
  return this.menu[menuName];
37
- } else {
38
- return [];
39
37
  }
38
+
39
+ return [];
40
40
  };
41
41
 
42
42
  this.setMenu = function (menuName, items) {
data/bastion.js CHANGED
@@ -4,6 +4,7 @@ module.exports = function (grunt) {
4
4
  var configs = requireDir('./grunt');
5
5
 
6
6
  grunt.loadTasks(__dirname + '/node_modules/grunt-contrib-jshint/tasks');
7
+ grunt.loadTasks(__dirname + '/node_modules/grunt-eslint/tasks');
7
8
  grunt.loadTasks(__dirname + '/node_modules/grunt-htmlhint/tasks');
8
9
  grunt.loadTasks(__dirname + '/node_modules/grunt-bower-task/tasks');
9
10
  grunt.loadTasks(__dirname + '/node_modules/grunt-karma/tasks');
data/grunt/eslint.js ADDED
@@ -0,0 +1,10 @@
1
+ module.exports = {
2
+ options: {
3
+ configFile: __dirname + '/../eslint.yaml'
4
+ },
5
+ target: [
6
+ 'Gruntfile.js',
7
+ 'app/assets/javascripts/**/*.js',
8
+ '!app/assets/javascripts/bastion/i18n/translations.js'
9
+ ]
10
+ };
@@ -1,3 +1,3 @@
1
1
  module Bastion
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
data/package.json CHANGED
@@ -15,7 +15,10 @@
15
15
  "grunt-htmlhint": "~0.4.1",
16
16
  "grunt-concurrent": "~1.0.0",
17
17
  "generator-bastion": "~0.1.2",
18
- "grunt-angular-gettext": "~0.2.15"
18
+ "grunt-angular-gettext": "~0.2.15",
19
+ "grunt-eslint": "~6.0.0",
20
+ "eslint": "~0.14.1",
21
+ "eslint-plugin-angular": "0.0.3"
19
22
  },
20
23
  "engines": {
21
24
  "node": ">=0.8.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bastion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katello
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-09 00:00:00.000000000 Z
11
+ date: 2015-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: angular-rails-templates
@@ -159,6 +159,7 @@ files:
159
159
  - config/routes.rb
160
160
  - config/routes/mount_engine.rb
161
161
  - grunt/bower.js
162
+ - grunt/eslint.js
162
163
  - grunt/htmlhint.js
163
164
  - grunt/jshint.js
164
165
  - grunt/karma.js