nice-elements 1.11.0 → 1.11.1

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 (150) hide show
  1. package/.vscode/settings.json +18 -18
  2. package/CHANGELOG.md +510 -505
  3. package/LICENSE.md +21 -21
  4. package/README.md +98 -98
  5. package/bower.json +10 -10
  6. package/dist/nice.js +8397 -8356
  7. package/dist/nice.min.js +1 -1
  8. package/dist/style.css +7 -7
  9. package/dist/style.min.css +7 -7
  10. package/eslint.config.mjs +32 -32
  11. package/package.json +45 -45
  12. package/src/components/nice-button/nice-button.html +4 -4
  13. package/src/components/nice-button/nice-button.js +41 -41
  14. package/src/components/nice-button/nice-button.scss +16 -16
  15. package/src/components/nice-button-toggle/nice-button-toggle.html +9 -9
  16. package/src/components/nice-button-toggle/nice-button-toggle.js +23 -23
  17. package/src/components/nice-button-toggle/nice-button-toggle.scss +2 -2
  18. package/src/components/nice-calendar/nice-calendar.html +91 -91
  19. package/src/components/nice-calendar/nice-calendar.js +336 -336
  20. package/src/components/nice-calendar/nice-calendar.scss +285 -285
  21. package/src/components/nice-checkbox/nice-checkbox.html +5 -5
  22. package/src/components/nice-checkbox/nice-checkbox.js +34 -34
  23. package/src/components/nice-checkbox/nice-checkbox.scss +91 -91
  24. package/src/components/nice-choice/nice-choice.html +18 -18
  25. package/src/components/nice-choice/nice-choice.js +212 -212
  26. package/src/components/nice-choice/nice-choice.scss +110 -110
  27. package/src/components/nice-click-outside/nice-click-outside.js +105 -105
  28. package/src/components/nice-comment/nice-comment.html +10 -10
  29. package/src/components/nice-comment/nice-comment.js +71 -71
  30. package/src/components/nice-comment/nice-comment.scss +39 -39
  31. package/src/components/nice-date/nice-date.html +79 -79
  32. package/src/components/nice-date/nice-date.js +333 -333
  33. package/src/components/nice-date/nice-date.scss +305 -305
  34. package/src/components/nice-date-input/nice-date-input.html +41 -41
  35. package/src/components/nice-date-input/nice-date-input.js +111 -111
  36. package/src/components/nice-date-input/nice-date-input.scss +45 -45
  37. package/src/components/nice-date-range/nice-date-range.html +15 -15
  38. package/src/components/nice-date-range/nice-date-range.js +78 -78
  39. package/src/components/nice-date-range/nice-date-range.scss +390 -390
  40. package/src/components/nice-datetime-picker/nice-datetime-picker.html +29 -29
  41. package/src/components/nice-datetime-picker/nice-datetime-picker.js +89 -89
  42. package/src/components/nice-datetime-picker/nice-datetime-picker.scss +428 -428
  43. package/src/components/nice-datetimerange-picker/nice-datetimerange-picker.html +55 -55
  44. package/src/components/nice-datetimerange-picker/nice-datetimerange-picker.js +248 -248
  45. package/src/components/nice-datetimerange-picker/nice-datetimerange-picker.scss +73 -73
  46. package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.html +44 -44
  47. package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.js +175 -175
  48. package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.scss +127 -127
  49. package/src/components/nice-dropdown/nice-dropdown.html +61 -61
  50. package/src/components/nice-dropdown/nice-dropdown.js +517 -517
  51. package/src/components/nice-dropdown/nice-dropdown.scss +262 -262
  52. package/src/components/nice-dropdown-date/nice-dropdown-date.html +28 -28
  53. package/src/components/nice-dropdown-date/nice-dropdown-date.js +132 -132
  54. package/src/components/nice-dropdown-date/nice-dropdown-date.scss +87 -87
  55. package/src/components/nice-dropdown-old/nice-dropdown-old.html +44 -44
  56. package/src/components/nice-dropdown-old/nice-dropdown-old.js +330 -330
  57. package/src/components/nice-dropdown-old/nice-dropdown-old.scss +129 -129
  58. package/src/components/nice-dtp/nice-dtp.html +91 -91
  59. package/src/components/nice-dtp/nice-dtp.js +835 -835
  60. package/src/components/nice-help/nice-help.html +6 -6
  61. package/src/components/nice-help/nice-help.js +58 -58
  62. package/src/components/nice-help/nice-help.scss +78 -78
  63. package/src/components/nice-input/nice-input.html +48 -48
  64. package/src/components/nice-input/nice-input.js +246 -245
  65. package/src/components/nice-input/nice-input.scss +130 -130
  66. package/src/components/nice-label/nice-label.html +10 -10
  67. package/src/components/nice-label/nice-label.js +32 -32
  68. package/src/components/nice-loader/nice-loader.html +6 -6
  69. package/src/components/nice-loader/nice-loader.js +28 -28
  70. package/src/components/nice-loader/nice-loader.scss +47 -47
  71. package/src/components/nice-no-data/nice-no-data.html +3 -3
  72. package/src/components/nice-no-data/nice-no-data.js +27 -27
  73. package/src/components/nice-no-data/nice-no-data.scss +26 -26
  74. package/src/components/nice-notification/nice-notification.html +3 -3
  75. package/src/components/nice-notification/nice-notification.js +124 -124
  76. package/src/components/nice-notification/nice-notification.scss +66 -66
  77. package/src/components/nice-number/nice-number.html +40 -40
  78. package/src/components/nice-number/nice-number.js +172 -172
  79. package/src/components/nice-number/nice-number.scss +18 -18
  80. package/src/components/nice-on-scroll/nice-on-scroll.js +17 -17
  81. package/src/components/nice-percent/nice-percent.html +24 -24
  82. package/src/components/nice-percent/nice-percent.js +95 -95
  83. package/src/components/nice-pill/nice-pill.html +3 -3
  84. package/src/components/nice-pill/nice-pill.js +29 -29
  85. package/src/components/nice-pill/nice-pill.scss +25 -25
  86. package/src/components/nice-popup/nice-popup.html +6 -6
  87. package/src/components/nice-popup/nice-popup.js +122 -122
  88. package/src/components/nice-popup/nice-popup.scss +43 -43
  89. package/src/components/nice-progress-bar/nice-progress-bar.html +15 -15
  90. package/src/components/nice-progress-bar/nice-progress-bar.js +55 -55
  91. package/src/components/nice-progress-bar/nice-progress-bar.scss +47 -47
  92. package/src/components/nice-quantity/nice-quantity.html +22 -22
  93. package/src/components/nice-quantity/nice-quantity.js +57 -57
  94. package/src/components/nice-quantity/nice-quantity.scss +51 -51
  95. package/src/components/nice-search/nice-search.html +44 -44
  96. package/src/components/nice-search/nice-search.js +243 -243
  97. package/src/components/nice-search/nice-search.scss +90 -90
  98. package/src/components/nice-search2/nice-search2.html +32 -32
  99. package/src/components/nice-search2/nice-search2.js +267 -267
  100. package/src/components/nice-search2/nice-search2.scss +80 -80
  101. package/src/components/nice-slot/nice-slot.html +10 -10
  102. package/src/components/nice-slot/nice-slot.js +31 -31
  103. package/src/components/nice-steps/nice-steps.scss +81 -81
  104. package/src/components/nice-svgs/nice-svgs.html +1275 -1275
  105. package/src/components/nice-svgs/nice-svgs.js +19 -19
  106. package/src/components/nice-table/nice-table.html +38 -38
  107. package/src/components/nice-table/nice-table.js +60 -60
  108. package/src/components/nice-table/nice-table.scss +112 -112
  109. package/src/components/nice-time-picker/nice-time-picker.html +43 -43
  110. package/src/components/nice-time-picker/nice-time-picker.js +85 -85
  111. package/src/components/nice-time-picker/nice-time-picker.scss +37 -37
  112. package/src/components/nice-title/nice-title.html +3 -3
  113. package/src/components/nice-title/nice-title.js +21 -21
  114. package/src/components/nice-toast/nice-toast.html +2 -2
  115. package/src/components/nice-toast/nice-toast.js +56 -56
  116. package/src/components/nice-toast/nice-toast.scss +74 -74
  117. package/src/components/nice-toggle/nice-toggle.html +12 -12
  118. package/src/components/nice-toggle/nice-toggle.js +55 -55
  119. package/src/components/nice-toggle/nice-toggle.scss +131 -131
  120. package/src/components/nice-tooltip/_nice-tooltip.scss +55 -55
  121. package/src/components/nice-tooltip/nice-tooltip.js +84 -84
  122. package/src/components/nice-upload/nice-upload.html +22 -22
  123. package/src/components/nice-upload/nice-upload.js +159 -159
  124. package/src/components/nice-upload/nice-upload.scss +85 -85
  125. package/src/components/nice-view/_nice-view.scss +62 -62
  126. package/src/components/nice-view/nice-view.html +12 -12
  127. package/src/components/nice-view/nice-view.js +30 -30
  128. package/src/components/nice-virtual-scroll/_nice-virtual-scroll.scss +17 -17
  129. package/src/components/nice-virtual-scroll/nice-virtual-scroll.html +12 -12
  130. package/src/components/nice-virtual-scroll/nice-virtual-scroll.js +70 -70
  131. package/src/components/nice-wrapper/_nice-wrapper.scss +87 -87
  132. package/src/components/nice-wrapper/nice-wrapper.html +12 -12
  133. package/src/components/nice-wrapper/nice-wrapper.js +44 -44
  134. package/src/components/nice-yesno/nice-yesno.html +14 -14
  135. package/src/components/nice-yesno/nice-yesno.js +111 -111
  136. package/src/components/nice-yesno/nice-yesno.scss +95 -95
  137. package/src/filters/nice-date.js +17 -17
  138. package/src/filters/nice-highlight.js +16 -16
  139. package/src/modals/nice-multilangual-modal/nice-multilangual-modal.html +30 -30
  140. package/src/modals/nice-multilangual-modal/nice-multilangual-modal.js +67 -67
  141. package/src/modals/nice-multilangual-modal/nice-multilangual-modal.scss +19 -19
  142. package/src/nice.js +2 -2
  143. package/src/services/nice-service.js +22 -22
  144. package/src/styles/_bootstrap-variables.scss +178 -178
  145. package/src/styles/_nice-buttons.scss +612 -612
  146. package/src/styles/_nice-common.scss +471 -471
  147. package/src/styles/_nice-ngdialog.scss +85 -85
  148. package/src/styles/_nice-spacing.scss +283 -283
  149. package/src/styles/_nice.scss +70 -70
  150. package/src/styles/_variables.scss +191 -191
@@ -1,56 +1,56 @@
1
- <div class="nice-component nice-datetime-picker nice-datetimerange-picker" name="form" ng-class="{ 'margin-bottom-0': noMargin, 'nice-component-inline': isInline }">
2
- <div class="nice-dtp-background" ng-click="cancelClick()" ng-if="showDtpRange"></div>
3
-
4
- <div class="row">
5
- <!------------------------- Title ------------------------->
6
- <nice-title text="title || niceTitle" help="help" required="required" label-width="labelWidth"></nice-title>
7
-
8
- <!------------------------- Field ------------------------->
9
- <div class="nice-field col-xs-12" ng-class="[fieldWidth ? fieldWidth : 'col-sm-8', { 'nice-disabled': isDisabled }]">
10
- <!--Needed for intercepting form changes ($dirty)!-->
11
- <div ng-form="formDatetimeRangePicker"></div>
12
-
13
- <div class="dropdown">
14
- <div class="dropdown-toggle" id="dropdown{{randNum}}" role="button" ng-click="openDtpRange()">
15
- <div class="input-group">
16
- <input type="text" class="form-control" value="{{value}}" ng-disabled="isDisabled" ng-click="openDtpRange()">
17
- <span class="input-group-btn">
18
- <button type="button" class="btn btn-default btn-right" ng-disabled="isDisabled">
19
- <nice-icon ng-if="date != 'false'" icon="icon-calendar"></nice-icon>
20
- <nice-icon ng-if="date == 'false'" icon="icon-clock"></nice-icon>
21
- </button>
22
- </span>
23
- </div>
24
- </div>
25
- </div>
26
-
27
- <div class="dtp-range-wrapper" ng-show="showDtpRange">
28
-
29
- <div class="dtp-layer">
30
- <div class="dtp-buttons-left">
31
- <a class="btn btn-primary btn-block" ng-click="selectLastNDays(1)" translate translate-context="Nice">Last 24 hours</a>
32
- <a class="btn btn-primary btn-block" ng-click="selectLastNDays(7)" translate translate-context="Nice">Last 7 days</a>
33
- <a class="btn btn-primary btn-block" ng-click="selectLastMonth()" translate translate-context="Nice">Last month</a>
34
- <a class="btn btn-primary btn-block" ng-click="selectThisMonth()" translate translate-context="Nice">This month</a>
35
- </div>
36
-
37
-
38
- <div class="dtp-left">
39
- <!-- inject nice-dtp here -->
40
- <nice-dtp model="dateStart" format="{{format}}" model-format="{{modelFormat}}" date="{{date}}" time="{{time}}" width="{{width}}" enable-ok-buttons="{{enableOkButtons}}" lang="{{lang}}" min-date="{{minDate}}" max-date="{{maxDate}}" week-start="{{weekStart}}" ok-text="{{okText}}" cancel-text="{{cancelText}}" inline="true"></nice-dtp>
41
- </div>
42
- <div class="dtp-right">
43
- <!-- inject nice-dtp here -->
44
- <nice-dtp model="dateEnd" format="{{format}}" model-format="{{modelFormat}}" date="{{date}}" time="{{time}}" width="{{width}}" enable-ok-buttons="{{enableOkButtons}}" lang="{{lang}}" min-date="{{minDate}}" max-date="{{maxDate}}" week-start="{{weekStart}}" ok-text="{{okText}}" cancel-text="{{cancelText}}" inline="true"></nice-dtp>
45
- </div>
46
-
47
- <div class="dtp-buttons-bottom">
48
- <a class="btn btn-danger btn-block margin-right-20" ng-click="cancelClick()" translate translate-context="Nice">Cancel</a>
49
- <a class="btn btn-success btn-block" ng-click="okClick()" translate translate-context="Nice">OK</a>
50
- </div>
51
- </div>
52
- </div>
53
-
54
- </div>
55
- </div>
1
+ <div class="nice-component nice-datetime-picker nice-datetimerange-picker" name="form" ng-class="{ 'margin-bottom-0': noMargin, 'nice-component-inline': isInline }">
2
+ <div class="nice-dtp-background" ng-click="cancelClick()" ng-if="showDtpRange"></div>
3
+
4
+ <div class="row">
5
+ <!------------------------- Title ------------------------->
6
+ <nice-title text="title || niceTitle" help="help" required="required" label-width="labelWidth"></nice-title>
7
+
8
+ <!------------------------- Field ------------------------->
9
+ <div class="nice-field col-xs-12" ng-class="[fieldWidth ? fieldWidth : 'col-sm-8', { 'nice-disabled': isDisabled }]">
10
+ <!--Needed for intercepting form changes ($dirty)!-->
11
+ <div ng-form="formDatetimeRangePicker"></div>
12
+
13
+ <div class="dropdown">
14
+ <div class="dropdown-toggle" id="dropdown{{randNum}}" role="button" ng-click="openDtpRange()">
15
+ <div class="input-group">
16
+ <input type="text" class="form-control" value="{{value}}" ng-disabled="isDisabled" ng-click="openDtpRange()">
17
+ <span class="input-group-btn">
18
+ <button type="button" class="btn btn-default btn-right" ng-disabled="isDisabled">
19
+ <nice-icon ng-if="date != 'false'" icon="icon-calendar"></nice-icon>
20
+ <nice-icon ng-if="date == 'false'" icon="icon-clock"></nice-icon>
21
+ </button>
22
+ </span>
23
+ </div>
24
+ </div>
25
+ </div>
26
+
27
+ <div class="dtp-range-wrapper" ng-show="showDtpRange">
28
+
29
+ <div class="dtp-layer">
30
+ <div class="dtp-buttons-left">
31
+ <a class="btn btn-primary btn-block" ng-click="selectLastNDays(1)" translate translate-context="Nice">Last 24 hours</a>
32
+ <a class="btn btn-primary btn-block" ng-click="selectLastNDays(7)" translate translate-context="Nice">Last 7 days</a>
33
+ <a class="btn btn-primary btn-block" ng-click="selectLastMonth()" translate translate-context="Nice">Last month</a>
34
+ <a class="btn btn-primary btn-block" ng-click="selectThisMonth()" translate translate-context="Nice">This month</a>
35
+ </div>
36
+
37
+
38
+ <div class="dtp-left">
39
+ <!-- inject nice-dtp here -->
40
+ <nice-dtp model="dateStart" format="{{format}}" model-format="{{modelFormat}}" date="{{date}}" time="{{time}}" width="{{width}}" enable-ok-buttons="{{enableOkButtons}}" lang="{{lang}}" min-date="{{minDate}}" max-date="{{maxDate}}" week-start="{{weekStart}}" ok-text="{{okText}}" cancel-text="{{cancelText}}" inline="true"></nice-dtp>
41
+ </div>
42
+ <div class="dtp-right">
43
+ <!-- inject nice-dtp here -->
44
+ <nice-dtp model="dateEnd" format="{{format}}" model-format="{{modelFormat}}" date="{{date}}" time="{{time}}" width="{{width}}" enable-ok-buttons="{{enableOkButtons}}" lang="{{lang}}" min-date="{{minDate}}" max-date="{{maxDate}}" week-start="{{weekStart}}" ok-text="{{okText}}" cancel-text="{{cancelText}}" inline="true"></nice-dtp>
45
+ </div>
46
+
47
+ <div class="dtp-buttons-bottom">
48
+ <a class="btn btn-danger btn-block margin-right-20" ng-click="cancelClick()" translate translate-context="Nice">Cancel</a>
49
+ <a class="btn btn-success btn-block" ng-click="okClick()" translate translate-context="Nice">OK</a>
50
+ </div>
51
+ </div>
52
+ </div>
53
+
54
+ </div>
55
+ </div>
56
56
  </div>
@@ -1,249 +1,249 @@
1
- 'use strict';
2
-
3
- /**
4
- * @ngdoc directive
5
- * @name niceElements.directive:niceDatetimerangePicker
6
- * @description
7
- * # niceDatetimerangePicker
8
- */
9
- angular.module('niceElements')
10
- .directive('niceDatetimerangePicker', function (gettextCatalog) {
11
- return {
12
- scope: {
13
- modelStart: '=', // binding model
14
- modelEnd: '=', // binding model
15
- format: '@', // default: 'D.M.YYYY • H:mm', format for input label string
16
- modelFormat: '@',
17
- date: '@', // default: true, is date picker enabled?
18
- time: '@', // default: false, is time picker enabled?
19
- width: '@', // default: 300, width of entire dtp-picker in px
20
- enableOkButtons: '@', // default: false, is ok/cancel buttons enabled?
21
- lang: '@', // default: 'en', which locale to use - you must load angular locales first
22
- minDate: '@', // default: undefined
23
- maxDate: '@', // default: undefined
24
- weekStart: '@', // default: 1, which day does the week start? (0 - sunday, 1 - monday, ...)
25
- okText: '@',
26
- cancelText: '@',
27
- shortTime: '@', // default: false,
28
- niceTitle: '@',
29
- title: '@', // default: ''
30
- noMargin: '@', // default: false, if noMargin==true then entire directive can be injected inside other divs
31
- fieldWidth: '@', // default: 'col-sm-8', bootstrap classes that defines width of field
32
- labelWidth: '@', // default: 'col-sm-4', bootstrap classes that defines width of label,
33
- formatOutput: '@', // Format output or moment
34
- isDisabled: '=',
35
- help: '@',
36
- isInline: '=',
37
- onChange: '&?',
38
- required: '='
39
- },
40
- templateUrl: 'src/components/nice-datetimerange-picker/nice-datetimerange-picker.html',
41
- link: {
42
- pre: function ($scope) {
43
- console.warn("[NICE ELEMENTS] nice-datetimerange-picker component is deprecated!");
44
- // Default parameters
45
- const params = {
46
- title: '',
47
- noMargin: false,
48
- fieldWidth: 'col-sm-8',
49
- labelWidth: 'col-sm-4',
50
- format: 'D.M.YYYY • H:mm',
51
- modelFormat: 'YYYY-MM-DDTHH:mm:ss.SSS',
52
- minDate: null,
53
- maxDate: null,
54
- lang: 'en',
55
- weekStart: 1,
56
- shortTime: false,
57
- cancelText: gettextCatalog.getString('Cancel', null, 'Nice'),
58
- okText: gettextCatalog.getString('OK', null, 'Nice'),
59
- date: true,
60
- time: false,
61
- width: 300,
62
- enableOkButtons: false
63
- };
64
-
65
- if ($scope.formatOutput === undefined) $scope.formatOutput = false;
66
-
67
- const setLabelValue = function () {
68
- const _from = moment($scope.internalStart).format(params.format);
69
- const _to = moment($scope.internalEnd).format(params.format);
70
- $scope.value = _from + ' - ' + _to;
71
- };
72
-
73
- const initCurrentDates = function () {
74
- if (typeof ($scope.modelStart) === 'undefined' || $scope.modelStart === null) {
75
- let _start = moment().subtract(1, 'days');
76
- if ($scope.formatOutput) _start = _start.format(params.modelFormat);
77
- $scope.modelStart = _start;
78
-
79
- } else {
80
- if (!params.date && params.time) {
81
- // if only time
82
- const _time = moment();
83
- const i_hour = params.modelFormat.indexOf('HH:mm');
84
- const i_min = params.modelFormat.indexOf('mm');
85
- const hours = $scope.model.substring(i_hour, i_hour + 2);
86
- const minutes = $scope.model.substring(i_min, i_min + 2);
87
-
88
- if (i_hour > -1 && i_min > -1) {
89
- _time.hours(hours);
90
- _time.minutes(minutes);
91
- } else {
92
- console.error('Cannot parse current time model with passed modelFilter. Please check if you missed ' +
93
- 'modelFilter setting in directive.. Falling back to current time instead.');
94
- }
95
-
96
- $scope.dateStart = _time;
97
- } else {
98
- $scope.dateStart = moment($scope.modelStart);
99
- }
100
- }
101
-
102
- // initialize dateEnd
103
- if (typeof ($scope.modelEnd) === 'undefined' || $scope.modelEnd === null) {
104
- let _end = moment();
105
- if ($scope.formatOutput) _end = _end.format(params.modelFormat);
106
- $scope.modelEnd = _end;
107
-
108
- } else {
109
- if (!params.date && params.time) {
110
- // if only time
111
- const _time = moment();
112
- const i_hour = params.modelFormat.indexOf('HH:mm');
113
- const i_min = params.modelFormat.indexOf('mm');
114
- const hours = $scope.model.substring(i_hour, i_hour + 2);
115
- const minutes = $scope.model.substring(i_min, i_min + 2);
116
-
117
- if (i_hour > -1 && i_min > -1) {
118
- _time.hours(hours);
119
- _time.minutes(minutes);
120
- } else {
121
- console.error('Cannot parse current time model with passed modelFilter. Please check if you missed ' +
122
- 'modelFilter setting in directive.. Falling back to current time instead.');
123
- }
124
-
125
- $scope.dateEnd = _time;
126
- } else {
127
- $scope.dateEnd = moment($scope.modelEnd);
128
- }
129
- }
130
-
131
- // Fix dateEnd if it's before dateStart
132
- if ($scope.dateStart > $scope.dateEnd) {
133
- $scope.dateEnd = moment($scope.dateStart);
134
- }
135
- };
136
-
137
- // prepare attributes
138
- params.date = $scope.date === 'true';
139
- params.time = $scope.time === 'true';
140
- if ($scope.format && $scope.format != "")
141
- params.format = $scope.format;
142
- if ($scope.enableOkButtons)
143
- params.enableOkButtons = $scope.enableOkButtons === 'true';
144
- if ($scope.lang)
145
- params.lang = $scope.lang;
146
- if ($scope.minDate)
147
- params.minDate = $scope.minDate;
148
- if ($scope.maxDate)
149
- params.maxDate = $scope.maxDate;
150
- if ($scope.weekStart)
151
- params.weekStart = parseInt($scope.weekStart);
152
- if ($scope.okText)
153
- params.okText = $scope.okText;
154
- if ($scope.cancelText)
155
- params.cancelText = $scope.cancelText;
156
- if ($scope.noMargin)
157
- params.noMargin = $scope.noMargin === 'true';
158
- if ($scope.modelFormat)
159
- params.modelFormat = $scope.modelFormat;
160
-
161
- $scope.date = params.date;
162
- $scope.time = params.time;
163
-
164
- // copy attributes back to scope - for template usage
165
- $scope = angular.extend($scope, params);
166
-
167
- $scope.openDtpRange = function () {
168
- if (!$scope.isDisabled) {
169
- initCurrentDates();
170
- $scope.showDtpRange = true;
171
- }
172
- };
173
-
174
- $scope.okClick = function () {
175
- setLabelValue();
176
- let _start = moment($scope.internalStart, params.modelFormat);
177
- if ($scope.formatOutput) _start = _start.format(params.modelFormat);
178
- $scope.modelStart = _start;
179
-
180
- let _end = moment($scope.internalEnd, params.modelFormat);
181
- if ($scope.formatOutput) _end = _end.format(params.modelFormat);
182
- $scope.modelEnd = _end;
183
-
184
- //$scope.modelStart = angular.copy($scope.internalStart);
185
- //$scope.modelEnd = angular.copy($scope.internalEnd);
186
- $scope.showDtpRange = false;
187
-
188
- if ($scope.onChange) $scope.onChange({ modelStart: $scope.modelStart, modelEnd: $scope.modelEnd });
189
- };
190
-
191
- $scope.cancelClick = function () {
192
- $scope.showDtpRange = false;
193
- //$scope.internalStart = angular.copy($scope.modelStart);
194
- //$scope.internalEnd = angular.copy($scope.modelEnd);
195
- let _start = moment($scope.modelStart);
196
- if ($scope.formatOutput) _start = _start.format(params.modelFormat);
197
- let _end = moment($scope.modelEnd);
198
- if ($scope.formatOutput) _end = _end.format(params.modelFormat);
199
-
200
- $scope.internalStart = _start;
201
- $scope.internalEnd = _end;
202
- setLabelValue();
203
- };
204
-
205
- $scope.selectLastNDays = function (days) {
206
- $scope.dateStart = moment().subtract(days, 'days');
207
- $scope.dateEnd = moment();
208
- $scope.internalStart = $scope.dateStart;
209
- $scope.internalEnd = $scope.dateEnd;
210
- setLabelValue();
211
- };
212
-
213
- $scope.selectLastMonth = function () {
214
- $scope.dateStart = moment().subtract(1, 'months');
215
- $scope.dateEnd = moment();
216
- $scope.internalStart = $scope.dateStart;
217
- $scope.internalEnd = $scope.dateEnd;
218
- setLabelValue();
219
- };
220
-
221
- $scope.selectThisMonth = function () {
222
- $scope.dateStart = moment().date(1).hours(0).minutes(0).seconds(0).milliseconds(0);
223
- $scope.dateEnd = moment().endOf('month');
224
- $scope.internalStart = $scope.dateStart;
225
- $scope.internalEnd = $scope.dateEnd;
226
- setLabelValue();
227
- };
228
-
229
-
230
- //$scope.$on('dateSelected', function () {
231
- // $scope.formDatetimePicker.$setDirty();
232
- // console.log('date selected');
233
- //});
234
-
235
- $scope.$watchGroup(['dateStart', 'dateEnd'], function (newValues) {
236
- $scope.internalStart = moment(newValues[0]);
237
- $scope.internalEnd = moment(newValues[1]);
238
- setLabelValue();
239
- });
240
-
241
- $scope.$watchGroup(['modelStart', 'modelEnd'], function () {
242
- initCurrentDates();
243
- });
244
-
245
- }
246
- }
247
- };
248
-
1
+ 'use strict';
2
+
3
+ /**
4
+ * @ngdoc directive
5
+ * @name niceElements.directive:niceDatetimerangePicker
6
+ * @description
7
+ * # niceDatetimerangePicker
8
+ */
9
+ angular.module('niceElements')
10
+ .directive('niceDatetimerangePicker', function (gettextCatalog) {
11
+ return {
12
+ scope: {
13
+ modelStart: '=', // binding model
14
+ modelEnd: '=', // binding model
15
+ format: '@', // default: 'D.M.YYYY • H:mm', format for input label string
16
+ modelFormat: '@',
17
+ date: '@', // default: true, is date picker enabled?
18
+ time: '@', // default: false, is time picker enabled?
19
+ width: '@', // default: 300, width of entire dtp-picker in px
20
+ enableOkButtons: '@', // default: false, is ok/cancel buttons enabled?
21
+ lang: '@', // default: 'en', which locale to use - you must load angular locales first
22
+ minDate: '@', // default: undefined
23
+ maxDate: '@', // default: undefined
24
+ weekStart: '@', // default: 1, which day does the week start? (0 - sunday, 1 - monday, ...)
25
+ okText: '@',
26
+ cancelText: '@',
27
+ shortTime: '@', // default: false,
28
+ niceTitle: '@',
29
+ title: '@', // default: ''
30
+ noMargin: '@', // default: false, if noMargin==true then entire directive can be injected inside other divs
31
+ fieldWidth: '@', // default: 'col-sm-8', bootstrap classes that defines width of field
32
+ labelWidth: '@', // default: 'col-sm-4', bootstrap classes that defines width of label,
33
+ formatOutput: '@', // Format output or moment
34
+ isDisabled: '=',
35
+ help: '@',
36
+ isInline: '=',
37
+ onChange: '&?',
38
+ required: '='
39
+ },
40
+ templateUrl: 'src/components/nice-datetimerange-picker/nice-datetimerange-picker.html',
41
+ link: {
42
+ pre: function ($scope) {
43
+ console.warn("[NICE ELEMENTS] nice-datetimerange-picker component is deprecated!");
44
+ // Default parameters
45
+ const params = {
46
+ title: '',
47
+ noMargin: false,
48
+ fieldWidth: 'col-sm-8',
49
+ labelWidth: 'col-sm-4',
50
+ format: 'D.M.YYYY • H:mm',
51
+ modelFormat: 'YYYY-MM-DDTHH:mm:ss.SSS',
52
+ minDate: null,
53
+ maxDate: null,
54
+ lang: 'en',
55
+ weekStart: 1,
56
+ shortTime: false,
57
+ cancelText: gettextCatalog.getString('Cancel', null, 'Nice'),
58
+ okText: gettextCatalog.getString('OK', null, 'Nice'),
59
+ date: true,
60
+ time: false,
61
+ width: 300,
62
+ enableOkButtons: false
63
+ };
64
+
65
+ if ($scope.formatOutput === undefined) $scope.formatOutput = false;
66
+
67
+ const setLabelValue = function () {
68
+ const _from = moment($scope.internalStart).format(params.format);
69
+ const _to = moment($scope.internalEnd).format(params.format);
70
+ $scope.value = _from + ' - ' + _to;
71
+ };
72
+
73
+ const initCurrentDates = function () {
74
+ if (typeof ($scope.modelStart) === 'undefined' || $scope.modelStart === null) {
75
+ let _start = moment().subtract(1, 'days');
76
+ if ($scope.formatOutput) _start = _start.format(params.modelFormat);
77
+ $scope.modelStart = _start;
78
+
79
+ } else {
80
+ if (!params.date && params.time) {
81
+ // if only time
82
+ const _time = moment();
83
+ const i_hour = params.modelFormat.indexOf('HH:mm');
84
+ const i_min = params.modelFormat.indexOf('mm');
85
+ const hours = $scope.model.substring(i_hour, i_hour + 2);
86
+ const minutes = $scope.model.substring(i_min, i_min + 2);
87
+
88
+ if (i_hour > -1 && i_min > -1) {
89
+ _time.hours(hours);
90
+ _time.minutes(minutes);
91
+ } else {
92
+ console.error('Cannot parse current time model with passed modelFilter. Please check if you missed ' +
93
+ 'modelFilter setting in directive.. Falling back to current time instead.');
94
+ }
95
+
96
+ $scope.dateStart = _time;
97
+ } else {
98
+ $scope.dateStart = moment($scope.modelStart);
99
+ }
100
+ }
101
+
102
+ // initialize dateEnd
103
+ if (typeof ($scope.modelEnd) === 'undefined' || $scope.modelEnd === null) {
104
+ let _end = moment();
105
+ if ($scope.formatOutput) _end = _end.format(params.modelFormat);
106
+ $scope.modelEnd = _end;
107
+
108
+ } else {
109
+ if (!params.date && params.time) {
110
+ // if only time
111
+ const _time = moment();
112
+ const i_hour = params.modelFormat.indexOf('HH:mm');
113
+ const i_min = params.modelFormat.indexOf('mm');
114
+ const hours = $scope.model.substring(i_hour, i_hour + 2);
115
+ const minutes = $scope.model.substring(i_min, i_min + 2);
116
+
117
+ if (i_hour > -1 && i_min > -1) {
118
+ _time.hours(hours);
119
+ _time.minutes(minutes);
120
+ } else {
121
+ console.error('Cannot parse current time model with passed modelFilter. Please check if you missed ' +
122
+ 'modelFilter setting in directive.. Falling back to current time instead.');
123
+ }
124
+
125
+ $scope.dateEnd = _time;
126
+ } else {
127
+ $scope.dateEnd = moment($scope.modelEnd);
128
+ }
129
+ }
130
+
131
+ // Fix dateEnd if it's before dateStart
132
+ if ($scope.dateStart > $scope.dateEnd) {
133
+ $scope.dateEnd = moment($scope.dateStart);
134
+ }
135
+ };
136
+
137
+ // prepare attributes
138
+ params.date = $scope.date === 'true';
139
+ params.time = $scope.time === 'true';
140
+ if ($scope.format && $scope.format != "")
141
+ params.format = $scope.format;
142
+ if ($scope.enableOkButtons)
143
+ params.enableOkButtons = $scope.enableOkButtons === 'true';
144
+ if ($scope.lang)
145
+ params.lang = $scope.lang;
146
+ if ($scope.minDate)
147
+ params.minDate = $scope.minDate;
148
+ if ($scope.maxDate)
149
+ params.maxDate = $scope.maxDate;
150
+ if ($scope.weekStart)
151
+ params.weekStart = parseInt($scope.weekStart);
152
+ if ($scope.okText)
153
+ params.okText = $scope.okText;
154
+ if ($scope.cancelText)
155
+ params.cancelText = $scope.cancelText;
156
+ if ($scope.noMargin)
157
+ params.noMargin = $scope.noMargin === 'true';
158
+ if ($scope.modelFormat)
159
+ params.modelFormat = $scope.modelFormat;
160
+
161
+ $scope.date = params.date;
162
+ $scope.time = params.time;
163
+
164
+ // copy attributes back to scope - for template usage
165
+ $scope = angular.extend($scope, params);
166
+
167
+ $scope.openDtpRange = function () {
168
+ if (!$scope.isDisabled) {
169
+ initCurrentDates();
170
+ $scope.showDtpRange = true;
171
+ }
172
+ };
173
+
174
+ $scope.okClick = function () {
175
+ setLabelValue();
176
+ let _start = moment($scope.internalStart, params.modelFormat);
177
+ if ($scope.formatOutput) _start = _start.format(params.modelFormat);
178
+ $scope.modelStart = _start;
179
+
180
+ let _end = moment($scope.internalEnd, params.modelFormat);
181
+ if ($scope.formatOutput) _end = _end.format(params.modelFormat);
182
+ $scope.modelEnd = _end;
183
+
184
+ //$scope.modelStart = angular.copy($scope.internalStart);
185
+ //$scope.modelEnd = angular.copy($scope.internalEnd);
186
+ $scope.showDtpRange = false;
187
+
188
+ if ($scope.onChange) $scope.onChange({ modelStart: $scope.modelStart, modelEnd: $scope.modelEnd });
189
+ };
190
+
191
+ $scope.cancelClick = function () {
192
+ $scope.showDtpRange = false;
193
+ //$scope.internalStart = angular.copy($scope.modelStart);
194
+ //$scope.internalEnd = angular.copy($scope.modelEnd);
195
+ let _start = moment($scope.modelStart);
196
+ if ($scope.formatOutput) _start = _start.format(params.modelFormat);
197
+ let _end = moment($scope.modelEnd);
198
+ if ($scope.formatOutput) _end = _end.format(params.modelFormat);
199
+
200
+ $scope.internalStart = _start;
201
+ $scope.internalEnd = _end;
202
+ setLabelValue();
203
+ };
204
+
205
+ $scope.selectLastNDays = function (days) {
206
+ $scope.dateStart = moment().subtract(days, 'days');
207
+ $scope.dateEnd = moment();
208
+ $scope.internalStart = $scope.dateStart;
209
+ $scope.internalEnd = $scope.dateEnd;
210
+ setLabelValue();
211
+ };
212
+
213
+ $scope.selectLastMonth = function () {
214
+ $scope.dateStart = moment().subtract(1, 'months');
215
+ $scope.dateEnd = moment();
216
+ $scope.internalStart = $scope.dateStart;
217
+ $scope.internalEnd = $scope.dateEnd;
218
+ setLabelValue();
219
+ };
220
+
221
+ $scope.selectThisMonth = function () {
222
+ $scope.dateStart = moment().date(1).hours(0).minutes(0).seconds(0).milliseconds(0);
223
+ $scope.dateEnd = moment().endOf('month');
224
+ $scope.internalStart = $scope.dateStart;
225
+ $scope.internalEnd = $scope.dateEnd;
226
+ setLabelValue();
227
+ };
228
+
229
+
230
+ //$scope.$on('dateSelected', function () {
231
+ // $scope.formDatetimePicker.$setDirty();
232
+ // console.log('date selected');
233
+ //});
234
+
235
+ $scope.$watchGroup(['dateStart', 'dateEnd'], function (newValues) {
236
+ $scope.internalStart = moment(newValues[0]);
237
+ $scope.internalEnd = moment(newValues[1]);
238
+ setLabelValue();
239
+ });
240
+
241
+ $scope.$watchGroup(['modelStart', 'modelEnd'], function () {
242
+ initCurrentDates();
243
+ });
244
+
245
+ }
246
+ }
247
+ };
248
+
249
249
  });