nice-elements 1.14.1 → 1.15.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 (56) hide show
  1. package/.claude/launch.json +11 -0
  2. package/CHANGELOG.md +28 -0
  3. package/CLAUDE.md +89 -0
  4. package/README.md +3 -1
  5. package/bower.json +1 -1
  6. package/dist/nice.js +707 -112
  7. package/dist/nice.min.js +1 -1
  8. package/dist/style.css +198 -11
  9. package/dist/style.css.map +1 -1
  10. package/dist/style.min.css +2 -2
  11. package/package.json +2 -2
  12. package/src/components/nice-badges-list/nice-badges-list.html +13 -0
  13. package/src/components/nice-badges-list/nice-badges-list.js +135 -0
  14. package/src/components/nice-badges-list/nice-badges-list.scss +75 -0
  15. package/src/components/nice-calendar/nice-calendar.html +4 -0
  16. package/src/components/nice-checkbox/nice-checkbox.html +11 -5
  17. package/src/components/nice-checkbox/nice-checkbox.js +1 -0
  18. package/src/components/nice-checkbox/nice-checkbox.scss +7 -0
  19. package/src/components/nice-choice/nice-choice.js +11 -0
  20. package/src/components/nice-date/nice-date.html +10 -1
  21. package/src/components/nice-date/nice-date.js +50 -1
  22. package/src/components/nice-date/nice-date.scss +1 -0
  23. package/src/components/nice-date-input/nice-date-input.js +1 -1
  24. package/src/components/nice-date-range/nice-date-range.html +1 -1
  25. package/src/components/nice-date-range/nice-date-range.js +7 -7
  26. package/src/components/nice-datetime-picker/nice-datetime-picker.html +6 -3
  27. package/src/components/nice-datetime-picker/nice-datetime-picker.js +7 -2
  28. package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.html +2 -2
  29. package/src/components/nice-dialog/nice-dialog.html +16 -0
  30. package/src/components/nice-dialog/nice-dialog.js +47 -0
  31. package/src/components/nice-dialog/nice-dialog.scss +126 -0
  32. package/src/components/nice-dropdown/nice-dropdown.js +16 -4
  33. package/src/components/nice-dropdown/nice-dropdown.scss +0 -11
  34. package/src/components/nice-dropdown-date/nice-dropdown-date.js +3 -1
  35. package/src/components/nice-input/nice-input.js +12 -8
  36. package/src/components/nice-no-data/nice-no-data.js +3 -1
  37. package/src/components/nice-number/nice-number.html +23 -9
  38. package/src/components/nice-number/nice-number.js +81 -12
  39. package/src/components/nice-percent/nice-percent.js +15 -6
  40. package/src/components/nice-popup/nice-popup.js +2 -2
  41. package/src/components/nice-search/nice-search.html +2 -4
  42. package/src/components/nice-search/nice-search.js +40 -20
  43. package/src/components/nice-search2/nice-search2.html +1 -1
  44. package/src/components/nice-search2/nice-search2.js +1 -0
  45. package/src/components/nice-svgs/nice-svgs.html +165 -20
  46. package/src/components/nice-table/nice-table.js +9 -4
  47. package/src/components/nice-toggle/nice-toggle.html +3 -0
  48. package/src/components/nice-upload/nice-upload.html +1 -1
  49. package/src/components/nice-view/_nice-view.scss +10 -1
  50. package/src/components/nice-view/nice-view.html +1 -0
  51. package/src/components/nice-wrapper/nice-wrapper.js +3 -1
  52. package/src/components/nice-yesno/nice-yesno.html +3 -0
  53. package/src/components/nice-yesno/nice-yesno.js +4 -2
  54. package/src/services/nice-service.js +16 -1
  55. package/src/styles/_nice-common.scss +17 -0
  56. package/src/styles/_nice.scss +2 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nice-elements",
3
- "version": "1.14.1",
3
+ "version": "1.15.1",
4
4
  "description": "Nice elements used in olaii angular 1.x webapps.",
5
5
  "main": "dist/nice.js",
6
6
  "license": "MIT",
@@ -42,4 +42,4 @@
42
42
  "load-grunt-tasks": "5.1.0",
43
43
  "sass": "1.107.1"
44
44
  }
45
- }
45
+ }
@@ -0,0 +1,13 @@
1
+ <div class="nice-badges-list" ng-class="{ 'nice-badges-list-full-width': fullWidth, 'nice-badges-list-expanded': expanded }">
2
+ <!-- Full width: all badges are rendered so they can be measured, the overflowing ones are hidden -->
3
+ <div class="nice-badge nice-badge-item" ng-if="fullWidth" ng-class="[badgeClass, { 'nice-badge-hidden': !expanded && $index >= visibleCount }]" ng-repeat="item in items track by $index" title="{{ getLabel(item) }}">{{ getLabel(item) }}</div>
4
+
5
+ <!-- Fixed limit -->
6
+ <div class="nice-badge nice-badge-item" ng-if="!fullWidth" ng-class="badgeClass" ng-repeat="item in items | limitTo:(expanded ? items.length : getLimit()) track by $index">{{ getLabel(item) }}</div>
7
+
8
+ <!-- More / less toggle -->
9
+ <div class="nice-badge nice-badge-more" ng-show="getHiddenCount() > 0" ng-click="toggle()">
10
+ <span ng-if="!expanded" translate translate-context="Nice" translate-n="getHiddenCount()" translate-plural="+{{$count}} more">+{{$count}} more</span>
11
+ <span ng-if="expanded" translate translate-context="Nice">Show less</span>
12
+ </div>
13
+ </div>
@@ -0,0 +1,135 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * @ngdoc directive
5
+ * @name niceElements.directive:niceBadgesList
6
+ * @description
7
+ * # niceBadgesList
8
+ * Row of small badges that shows the first few items and collapses the rest into a "+X more" toggle.
9
+ * `label` is an expression with `item` in scope, e.g. `label="item.name"`; without it the item itself is shown.
10
+ *
11
+ * With `full-width="true"` the list fills the available width: when collapsed it stays on one line and shows
12
+ * as many badges as fit (the `limit` is ignored), expanding shows all badges on multiple lines.
13
+ *
14
+ * Usage:
15
+ * <nice-badges-list items="row.ticket_types" label="item.name" limit="3" badge-class="badge-color-1"></nice-badges-list>
16
+ * <nice-badges-list items="row.ticket_types" label="item.name" full-width="true"></nice-badges-list>
17
+ */
18
+ angular.module('niceElements')
19
+ .directive('niceBadgesList', function ($timeout) {
20
+ return {
21
+ templateUrl: 'src/components/nice-badges-list/nice-badges-list.html',
22
+ restrict: 'E',
23
+ scope: {
24
+ items: '<',
25
+ label: '&?',
26
+ limit: '<?',
27
+ fullWidth: '<?',
28
+ badgeClass: '@?'
29
+ },
30
+ link: function (scope, element) {
31
+ scope.expanded = false;
32
+ scope.visibleCount = 0;
33
+
34
+ scope.getItemsLength = function () {
35
+ return scope.items ? scope.items.length : 0;
36
+ };
37
+
38
+ scope.getLimit = function () {
39
+ if (scope.fullWidth) return scope.visibleCount;
40
+ return angular.isNumber(scope.limit) ? scope.limit : 3;
41
+ };
42
+
43
+ scope.getHiddenCount = function () {
44
+ return Math.max(scope.getItemsLength() - scope.getLimit(), 0);
45
+ };
46
+
47
+ scope.getLabel = function (item) {
48
+ return scope.label ? scope.label({ item: item }) : item;
49
+ };
50
+
51
+ scope.toggle = function () {
52
+ scope.expanded = !scope.expanded;
53
+ };
54
+
55
+
56
+ // ---------- Full width: fit as many badges as possible in one line ----------
57
+
58
+ // Measures all badges laid out in a single line and returns how many fit next to the "+X more" toggle
59
+ function measureVisibleCount() {
60
+ var container = element[0].querySelector('.nice-badges-list');
61
+ if (!container) return 0;
62
+
63
+ container.classList.add('nice-badges-list-measuring');
64
+
65
+ var badges = container.querySelectorAll('.nice-badge-item');
66
+ var more = container.querySelector('.nice-badge-more');
67
+ var available = container.clientWidth;
68
+ var gap = parseFloat(window.getComputedStyle(container).columnGap) || 0;
69
+ var moreWidth = more ? more.getBoundingClientRect().width + gap : 0;
70
+
71
+ var widths = [];
72
+ var total = 0;
73
+ for (var i = 0; i < badges.length; i++) {
74
+ widths.push(badges[i].getBoundingClientRect().width);
75
+ total += widths[i] + (i > 0 ? gap : 0);
76
+ }
77
+
78
+ container.classList.remove('nice-badges-list-measuring');
79
+
80
+ // Everything fits, no toggle needed
81
+ if (total <= available) return widths.length;
82
+
83
+ var count = 0;
84
+ var used = moreWidth;
85
+ for (var j = 0; j < widths.length; j++) {
86
+ used += widths[j] + (j > 0 ? gap : 0);
87
+ if (used > available) break;
88
+ count++;
89
+ }
90
+
91
+ // Always show at least one badge (it gets truncated if it's too wide)
92
+ return Math.max(count, Math.min(1, widths.length));
93
+ }
94
+
95
+ function calculate() {
96
+ if (!scope.fullWidth) return;
97
+ var count = measureVisibleCount();
98
+ if (count !== scope.visibleCount) {
99
+ scope.visibleCount = count;
100
+ // The "+X more" label width depends on the count, so check once more after it re-renders
101
+ $timeout(function () {
102
+ var recount = measureVisibleCount();
103
+ if (recount < scope.visibleCount) scope.visibleCount = recount;
104
+ });
105
+ }
106
+ }
107
+
108
+ var lastWidth = null;
109
+ var resizeObserver = new ResizeObserver(function (entries) {
110
+ var width = entries[0].contentRect.width;
111
+ if (width === lastWidth) return;
112
+ lastWidth = width;
113
+ scope.$applyAsync(calculate);
114
+ });
115
+
116
+ scope.$watch('fullWidth', function (fullWidth) {
117
+ if (fullWidth) {
118
+ resizeObserver.observe(element[0]);
119
+ $timeout(calculate);
120
+ } else {
121
+ resizeObserver.disconnect();
122
+ lastWidth = null;
123
+ }
124
+ });
125
+
126
+ scope.$watchCollection('items', function () {
127
+ if (scope.fullWidth) $timeout(calculate);
128
+ });
129
+
130
+ scope.$on('$destroy', function () {
131
+ resizeObserver.disconnect();
132
+ });
133
+ }
134
+ };
135
+ });
@@ -0,0 +1,75 @@
1
+ nice-badges-list {
2
+ display: block;
3
+ min-width: 0;
4
+ }
5
+
6
+ .nice-badges-list {
7
+ display: flex;
8
+ flex-wrap: wrap;
9
+ gap: 0.2rem;
10
+
11
+ // Full width collapsed: a single line, overflowing badges are hidden
12
+ &.nice-badges-list-full-width:not(.nice-badges-list-expanded) {
13
+ flex-wrap: nowrap;
14
+ overflow: hidden;
15
+
16
+ .nice-badge-item {
17
+ min-width: 0;
18
+ flex-shrink: 1;
19
+ }
20
+
21
+ .nice-badge-hidden {
22
+ display: none;
23
+ }
24
+ }
25
+
26
+ // Temporary state while badge widths are measured
27
+ &.nice-badges-list-measuring.nice-badges-list-full-width {
28
+ flex-wrap: nowrap;
29
+
30
+ .nice-badge-item {
31
+ flex-shrink: 0;
32
+ }
33
+
34
+ .nice-badge-hidden {
35
+ display: block;
36
+ }
37
+
38
+ .nice-badge-more {
39
+ display: inline-flex !important;
40
+ }
41
+ }
42
+ }
43
+
44
+ .nice-badge {
45
+ display: inline-flex;
46
+ align-items: center;
47
+ justify-content: center;
48
+ padding: 3px 7px;
49
+ font-size: 0.7em;
50
+ line-height: 1;
51
+ white-space: nowrap;
52
+ border-radius: var(--nice-border-radius-small);
53
+ background: var(--nice-primary-color-plain);
54
+ color: var(--nice-primary-color);
55
+ }
56
+
57
+ .nice-badge-item {
58
+ overflow: hidden;
59
+ text-overflow: ellipsis;
60
+ // inline-flex doesn't ellipsize text nodes, so use block for the item itself
61
+ display: block;
62
+ }
63
+
64
+ // Transparent "+X more" toggle shown after a collapsed list of badges
65
+ .nice-badge-more {
66
+ flex-shrink: 0;
67
+ background: transparent;
68
+ color: var(--nice-font-color-lighter);
69
+ cursor: pointer;
70
+ user-select: none;
71
+
72
+ &:hover {
73
+ color: var(--nice-font-color);
74
+ }
75
+ }
@@ -7,6 +7,10 @@
7
7
  <div class="nice-field col-xs-12" ng-class="[fieldWidth ? fieldWidth : 'col-sm-8', { 'nice-disabled': isDisabled }]">
8
8
  <div class="disabled-shield" ng-if="isDisabled"></div>
9
9
 
10
+ <!-- Only for form validation (start and end date have to be set when required) -->
11
+ <input class="hidden-input" ng-model="startDate" ng-required="required" tabindex="-1" />
12
+ <input class="hidden-input" ng-model="endDate" ng-required="required" tabindex="-1" />
13
+
10
14
  <div class="nice-calendar-wrapper">
11
15
  <div class="nice-calendar-weeks">
12
16
  <div class="nice-calendar-header">
@@ -9,12 +9,18 @@
9
9
  }"
10
10
  ng-click="toggle()"
11
11
  >
12
- <button type="button" class="btn nice-checkbox-checkbox" ng-disabled="isDisabled">
13
- <nice-icon ng-if="model" class="nice-checkbox-check" icon="icon-check"></nice-icon>
14
- <nice-icon ng-if="!model && indeterminate" class="nice-checkbox-check" icon="icon-minus"></nice-icon>
15
- </button>
12
+ <span class="nice-checkbox-box">
13
+ <button type="button" class="btn nice-checkbox-checkbox" ng-disabled="isDisabled">
14
+ <nice-icon ng-if="model" class="nice-checkbox-check" icon="icon-check"></nice-icon>
15
+ <nice-icon ng-if="!model && indeterminate" class="nice-checkbox-check" icon="icon-minus"></nice-icon>
16
+ </button>
17
+
18
+ <!-- Only for form validation (checkbox must be checked when required).
19
+ Placed next to the box so the browser "required" bubble points at it. -->
20
+ <input type="checkbox" class="hidden-input" ng-model="model" ng-required="required" tabindex="-1" />
21
+ </span>
16
22
  <div class="nice-checkbox-info" ng-transclude>
17
- <nice-title text="title || niceTitle" help="help" required="required" description="description" description="niceDescription" label-width="col-xs-12"></nice-title>
23
+ <nice-title text="title || niceTitle" help="help" required="required" description="niceDescription" label-width="col-xs-12"></nice-title>
18
24
  <!-- <div ng-if="title || niceTitle" class="nice-checkbox-message" ng-class="{ 'nice-disabled': isDisabled }">{{ title || niceTitle }}</div> -->
19
25
  <!-- <div ng-if="niceDescription" class="nice-checkbox-description" ng-class="{ 'nice-disabled': isDisabled }">{{ niceDescription }}</div> -->
20
26
  </div>
@@ -24,6 +24,7 @@ angular.module('niceElements')
24
24
  onChange: '&?',
25
25
  help: '@',
26
26
  isDisabled: '=',
27
+ required: '=', // Checkbox must be checked
27
28
  },
28
29
  controller: function ($scope) {
29
30
  if ($scope.model === undefined) $scope.model = false;
@@ -16,6 +16,13 @@
16
16
  }
17
17
  }
18
18
 
19
+ // Wraps the box and its hidden validation input
20
+ .nice-checkbox-box {
21
+ position: relative;
22
+ display: flex;
23
+ flex-shrink: 0;
24
+ }
25
+
19
26
  .nice-checkbox-checkbox {
20
27
  height: 20px;
21
28
  width: 20px;
@@ -29,6 +29,7 @@ angular.module('niceElements')
29
29
  multiple: '=?',
30
30
  help: '@',
31
31
  isInline: '=?',
32
+ required: '=?',
32
33
  onChange: '&?'
33
34
  },
34
35
  controller: function ($attrs, $scope) {
@@ -208,6 +209,16 @@ angular.module('niceElements')
208
209
  }
209
210
  });
210
211
 
212
+ // Required: something has to be selected (at least one item when multiple)
213
+ const checkRequired = function () {
214
+ if (!$scope.formChoice) return;
215
+ let hasValue = $scope.model !== null && angular.isDefined($scope.model);
216
+ if ($scope.multiple) hasValue = !!($scope.model && $scope.model.length);
217
+ $scope.formChoice.$setValidity('required', !$scope.required || hasValue);
218
+ };
219
+ $scope.$watchCollection('model', checkRequired);
220
+ $scope.$watch('required', checkRequired);
221
+
211
222
  }
212
223
  };
213
224
  });
@@ -11,7 +11,16 @@
11
11
 
12
12
  <!------------------------------ Input ------------------------------>
13
13
  <div class="nice-date-button input-group" ng-class="{ 'open': isOpen }" ng-show="!inline" ng-click="toggleOpen()">
14
- <input type="text" class="form-control" value="{{ innerDate.value }}" placeholder="{{ placeholder }}" readonly="readonly" ng-disabled="isDisabled" />
14
+ <input
15
+ type="text"
16
+ class="form-control"
17
+ ng-model="innerDate.value"
18
+ placeholder="{{ placeholder }}"
19
+ ng-required="required"
20
+ ng-disabled="isDisabled"
21
+ ng-blur="parseTypedDate()"
22
+ ng-keydown="typedDateKeydown($event)"
23
+ />
15
24
  <span class="input-group-btn">
16
25
  <button type="button" class="btn btn-default btn-right" ng-disabled="isDisabled" ng-if="!(model && nullable)">
17
26
  <nice-icon icon="icon-calendar"></nice-icon>
@@ -36,7 +36,9 @@ angular.module('niceElements')
36
36
  placeholder: '@',
37
37
  placement: '@', // Describes the preferred placement of the popper
38
38
  },
39
- controller: function ($scope, $element, $timeout, gettextCatalog) {
39
+ controller: function ($scope, $attrs, $element, $timeout, gettextCatalog, NiceService) {
40
+ NiceService.bindFlag($scope, $attrs, 'inline');
41
+
40
42
  $scope.isOpen = false;
41
43
  if (!$scope.placement) { $scope.placement = "bottom-start"; }
42
44
  if (!$scope.placeholder) { $scope.placeholder = gettextCatalog.getString("Select date", null, "Nice"); }
@@ -158,6 +160,53 @@ angular.module('niceElements')
158
160
  };
159
161
 
160
162
 
163
+ // ------------------ Typed date ------------------
164
+ // Formats accepted when the date is typed in (strict parsing)
165
+ const TYPED_DATE_FORMATS = ['D.M.YYYY', 'D.M.YY', 'D.M.', 'D.M'];
166
+ const TYPED_TIME_FORMATS = ['D.M.YYYY H:mm', 'D.M.YY H:mm', 'D.M. H:mm', 'D.M H:mm'];
167
+
168
+ // Parse typed text on blur (or Enter). Invalid or out of range text reverts to the current model.
169
+ $scope.parseTypedDate = function () {
170
+ const text = ($scope.innerDate.value || "").replace("•", " ").replace(/\s+/g, " ").trim();
171
+
172
+ // Nothing changed
173
+ if (text == $scope.formatDate($scope.model).replace("•", " ").replace(/\s+/g, " ")) return;
174
+
175
+ // Empty text clears the model, unless the field can't be empty
176
+ if (!text) {
177
+ if ($scope.nullable || $scope.required) $scope.setTypedDate(null);
178
+ else $scope.innerDate.value = $scope.formatDate($scope.model);
179
+ return;
180
+ }
181
+
182
+ const formats = $scope.time ? TYPED_TIME_FORMATS.concat(TYPED_DATE_FORMATS) : TYPED_DATE_FORMATS;
183
+ const date = moment(text, formats, true);
184
+ if (!date.isValid() || _isDisabledDate(date)) {
185
+ $scope.innerDate.value = $scope.formatDate($scope.model);
186
+ return;
187
+ }
188
+
189
+ if (!$scope.time) $scope._removeTime(date);
190
+ $scope.setTypedDate(date);
191
+ };
192
+
193
+ $scope.setTypedDate = function (date) {
194
+ $scope.model = date;
195
+ $scope.innerDate.value = $scope.formatDate($scope.model);
196
+ $timeout(function () {
197
+ if ($scope.onChange) $scope.onChange({ model: $scope.model });
198
+ $scope.forma.$setDirty();
199
+ });
200
+ };
201
+
202
+ // Enter parses the text first, so the form is submitted with the typed date.
203
+ // Enter and Tab also close the picker (it isn't closed on blur, because clicking a day blurs the input).
204
+ $scope.typedDateKeydown = function (event) {
205
+ if (event.keyCode == 13) $scope.parseTypedDate();
206
+ if (event.keyCode == 13 || event.keyCode == 9) $scope.isOpen = false;
207
+ };
208
+
209
+
161
210
  // ------------------ Clear ------------------
162
211
  $scope.clear = function () {
163
212
  $scope.isOpen = false;
@@ -27,6 +27,7 @@
27
27
 
28
28
  .form-control {
29
29
  text-overflow: ellipsis;
30
+ cursor: text;
30
31
  }
31
32
  }
32
33
 
@@ -41,7 +41,7 @@ angular.module('niceElements')
41
41
  if ($scope.time === undefined) $scope.time = true;
42
42
  if (!$scope.placeholderDate) { $scope.placeholderDate = gettextCatalog.getString("••.••.••••", null, "Nice"); }
43
43
  if (!$scope.placeholderTime) { $scope.placeholderTime = gettextCatalog.getString("••:••", null, "Nice"); }
44
- if (!$scope.model && !$scope.nullable) $scope.model = moment($scope.model) || moment().set({ 'second': 0, 'millisecond': 0 });
44
+ if (!$scope.model && !$scope.nullable) $scope.model = moment().set({ 'second': 0, 'millisecond': 0 });
45
45
  $scope.inner = {
46
46
  timeModel: angular.copy($scope.model || moment()),
47
47
  dateModel: angular.copy($scope.model || moment()),
@@ -6,7 +6,7 @@
6
6
  <!------------------------- Field ------------------------->
7
7
  <div class="nice-field col-xs-12" ng-class="fieldWidth ? fieldWidth : 'col-sm-8'">
8
8
  <div class="input-group">
9
- <input date-range-picker class="form-control date-picker" type="text" options="opts" ng-model="model" />
9
+ <input date-range-picker class="form-control date-picker" type="text" options="opts" ng-model="model" ng-required="required" />
10
10
  <span date-range-picker options="opts" ng-model="model" class="input-group-addon">
11
11
  <nice-icon icon="icon-calendar"></nice-icon>
12
12
  </span>
@@ -31,12 +31,12 @@ angular.module('niceElements')
31
31
  required: '='
32
32
  },
33
33
 
34
- link: function (scope, attrs) {
35
- if (!attrs.title) { attrs.title = ''; }
36
- if (!attrs.fieldWidth) { attrs.fieldWidth = 'col-sm-8'; }
37
- if (!attrs.labelWidth) { attrs.labelWidth = 'col-sm-4'; }
38
- if (!attrs.format) { attrs.format = 'dd.MM.yyyy'; }
39
- attrs.noMargin = attrs.noMargin === 'true' || attrs.noMargin === true;
34
+ link: function (scope) {
35
+ if (!scope.title) { scope.title = ''; }
36
+ if (!scope.fieldWidth) { scope.fieldWidth = 'col-sm-8'; }
37
+ if (!scope.labelWidth) { scope.labelWidth = 'col-sm-4'; }
38
+ if (!scope.format) { scope.format = 'dd.MM.yyyy'; }
39
+ scope.noMargin = scope.noMargin === 'true' || scope.noMargin === true;
40
40
 
41
41
  if (!angular.isDefined(scope.model)) {
42
42
  let model = null;
@@ -56,7 +56,7 @@ angular.module('niceElements')
56
56
  }
57
57
  },
58
58
 
59
- controller: function ($scope) {
59
+ controller: function ($scope, gettextCatalog) {
60
60
  $scope.opts = {
61
61
  locale: {
62
62
  applyClass: 'btn-green',
@@ -15,15 +15,18 @@
15
15
  <span class="input-group-btn">
16
16
  <button type="button" class="btn btn-default" ng-click="openDtp()">
17
17
  <!-- <i class="fa" ng-class="date == 'true' ? 'fa-calendar' : 'fa-clock-o'"></i> -->
18
- <nice-icon ng-if="date == 'true'" icon="icon-calendar"></nice-icon>
19
- <nice-icon ng-if="date != 'true'" icon="icon-clock"></nice-icon>
18
+ <nice-icon ng-if="isTrue(date)" icon="icon-calendar"></nice-icon>
19
+ <nice-icon ng-if="!isTrue(date)" icon="icon-clock"></nice-icon>
20
20
  </button>
21
21
  </span>
22
22
  </div>
23
23
 
24
+ <!-- Only for form validation (date has to be set when required) -->
25
+ <input class="hidden-input" ng-model="model" ng-required="required" tabindex="-1" />
26
+
24
27
  <!-- inject nice-dtp here -->
25
28
  <div ng-show="isOpen">
26
- <nice-dtp model="internalDate" format="{{ format }}" model-format="{{ modelFormat }}" date="{{ date == 'true' }}" time="{{ time == 'true' }}" width="{{ width }}" enable-ok-buttons="{{ enableOkButtons }}" lang="{{ lang }}" min-date="{{ minDate }}" max-date="{{ maxDate }}" week-start="{{ weekStart }}" ok-text="{{ okText }}" cancel-text="{{ cancelText }}" closed="closeDtp"></nice-dtp>
29
+ <nice-dtp model="internalDate" format="{{ format }}" model-format="{{ modelFormat }}" date="{{ isTrue(date) }}" time="{{ isTrue(time) }}" width="{{ width }}" enable-ok-buttons="{{ enableOkButtons }}" lang="{{ lang }}" min-date="{{ minDate }}" max-date="{{ maxDate }}" week-start="{{ weekStart }}" ok-text="{{ okText }}" cancel-text="{{ cancelText }}" closed="closeDtp"></nice-dtp>
27
30
  </div>
28
31
  </div>
29
32
  </div>
@@ -41,9 +41,14 @@ angular.module('niceElements').directive('niceDatetimePicker', function () {
41
41
  console.warn("[NICE ELEMENTS] nice-datetime-picker component is deprecated!");
42
42
  $scope.date = $scope.date == 'true' || $scope.date == true;
43
43
  $scope.time = $scope.time == 'true' || $scope.time == true;
44
- $scope.noMargin === 'true' || $scope.noMargin === true;
45
- $scope.enableOkButtons === 'true' || $scope.enableOkButtons === true;
44
+ $scope.noMargin = $scope.noMargin === 'true' || $scope.noMargin === true;
45
+ $scope.enableOkButtons = $scope.enableOkButtons === 'true' || $scope.enableOkButtons === true;
46
46
  $scope.lang = $scope.lang || 'en';
47
+
48
+ // date/time are "@" attributes, so in the template they can be the string "true" or a boolean
49
+ $scope.isTrue = function (value) {
50
+ return value === true || value === 'true';
51
+ };
47
52
  $scope.okText = $scope.okText || gettextCatalog.getString('OK', null, 'Nice');
48
53
  $scope.cancelText = $scope.cancelText || gettextCatalog.getString('Cancel', null, 'Nice');
49
54
  $scope.weekStart = parseInt($scope.weekStart) || 1;
@@ -32,11 +32,11 @@
32
32
  </div>
33
33
 
34
34
  <div class="dtp-left">
35
- <nice-date model="model.innerStartDate" next-date="model.innerEndDate" is-inline="true" no-margin="true" inline="true" time="time" on-change="dateChanged(model)"></nice-date>
35
+ <nice-date model="model.innerStartDate" next-date="model.innerEndDate" is-inline="true" no-margin="true" inline="true" time="time" min-date="minDate" max-date="maxDate" on-change="dateChanged(model)"></nice-date>
36
36
  </div>
37
37
 
38
38
  <div class="dtp-right">
39
- <nice-date model="model.innerEndDate" next-date="model.innerStartDate" is-inline="true" no-margin="true" inline="true" time="time" on-change="dateChanged(model)"></nice-date>
39
+ <nice-date model="model.innerEndDate" next-date="model.innerStartDate" is-inline="true" no-margin="true" inline="true" time="time" min-date="minDate" max-date="maxDate" on-change="dateChanged(model)"></nice-date>
40
40
  </div>
41
41
  </div>
42
42
  </div>
@@ -0,0 +1,16 @@
1
+ <form class="nice-dialog" ng-submit="handleSubmit()">
2
+ <!-- Header -->
3
+ <div class="nice-dialog-header" ng-transclude="header">
4
+ <nice-icon icon="{{ niceIcon }}" ng-if="niceIcon"></nice-icon>
5
+ <div>
6
+ <div class="nice-dialog-sub-title" ng-if="niceSubtitle && !niceHideSubtitle">{{ niceSubtitle }}</div>
7
+ <div class="nice-dialog-title">{{ niceTitle }}</div>
8
+ </div>
9
+ </div>
10
+
11
+ <!-- Body -->
12
+ <div class="nice-dialog-body" ng-transclude></div>
13
+
14
+ <!-- Footer -->
15
+ <div class="nice-dialog-footer" ng-transclude="footer"></div>
16
+ </form>
@@ -0,0 +1,47 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * @ngdoc directive
5
+ * @name niceElements.directive:niceDialog
6
+ * @description
7
+ * # niceDialog
8
+ * Layout for dialog content (header, scrollable body, footer). Meant to be used inside an ngDialog template,
9
+ * opened with `className: 'nice-ngdialog'` and `showClose: false` (close from the footer instead).
10
+ * The whole dialog is a <form>, so `nice-submit` is called on submit (e.g. pressing enter or a type="submit" button).
11
+ * Header / footer borders appear based on the body scroll position.
12
+ *
13
+ * Usage:
14
+ * <nice-dialog nice-title="Edit" nice-subtitle="Event" nice-icon="icon-edit" nice-submit="save()">
15
+ * ...body...
16
+ * <nice-dialog-footer>
17
+ * <button type="button" class="btn btn-default" ng-click="closeThisDialog()">Cancel</button>
18
+ * <button type="submit" class="btn btn-primary">Save</button>
19
+ * </nice-dialog-footer>
20
+ * </nice-dialog>
21
+ *
22
+ * Pass <nice-dialog-header> to replace the default header (icon + subtitle + title).
23
+ */
24
+ angular.module('niceElements')
25
+ .directive('niceDialog', function () {
26
+ return {
27
+ templateUrl: 'src/components/nice-dialog/nice-dialog.html',
28
+ restrict: 'E',
29
+ replace: true,
30
+ transclude: {
31
+ 'header': '?niceDialogHeader',
32
+ 'footer': '?niceDialogFooter'
33
+ },
34
+ scope: {
35
+ niceTitle: '@',
36
+ niceIcon: '@',
37
+ niceSubtitle: '@',
38
+ niceSubmit: '&?',
39
+ niceHideSubtitle: '=?'
40
+ },
41
+ link: function (scope) {
42
+ scope.handleSubmit = function () {
43
+ if (scope.niceSubmit) scope.niceSubmit();
44
+ };
45
+ }
46
+ };
47
+ });