nice-elements 1.10.4 → 1.10.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/README.md +1 -1
  3. package/bower.json +1 -1
  4. package/dist/nice.js +142 -114
  5. package/dist/nice.min.js +1 -1
  6. package/dist/style.css +13 -2
  7. package/dist/style.css.map +1 -1
  8. package/dist/style.min.css +1 -1
  9. package/eslint.config.mjs +28 -0
  10. package/package.json +4 -1
  11. package/src/components/nice-calendar/nice-calendar.js +2 -1
  12. package/src/components/nice-comment/nice-comment.html +1 -1
  13. package/src/components/nice-comment/nice-comment.js +2 -1
  14. package/src/components/nice-date/nice-date.html +2 -1
  15. package/src/components/nice-date/nice-date.js +2 -1
  16. package/src/components/nice-date-input/nice-date-input.js +2 -1
  17. package/src/components/nice-date-range/nice-date-range.js +8 -7
  18. package/src/components/nice-datetime-picker/nice-datetime-picker.js +2 -1
  19. package/src/components/nice-datetimerange-picker/nice-datetimerange-picker.js +2 -1
  20. package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.js +2 -1
  21. package/src/components/nice-dropdown/nice-dropdown.html +2 -1
  22. package/src/components/nice-dropdown/nice-dropdown.js +12 -6
  23. package/src/components/nice-dropdown/nice-dropdown.scss +13 -1
  24. package/src/components/nice-dropdown-date/nice-dropdown-date.js +9 -8
  25. package/src/components/nice-dtp/nice-dtp.js +2 -1
  26. package/src/components/nice-label/nice-label.js +2 -1
  27. package/src/components/nice-quantity/nice-quantity.js +1 -0
  28. package/src/components/nice-slot/nice-slot.js +2 -1
  29. package/src/components/nice-time-picker/nice-time-picker.js +2 -1
  30. package/src/components/nice-toggle/nice-toggle.js +3 -2
  31. package/src/components/nice-upload/nice-upload.html +1 -1
  32. package/src/components/nice-upload/nice-upload.js +2 -1
  33. package/src/components/nice-yesno/nice-yesno.js +22 -21
  34. package/src/services/nice-service.js +5 -2
@@ -0,0 +1,28 @@
1
+ import globals from "globals";
2
+ import pluginJs from "@eslint/js";
3
+
4
+ export default [
5
+ {
6
+ files: ["**/*.js"],
7
+ languageOptions: {
8
+ sourceType: "script"
9
+ }
10
+ },
11
+ {
12
+ languageOptions: {
13
+ globals: {
14
+ ...globals.browser,
15
+ angular: true,
16
+ moment: true,
17
+ Popper: true
18
+ }
19
+ }
20
+ },
21
+ pluginJs.configs.recommended,
22
+ {
23
+ rules: {
24
+ "no-unused-vars": "warn",
25
+ "no-vars": "warn"
26
+ }
27
+ }
28
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nice-elements",
3
- "version": "1.10.4",
3
+ "version": "1.10.5",
4
4
  "description": "Nice elements used in olaii angular 1.x webapps.",
5
5
  "main": "dist/nice.js",
6
6
  "license": "MIT",
@@ -27,6 +27,9 @@
27
27
  "ng-dialog": "0.5.6"
28
28
  },
29
29
  "devDependencies": {
30
+ "@eslint/js": "8.0.0",
31
+ "eslint": "8.0.0",
32
+ "globals": "15.2.0",
30
33
  "express": "4.17.1",
31
34
  "grunt": "1.6.1",
32
35
  "grunt-angular-templates": "1.2.0",
@@ -27,7 +27,8 @@ angular.module('niceElements')
27
27
  isDisabled: '=',
28
28
  help: '@',
29
29
  isInline: '=',
30
- onChange: '&?'
30
+ onChange: '&?',
31
+ required: '='
31
32
  },
32
33
  link: function (scope, element) {
33
34
  // ------------------ Init default values ------------------
@@ -5,7 +5,7 @@
5
5
 
6
6
  <!------------------------- Field ------------------------->
7
7
  <div class="nice-field col-xs-12" ng-class="[fieldWidth ? fieldWidth : 'col-sm-8', { 'nice-disabled': isDisabled }]" ng-click="edit()">
8
- <textarea ng-class="{'editing': editing}" class="form-control" ng-model="model" placeholder="{{placeholder}}" rows="{{rows}}" ng-blur="save()" ng-disabled="isDisabled"></textarea>
8
+ <textarea ng-class="{'editing': editing}" class="form-control" ng-model="model" placeholder="{{placeholder}}" rows="{{rows}}" ng-blur="save()" ng-required="required" ng-disabled="isDisabled"></textarea>
9
9
  </div>
10
10
  </div>
11
11
  </div>
@@ -23,7 +23,8 @@ angular.module('niceElements')
23
23
  labelWidth: '@',
24
24
  help: '@',
25
25
  isInline: '=',
26
- rows: '@'
26
+ rows: '@',
27
+ required: '='
27
28
  },
28
29
  link: function postLink(scope, element, attrs) {
29
30
  if (scope.model == null) { scope.model = ''; }
@@ -27,7 +27,8 @@
27
27
  <div class="nice-date-header">
28
28
  <span>
29
29
  <select class="year-picker" ng-model="innerDate.year" ng-change="handleDateChange()" ng-options="year for year in years" ng-disabled="isDisabled">
30
- </select>,
30
+ </select>
31
+ <span>,</span>
31
32
  <select class="month-picker" ng-model="innerDate.month" ng-change="handleDateChange()" ng-options="month.value as month.name for month in months" ng-disabled="isDisabled">
32
33
  </select>
33
34
  </span>
@@ -29,7 +29,8 @@ angular.module('niceElements')
29
29
  nextDate: '=',
30
30
  isDisabled: '=',
31
31
  isInline: '=',
32
- onChange: '&?'
32
+ onChange: '&?',
33
+ required: '='
33
34
  },
34
35
  controller: function ($scope, $element, $timeout, gettextCatalog) {
35
36
  $scope.isOpen = false;
@@ -26,7 +26,8 @@ angular.module('niceElements')
26
26
  isDisabled: '=',
27
27
  help: '@',
28
28
  isInline: '=',
29
- onChange: '&?'
29
+ onChange: '&?',
30
+ required: '='
30
31
  },
31
32
  controller: function ($scope, $timeout) {
32
33
  $scope.formatDate = "DD.MM.YYYY";
@@ -8,7 +8,7 @@
8
8
  */
9
9
  angular.module('niceElements')
10
10
 
11
- .directive('niceDateRange', function() {
11
+ .directive('niceDateRange', function () {
12
12
  return {
13
13
  restrict: 'E',
14
14
  transclude: true,
@@ -26,19 +26,20 @@ angular.module('niceElements')
26
26
  startOfTheYear: '@',
27
27
  help: '@',
28
28
  isInline: '=',
29
- onChange: '&?'
29
+ onChange: '&?',
30
+ required: '='
30
31
  },
31
32
 
32
- link: function(scope, attrs){
33
+ link: function (scope, attrs) {
33
34
  if (!attrs.title) { attrs.title = ''; }
34
35
  if (!attrs.fieldWidth) { attrs.fieldWidth = 'col-sm-8'; }
35
36
  if (!attrs.labelWidth) { attrs.labelWidth = 'col-sm-4'; }
36
37
  if (!attrs.format) { attrs.format = 'dd.MM.yyyy'; }
37
38
  attrs.noMargin = angular.isDefined(attrs.noMargin);
38
39
 
39
- if(!angular.isDefined(scope.model)) {
40
+ if (!angular.isDefined(scope.model)) {
40
41
  var model = null;
41
- if(!angular.isDefined(scope.startOfTheYear)){
42
+ if (!angular.isDefined(scope.startOfTheYear)) {
42
43
  model = {
43
44
  startDate: moment().format(),
44
45
  endDate: moment().format()
@@ -54,7 +55,7 @@ angular.module('niceElements')
54
55
  }
55
56
  },
56
57
 
57
- controller: function($scope) {
58
+ controller: function ($scope) {
58
59
  $scope.opts = {
59
60
  locale: {
60
61
  applyClass: 'btn-green',
@@ -70,7 +71,7 @@ angular.module('niceElements')
70
71
  $scope.opts.ranges[gettextCatalog.getString("Last 30 days", null, "Nice")] = [moment().subtract(30, 'days'), moment()];
71
72
  $scope.opts.ranges[gettextCatalog.getString("This month", null, "Nice")] = [moment().startOf('month'), moment().endOf('month')];
72
73
 
73
- if(angular.isDefined($scope.format)) $scope.opts.format = format;
74
+ if (angular.isDefined($scope.format)) $scope.opts.format = format;
74
75
  }
75
76
 
76
77
  };
@@ -33,7 +33,8 @@ angular.module('niceElements').directive('niceDatetimePicker', function () {
33
33
  isDisabled: '=',
34
34
  help: '@',
35
35
  isInline: '=',
36
- onChange: '&?'
36
+ onChange: '&?',
37
+ required: '='
37
38
  },
38
39
  controller: function ($scope, gettextCatalog) {
39
40
  console.warn("[NICE ELEMENTS] nice-datetime-picker component is deprecated!");
@@ -34,7 +34,8 @@ angular.module('niceElements')
34
34
  isDisabled: '=',
35
35
  help: '@',
36
36
  isInline: '=',
37
- onChange: '&?'
37
+ onChange: '&?',
38
+ required: '='
38
39
  },
39
40
  templateUrl: 'src/components/nice-datetimerange-picker/nice-datetimerange-picker.html',
40
41
  link: {
@@ -25,7 +25,8 @@ angular.module('niceElements')
25
25
  isDisabled: '=',
26
26
  help: '@',
27
27
  isInline: '=',
28
- onChange: '&?'
28
+ onChange: '&?',
29
+ required: '='
29
30
  },
30
31
  templateUrl: 'src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.html',
31
32
  controller: function ($element, $timeout, $scope) {
@@ -8,6 +8,7 @@
8
8
  <div class="nice-field-wrapper">
9
9
  <!------------------------- Button ------------------------->
10
10
  <button type="button" class="btn btn-dropdown" type="button" ng-ref="dropdown-button" ng-click="toggle()" ng-disabled="isDisabled || emptyList" aria-expanded="{{ isOpen }}" aria-haspopup="true" aria-controls="menu" id="nice-dropdown-{{ id }}">
11
+ <input class="hidden-input" ng-model="model" ng-required="required" ng-disabled="disabled" tabindex="-1" />
11
12
  <div class="btn-dropdown-inside" ng-transclude="button" ng-if="selected != null">
12
13
  <span ng-if="!multiple">{{ selected[objValue] }}</span>
13
14
  <span ng-if="multiple">
@@ -28,7 +29,7 @@
28
29
  <div class="nice-dropdown-menu-wrapper">
29
30
  <div class="nice-dropdown-menu" ng-if="isOpen">
30
31
  <div class="search-bar" ng-if="!noSearch && searchFunction">
31
- <input ng-model="internal.search" ng-model-options="{ debounce: 500 }" ng-change="handleSearch()" placeholder="{{ searchText }}" />
32
+ <input class="search-bar-input" ng-model="internal.search" ng-model-options="{ debounce: 500 }" ng-change="handleSearch()" placeholder="{{ searchText }}" />
32
33
  <div class="count" ng-if="internalList && internalList._metadata && enableLoadMore">{{ internalList.length }}/{{ internalList._metadata.count }}</div>
33
34
  <nice-icon ng-if="!internal.search" class="icon" icon="icon-search"></nice-icon>
34
35
  <nice-icon ng-if="internal.search" class="icon" icon="icon-x" ng-click="clearSearch()"></nice-icon>
@@ -197,15 +197,21 @@ angular.module('niceElements')
197
197
 
198
198
  // ----------------------------------- Focus input -----------------------------------
199
199
  $scope.focusInput = function () {
200
- var input = $element[0].getElementsByTagName('input')[0];
201
- if (input) {
202
- $timeout(function () {
203
- input.focus();
204
- });
205
- }
200
+ $timeout(function () {
201
+ const input = $element[0].getElementsByClassName("search-bar-input")[0];
202
+ if (input) input.focus();
203
+ });
206
204
  };
207
205
 
208
206
 
207
+ // $scope.onInputFocus = function () {
208
+ // $timeout(function () {
209
+ // const input = $element[0].getElementsByClassName("btn-dropdown")[0];
210
+ // if (input) input.focus();
211
+ // });
212
+ // }
213
+
214
+
209
215
  // ------------------- On blur -------------------
210
216
  $scope.onBlur = function () {
211
217
  $scope.close();
@@ -7,6 +7,17 @@
7
7
  position: fixed !important;
8
8
  }
9
9
 
10
+ .hidden-input {
11
+ height: 0;
12
+ width: 100%;
13
+ position: absolute;
14
+ bottom: 0;
15
+ left: 0;
16
+ padding: 0;
17
+ background: transparent;
18
+ opacity: 0;
19
+ }
20
+
10
21
  .open {
11
22
  .btn-dropdown {
12
23
  background: $nice-focus-bg !important;
@@ -240,7 +251,8 @@
240
251
  }
241
252
 
242
253
  &:active,
243
- &:focus {
254
+ &:focus,
255
+ &:focus-within {
244
256
  background: $nice-focus-bg !important;
245
257
  color: $nice-focus-color !important;
246
258
  border-color: var(--nice-border-color);
@@ -25,7 +25,8 @@ angular.module('niceElements')
25
25
  mature: '@',
26
26
  help: '@',
27
27
  isInline: '=',
28
- onChange: '&?'
28
+ onChange: '&?',
29
+ required: '='
29
30
  },
30
31
  link: function ($scope) {
31
32
  $scope.days = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31];
@@ -46,10 +47,10 @@ angular.module('niceElements')
46
47
 
47
48
 
48
49
  // Set the years drop down from attributes or defaults
49
- var currentYear = parseInt($scope.startingYear, 10) || new Date().getFullYear();
50
- var numYears = parseInt($scope.numYears, 10) || 100;
51
- var oldestYear = currentYear - numYears;
52
- var newestYear = currentYear;
50
+ const currentYear = parseInt($scope.startingYear, 10) || new Date().getFullYear();
51
+ const numYears = parseInt($scope.numYears, 10) || 100;
52
+ const oldestYear = currentYear - numYears;
53
+ let newestYear = currentYear;
53
54
 
54
55
 
55
56
  // If mature
@@ -83,7 +84,7 @@ angular.module('niceElements')
83
84
 
84
85
  // validate that the date selected is accurate
85
86
  $scope.checkDate = function () {
86
- var date = moment($scope.dateFields.day + "." + ($scope.dateFields.month + 1) + "." + $scope.dateFields.year, "D.M.YYYY");
87
+ const date = moment($scope.dateFields.day + "." + ($scope.dateFields.month + 1) + "." + $scope.dateFields.year, "D.M.YYYY");
87
88
 
88
89
  if (date.isValid()) {
89
90
  // Format
@@ -110,14 +111,14 @@ angular.module('niceElements')
110
111
 
111
112
  // Set current date
112
113
  if (!$scope.model) {
113
- var date = moment();
114
+ const date = moment();
114
115
  $scope.dateFields.day = date.get('date');
115
116
  $scope.dateFields.month = date.get('month');
116
117
  $scope.dateFields.year = date.get('year');
117
118
  if ($scope.mature) $scope.dateFields.year -= 18;
118
119
  $scope.checkDate();
119
120
  } else {
120
- var date = moment($scope.model);
121
+ const date = moment($scope.model);
121
122
  $scope.dateFields.day = date.get('date');
122
123
  $scope.dateFields.month = date.get('month');
123
124
  $scope.dateFields.year = date.get('year');
@@ -33,7 +33,8 @@ angular.module('niceElements')
33
33
  noMargin: '@', // default: false, if noMargin==true then entire directive can be injected inside other divs
34
34
  fieldWidth: '@', // default: 'col-sm-8', bootstrap classes that defines width of field
35
35
  labelWidth: '@', // default: 'col-sm-4', bootstrap classes that defines width of label
36
- closed: '='
36
+ closed: '=',
37
+ required: '='
37
38
  },
38
39
  templateUrl: 'src/components/nice-dtp/nice-dtp.html',
39
40
  controller: function ($scope, $element, $attrs, gettextCatalog) {
@@ -19,7 +19,8 @@ angular.module('niceElements')
19
19
  title: '@',
20
20
  noMargin: '@',
21
21
  isInline: '=',
22
- help: '@'
22
+ help: '@',
23
+ required: '='
23
24
  },
24
25
  link: function postLink(scope, element, attrs) {
25
26
  if (!attrs.fieldWidth) { attrs.fieldWidth = 'col-sm-8'; }
@@ -24,6 +24,7 @@ angular.module('niceElements')
24
24
  isDisabled: '=',
25
25
  isInline: '=',
26
26
  help: '@',
27
+ required: '='
27
28
  },
28
29
  controller: function ($scope) {
29
30
  $scope.min = Number($scope.min) || 0;
@@ -19,7 +19,8 @@ angular.module('niceElements')
19
19
  title: '@',
20
20
  noMargin: '@',
21
21
  isInline: '=',
22
- help: '@'
22
+ help: '@',
23
+ required: '='
23
24
  },
24
25
  link: function postLink(scope, element, attrs) {
25
26
  if (!attrs.fieldWidth) { attrs.fieldWidth = 'col-sm-8'; }
@@ -19,7 +19,8 @@ angular.module('niceElements')
19
19
  labelWidth: '@',
20
20
  onChange: '&?',
21
21
  isInline: '=',
22
- help: '@'
22
+ help: '@',
23
+ required: '='
23
24
  },
24
25
  restrict: 'E',
25
26
  templateUrl: 'src/components/nice-time-picker/nice-time-picker.html',
@@ -23,7 +23,8 @@ angular.module('niceElements')
23
23
  isInline: '=',
24
24
  isBlock: '=',
25
25
  titleRight: '=',
26
- help: '@'
26
+ help: '@',
27
+ required: '='
27
28
  },
28
29
  controller: function ($scope, $timeout) {
29
30
  if (!$scope.title) { $scope.title = ''; }
@@ -43,7 +44,7 @@ angular.module('niceElements')
43
44
  }
44
45
  }
45
46
 
46
- $timeout(function() {
47
+ $timeout(function () {
47
48
  if ($scope.onChange) $scope.onChange({ model: $scope.model });
48
49
  $scope.formToggle.$setDirty();
49
50
  });
@@ -15,7 +15,7 @@
15
15
  </div>
16
16
  <img ng-if="imageSource" data-ng-src="{{ imageSource }}" />
17
17
  </div>
18
- <input class="input-file" type="file" accept="{{ accept }}" ng-model="file" ng-disabled="isDisabled || loading" />
18
+ <input class="input-file" type="file" accept="{{ accept }}" ng-model="file" ng-required="required" ng-disabled="isDisabled || loading" />
19
19
  <nice-loader fulldiv="true" ng-if="loading"></nice-loader>
20
20
  </div>
21
21
  </div>
@@ -29,7 +29,8 @@ angular.module('niceElements')
29
29
  isDisabled: '=',
30
30
  isInline: '=',
31
31
  help: '@',
32
- maxFileSize: '@'
32
+ maxFileSize: '@',
33
+ required: '=',
33
34
  },
34
35
 
35
36
  link: function (scope, element, attrs) {
@@ -26,26 +26,27 @@ angular.module('niceElements')
26
26
  noMargin: '@',
27
27
  onChange: '&?',
28
28
  isInline: '=',
29
- help: '@'
29
+ help: '@',
30
+ required: '='
30
31
  },
31
- controller: function($scope, gettextCatalog) {
32
+ controller: function ($scope, gettextCatalog) {
32
33
  if (!$scope.yes) { $scope.yes = gettextCatalog.getString('Yes', null, "Nice"); }
33
34
  if (!$scope.no) { $scope.no = gettextCatalog.getString('No', null, "Nice"); }
34
35
  if (!$scope.title) { $scope.title = ''; }
35
36
  if (!$scope.fieldWidth) { $scope.fieldWidth = 'col-sm-8'; }
36
37
  if (!$scope.labelWidth) { $scope.labelWidth = 'col-sm-4'; }
37
- if(!angular.isDefined($scope.model) && !angular.isDefined($scope.options)) $scope.model = !angular.isDefined($scope.defaultFalse);
38
- if(!angular.isDefined($scope.modelValue) && angular.isDefined($scope.options)) $scope.modelValue = $scope.options[0];
38
+ if (!angular.isDefined($scope.model) && !angular.isDefined($scope.options)) $scope.model = !angular.isDefined($scope.defaultFalse);
39
+ if (!angular.isDefined($scope.modelValue) && angular.isDefined($scope.options)) $scope.modelValue = $scope.options[0];
39
40
 
40
41
  $scope.defaultFalse = angular.isDefined($scope.defaultFalse);
41
42
  $scope.noMargin = angular.isDefined($scope.noMargin);
42
43
 
43
44
  $scope.buttonClass = "";
44
-
45
+
45
46
 
46
47
  // ------------------------- Set overlay button position based on passed state in $scope.model -------------------------
47
- $scope.setButtonPosition = function(state) {
48
- if(state) {
48
+ $scope.setButtonPosition = function (state) {
49
+ if (state) {
49
50
  $scope.buttonClass = "yesno-button-yes";
50
51
  } else {
51
52
  $scope.buttonClass = "yesno-button-no";
@@ -53,48 +54,48 @@ angular.module('niceElements')
53
54
  };
54
55
 
55
56
  // ------------------------- Watch for changes from outside -------------------------
56
- $scope.$watch('model', function(value_new, value_old){
57
- if(angular.isDefined($scope.model)){
57
+ $scope.$watch('model', function (value_new, value_old) {
58
+ if (angular.isDefined($scope.model)) {
58
59
  $scope.setButtonLabel($scope.model);
59
60
  $scope.setButtonPosition($scope.model);
60
61
  }
61
62
  });
62
63
 
63
64
  // ------------------------- Watch for model value -------------------------
64
- $scope.$watch('modelValue', function(value_new, value_old){
65
- if($scope.options){
65
+ $scope.$watch('modelValue', function (value_new, value_old) {
66
+ if ($scope.options) {
66
67
  $scope.model = $scope.modelValue == $scope.options[0];
67
68
  }
68
69
  });
69
70
 
70
71
  // ------------------------- Set button label -------------------------
71
- $scope.setButtonLabel = function(state){
72
+ $scope.setButtonLabel = function (state) {
72
73
  if (state) {
73
74
  $scope.state = $scope.yes;
74
75
  } else {
75
76
  $scope.state = $scope.no;
76
77
  }
77
78
  };
78
-
79
+
79
80
  // ------------------------- Set width -------------------------
80
- $scope.setWidth = function(width, el){
81
+ $scope.setWidth = function (width, el) {
81
82
  el.style.width = width;
82
83
  };
83
-
84
+
84
85
 
85
86
  // ------------------------- Switch -------------------------
86
- $scope.switch = function(){
87
- if(!$scope.isDisabled){
87
+ $scope.switch = function () {
88
+ if (!$scope.isDisabled) {
88
89
  $scope.model = !$scope.model;
89
-
90
- if($scope.options){
91
- if($scope.model){
90
+
91
+ if ($scope.options) {
92
+ if ($scope.model) {
92
93
  $scope.modelValue = $scope.options[0];
93
94
  } else {
94
95
  $scope.modelValue = $scope.options[1];
95
96
  }
96
97
  }
97
-
98
+
98
99
  if ($scope.onChange) $scope.onChange({ model: $scope.model });
99
100
  $scope.formYesno.$setDirty();
100
101
  }
@@ -7,12 +7,15 @@
7
7
  * Service in the niceElements.
8
8
  */
9
9
  angular.module('niceElements')
10
- .service('NiceService', function () {
10
+ .service('NiceService', function ($rootScope) {
11
11
  var service = {
12
12
  name: "Nice elements",
13
- version: "1.10.4",
13
+ version: "1.10.5",
14
14
  getHeader: function () {
15
15
  return {};
16
+ },
17
+ toast: function (message, type) {
18
+ $rootScope.$broadcast('toast', message, type);
16
19
  }
17
20
  };
18
21