nice-elements 1.13.2 → 1.13.4

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 (68) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +1 -1
  3. package/bower.json +1 -1
  4. package/dist/nice.js +313 -145
  5. package/dist/nice.min.js +1 -1
  6. package/dist/style.css +108 -74
  7. package/dist/style.css.map +1 -1
  8. package/dist/style.min.css +2 -2
  9. package/package.json +1 -1
  10. package/src/components/nice-alert/nice-alert.js +3 -2
  11. package/src/components/nice-calendar/nice-calendar.html +105 -12
  12. package/src/components/nice-calendar/nice-calendar.js +118 -47
  13. package/src/components/nice-calendar/nice-calendar.scss +137 -95
  14. package/src/components/nice-checkbox/nice-checkbox.html +1 -1
  15. package/src/components/nice-choice/nice-choice.html +1 -1
  16. package/src/components/nice-choice/nice-choice.js +1 -0
  17. package/src/components/nice-comment/nice-comment.html +1 -1
  18. package/src/components/nice-comment/nice-comment.js +1 -0
  19. package/src/components/nice-date/nice-date.html +18 -9
  20. package/src/components/nice-date/nice-date.js +67 -36
  21. package/src/components/nice-date/nice-date.scss +21 -27
  22. package/src/components/nice-date-input/nice-date-input.html +1 -1
  23. package/src/components/nice-date-input/nice-date-input.js +1 -0
  24. package/src/components/nice-date-range/nice-date-range.html +1 -1
  25. package/src/components/nice-date-range/nice-date-range.js +1 -0
  26. package/src/components/nice-datetime-picker/nice-datetime-picker.html +1 -1
  27. package/src/components/nice-datetime-picker/nice-datetime-picker.js +1 -0
  28. package/src/components/nice-datetimerange-picker/nice-datetimerange-picker.html +1 -1
  29. package/src/components/nice-datetimerange-picker/nice-datetimerange-picker.js +1 -0
  30. package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.html +1 -1
  31. package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.js +1 -0
  32. package/src/components/nice-dropdown/nice-dropdown.html +1 -1
  33. package/src/components/nice-dropdown/nice-dropdown.js +1 -0
  34. package/src/components/nice-dropdown-date/nice-dropdown-date.html +1 -1
  35. package/src/components/nice-dropdown-date/nice-dropdown-date.js +1 -0
  36. package/src/components/nice-dropdown-old/nice-dropdown-old.html +1 -1
  37. package/src/components/nice-dropdown-old/nice-dropdown-old.js +1 -0
  38. package/src/components/nice-dtp/nice-dtp.js +1 -0
  39. package/src/components/nice-input/nice-input.js +1 -1
  40. package/src/components/nice-label/nice-label.html +1 -1
  41. package/src/components/nice-label/nice-label.js +1 -0
  42. package/src/components/nice-number/nice-number.html +1 -1
  43. package/src/components/nice-number/nice-number.js +1 -0
  44. package/src/components/nice-options/nice-options.html +1 -1
  45. package/src/components/nice-options/nice-options.js +1 -0
  46. package/src/components/nice-percent/nice-percent.html +1 -1
  47. package/src/components/nice-percent/nice-percent.js +1 -0
  48. package/src/components/nice-progress-bar/nice-progress-bar.html +1 -1
  49. package/src/components/nice-progress-bar/nice-progress-bar.js +1 -0
  50. package/src/components/nice-quantity/nice-quantity.html +1 -1
  51. package/src/components/nice-quantity/nice-quantity.js +1 -0
  52. package/src/components/nice-search/nice-search.html +1 -1
  53. package/src/components/nice-search/nice-search.js +1 -0
  54. package/src/components/nice-search2/nice-search2.html +1 -1
  55. package/src/components/nice-search2/nice-search2.js +1 -0
  56. package/src/components/nice-slot/nice-slot.html +1 -1
  57. package/src/components/nice-slot/nice-slot.js +1 -0
  58. package/src/components/nice-time-picker/nice-time-picker.html +1 -1
  59. package/src/components/nice-time-picker/nice-time-picker.js +1 -0
  60. package/src/components/nice-toggle/nice-toggle.html +1 -1
  61. package/src/components/nice-upload/nice-upload.html +17 -3
  62. package/src/components/nice-upload/nice-upload.js +12 -6
  63. package/src/components/nice-wrapper/nice-wrapper.js +1 -0
  64. package/src/components/nice-yesno/nice-yesno.html +1 -1
  65. package/src/components/nice-yesno/nice-yesno.js +1 -0
  66. package/src/filters/nice-highlight.js +15 -6
  67. package/src/services/nice-service.js +1 -1
  68. package/src/styles/_nice-common.scss +11 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nice-elements",
3
- "version": "1.13.2",
3
+ "version": "1.13.4",
4
4
  "description": "Nice elements used in olaii angular 1.x webapps.",
5
5
  "main": "dist/nice.js",
6
6
  "license": "MIT",
@@ -16,10 +16,11 @@ angular.module('niceElements')
16
16
  icon: '@?',
17
17
  type: '@?',
18
18
  niceTitle: '@?',
19
+ description: '@?',
19
20
  message: '@?',
20
21
  fitContent: '=?',
21
- iconCenter: '@?',
22
- largeIcon: '@?'
22
+ iconCenter: '=?',
23
+ largeIcon: '=?'
23
24
  },
24
25
  controller: function ($scope) {
25
26
  if (!$scope.type) $scope.type = "error";
@@ -1,7 +1,7 @@
1
1
  <div class="nice-component nice-calendar" ng-form="formCalendar" ng-class="{ 'margin-bottom-0': noMargin, 'nice-component-inline': isInline }">
2
2
  <div class="row">
3
3
  <!------------------------- Title ------------------------->
4
- <nice-title text="title || niceTitle" help="help" required="required" label-width="labelWidth"></nice-title>
4
+ <nice-title text="title || niceTitle" help="help" required="required" description="description" label-width="labelWidth"></nice-title>
5
5
 
6
6
  <!------------------------- Field ------------------------->
7
7
  <div class="nice-field col-xs-12" ng-class="[fieldWidth ? fieldWidth : 'col-sm-8', { 'nice-disabled': isDisabled }]">
@@ -9,13 +9,63 @@
9
9
 
10
10
  <div class="nice-calendar-wrapper">
11
11
  <div class="nice-calendar-weeks">
12
- <div class="header">
13
- <button type="button" class="btn" type="button" ng-click="previous()" title="{{ 'Previous month' | translate:'Nice' }}" ng-disabled="isDisabled"><i class="fa fa-angle-left"></i></button>
14
- <span title="{{ month.format('M.YYYY' )}}">{{ month.format("MMMM, YYYY" )}}</span>
15
- <button type="button" class="btn" type="button" ng-click="next()" title="{{ 'Next month' | translate:'Nice' }}" ng-disabled="isDisabled"><i class="fa fa-angle-right"></i></button>
12
+ <div class="nice-calendar-header">
13
+ <!-- <span title="{{ month.format('M.YYYY' )}}">{{ month.format("MMMM, YYYY" )}}</span> -->
14
+ <div class="nice-calendar-header-selects">
15
+ <!-- Year -->
16
+ <select
17
+ class="year-select"
18
+ ng-model="selectedYear"
19
+ ng-change="yearSelectChange()"
20
+ ng-options="year for year in years"
21
+ ng-disabled="isDisabled"
22
+ ></select>
23
+ <span>,</span>
24
+ <!-- Month -->
25
+ <select
26
+ class="month-select"
27
+ ng-model="selectedMonth"
28
+ ng-change="monthSelectChange()"
29
+ ng-options="month.value as month.name for month in months"
30
+ ng-disabled="isDisabled"
31
+ ></select>
32
+ </div>
33
+
34
+ <!-- Previous month -->
35
+ <button
36
+ title="{{ 'Previous month' | translate:'Nice' }}"
37
+ type="button"
38
+ class="btn"
39
+ ng-click="previous()"
40
+ ng-disabled="isDisabled"
41
+ >
42
+ <i class="fa fa-angle-left"></i>
43
+ </button>
44
+
45
+ <!-- Today -->
46
+ <button
47
+ title="{{ 'Today' | translate:'Nice' }}"
48
+ type="button"
49
+ class="btn"
50
+ ng-click="today()"
51
+ ng-disabled="isDisabled"
52
+ >
53
+ <nice-icon icon="icon-circle"></nice-icon>
54
+ </button>
55
+
56
+ <!-- Next month -->
57
+ <button
58
+ title="{{ 'Next month' | translate:'Nice' }}"
59
+ type="button"
60
+ class="btn"
61
+ ng-click="next()"
62
+ ng-disabled="isDisabled"
63
+ >
64
+ <i class="fa fa-angle-right"></i>
65
+ </button>
16
66
  </div>
17
67
 
18
- <div class="week names">
68
+ <div class="nice-calendar-days nice-calendar-days-header">
19
69
  <span class="day" translate translate-context="Nice">Mon</span>
20
70
  <span class="day" translate translate-context="Nice">Tue</span>
21
71
  <span class="day" translate translate-context="Nice">Wed</span>
@@ -25,7 +75,38 @@
25
75
  <span class="day weekend" translate translate-context="Nice">Sun</span>
26
76
  </div>
27
77
 
28
- <div class="week" ng-repeat="week in weeks">
78
+ <div class="nice-calendar-days">
79
+ <button
80
+ type="button"
81
+ class="day"
82
+ type="button"
83
+ title="{{ day.text }}"
84
+ ng-class="{
85
+ 'today': day.isToday,
86
+ 'different-month': !day.isCurrentMonth,
87
+ 'start-selected': isSameDay(day.date, startDate),
88
+ 'end-selected': isSameDay(day.date, endDate),
89
+ 'selected': isBetweenRange(day.date),
90
+ 'selecting-start': selectStart,
91
+ 'selecting-end': !selectStart,
92
+ 'weekend': day.isWeekday,
93
+ 'disabled': day.isDisabled
94
+ }"
95
+ ng-style="
96
+ (color && isBetweenRange(day.date)) && {'background-color': lighten(color) } ||
97
+ (color && isSameDay(day.date, startDate)) && {'background-color': color } ||
98
+ (color && isSameDay(day.date, endDate)) && {'background-color': color }
99
+ "
100
+ ng-click="select(day)"
101
+ ng-repeat="day in days"
102
+ ng-disabled="isDisabled"
103
+ >
104
+ <span>{{ day.name }}</span>
105
+ <p class="popup" ng-if="!hideHover">{{ popupText }}</p>
106
+ </button>
107
+ </div>
108
+
109
+ <!-- <div class="week" ng-repeat="week in weeks">
29
110
  <button type="button" class="day" type="button" title="{{ day.date.format('D.M.YYYY') }}" ng-class="{
30
111
  today: day.isToday,
31
112
  'different-month': !day.isCurrentMonth,
@@ -44,19 +125,31 @@
44
125
  {{ day.number }}
45
126
  <p class="popup" ng-if="!hideHover">{{ popupText }}</p>
46
127
  </button>
47
- </div>
128
+ </div> -->
48
129
  </div>
49
130
 
50
131
 
51
132
  <div class="nice-calendar-time" ng-if="time">
52
133
  <div class="time-picker">
53
- <select title="{{ 'Select start time' | translate:'Nice' }}" class="time-picker-hour" ng-model="startDateHour" ng-change="startHourChange(startDateHour)" ng-options="hour for hour in hours" ng-disabled="isDisabled">
54
- </select>
134
+ <select
135
+ title="{{ 'Select start time' | translate:'Nice' }}"
136
+ class="time-picker-hour"
137
+ ng-model="startDateHour"
138
+ g-change="startHourChange(startDateHour)"
139
+ ng-options="hour for hour in hours"
140
+ ng-disabled="isDisabled"
141
+ ></select>
55
142
  </div>
56
143
 
57
144
  <div class="time-picker">
58
- <select title="{{ 'Select start time' | translate:'Nice' }}" class="time-picker-minute" ng-model="startDateMinute" ng-change="startMinuteChange(startDateMinute)" ng-options="minute for minute in minutes" ng-disabled="isDisabled">
59
- </select>
145
+ <select
146
+ title="{{ 'Select start time' | translate:'Nice' }}"
147
+ class="time-picker-minute"
148
+ ng-model="startDateMinute"
149
+ ng-change="startMinuteChange(startDateMinute)"
150
+ ng-options="minute for minute in minutes"
151
+ ng-disabled="isDisabled"
152
+ ></select>
60
153
  </div>
61
154
 
62
155
  <div class="time-picker-icon">
@@ -13,6 +13,7 @@ angular.module('niceElements')
13
13
  templateUrl: "src/components/nice-calendar/nice-calendar.html",
14
14
  scope: {
15
15
  niceTitle: '@',
16
+ description: '@?',
16
17
  title: '@',
17
18
  fieldWidth: '@',
18
19
  labelWidth: '@',
@@ -33,9 +34,31 @@ angular.module('niceElements')
33
34
  },
34
35
  link: function (scope, element) {
35
36
  // ------------------ Init default values ------------------
37
+ scope.innerDate = moment();
36
38
  scope.selectStart = true;
37
39
  scope.popupText = gettextCatalog.getString("Select start date", null, "Nice");
38
40
 
41
+ scope.years = [];
42
+ const year = moment().year() - 100;
43
+ for (let i = 0; i < 200; i++) {
44
+ scope.years.push(year + i);
45
+ }
46
+
47
+ scope.months = [
48
+ { value: 0, name: gettextCatalog.getString("January", null, "Nice") },
49
+ { value: 1, name: gettextCatalog.getString("February", null, "Nice") },
50
+ { value: 2, name: gettextCatalog.getString("March", null, "Nice") },
51
+ { value: 3, name: gettextCatalog.getString("April", null, "Nice") },
52
+ { value: 4, name: gettextCatalog.getString("May", null, "Nice") },
53
+ { value: 5, name: gettextCatalog.getString("June", null, "Nice") },
54
+ { value: 6, name: gettextCatalog.getString("July", null, "Nice") },
55
+ { value: 7, name: gettextCatalog.getString("August", null, "Nice") },
56
+ { value: 8, name: gettextCatalog.getString("September", null, "Nice") },
57
+ { value: 9, name: gettextCatalog.getString("October", null, "Nice") },
58
+ { value: 10, name: gettextCatalog.getString("November", null, "Nice") },
59
+ { value: 11, name: gettextCatalog.getString("December", null, "Nice") }
60
+ ];
61
+
39
62
  scope.hours = [
40
63
  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23
41
64
  ];
@@ -98,11 +121,11 @@ angular.module('niceElements')
98
121
  scope.endDateMinute = moment(scope.endDate).minutes();
99
122
  }
100
123
  }
101
-
102
- scope.month = angular.copy(moment(scope.startDate));
124
+
125
+ scope.innerDate = angular.copy(moment(scope.startDate));
103
126
  const start = angular.copy(moment(scope.startDate));
104
127
  _removeTimeWithDate(start.date(0));
105
- _buildMonth(scope, start, scope.month);
128
+ _buildMonth();
106
129
  }
107
130
 
108
131
  bootstrap();
@@ -159,7 +182,7 @@ angular.module('niceElements')
159
182
  }
160
183
  }
161
184
 
162
- if (scope.onChange) scope.onChange({ model: { startDate: scope.startDate, endDate: scope.endDate }, element: element });
185
+ scope.handleUpdate();
163
186
  }
164
187
  };
165
188
 
@@ -218,31 +241,44 @@ angular.module('niceElements')
218
241
 
219
242
 
220
243
  scope.handleUpdate = function () {
244
+ scope.startDate.seconds(0).millisecond(0);
245
+ scope.endDate.seconds(59).milliseconds(999);
221
246
  if (scope.onChange) scope.onChange({ model: { startDate: scope.startDate, endDate: scope.endDate }, element: element });
222
247
  };
223
248
 
249
+ scope.yearSelectChange = function () {
250
+ scope.innerDate = scope.innerDate.year(scope.selectedYear);
251
+ _buildMonth();
252
+ };
253
+
254
+ scope.monthSelectChange = function () {
255
+ scope.innerDate = scope.innerDate.month(scope.selectedMonth);
256
+ _buildMonth();
257
+ };
258
+
259
+ // ------------------ Go to today ------------------
260
+ scope.today = function () {
261
+ scope.innerDate = moment();
262
+ _buildMonth();
263
+ };
224
264
 
225
265
  // ------------------ Go to next month ------------------
226
266
  scope.next = function () {
227
- const next = angular.copy(scope.month);
228
- _removeTimeWithDate(next.month(next.month() + 1).date(0));
229
- scope.month.month(scope.month.month() + 1);
230
- _buildMonth(scope, next, scope.month);
267
+ scope.innerDate = scope.innerDate.add(1, "month");
268
+ _buildMonth();
231
269
  };
232
270
 
233
271
 
234
272
  // ------------------ Go to previous month ------------------
235
273
  scope.previous = function () {
236
- const previous = angular.copy(scope.month);
237
- _removeTimeWithDate(previous.month(previous.month() - 1).date(0));
238
- scope.month.month(scope.month.month() - 1);
239
- _buildMonth(scope, previous, scope.month);
274
+ scope.innerDate = scope.innerDate.subtract(1, "month");
275
+ _buildMonth();
240
276
  };
241
277
 
242
278
 
243
279
  // ------------------ Check if dates are equal without time ------------------
244
280
  scope.isSameDay = function (date1, date2) {
245
- if(!date1 || !date2) return false;
281
+ if (!date1 || !date2) return false;
246
282
  const d1 = _removeTime(angular.copy(date1));
247
283
  const d2 = _removeTime(angular.copy(date2));
248
284
  return d1.isSame(d2);
@@ -251,7 +287,7 @@ angular.module('niceElements')
251
287
 
252
288
  // ------------------ Check if date is between start and end date ------------------
253
289
  scope.isBetweenRange = function (date) {
254
- if(!scope.endDate || !scope.startDate) return false;
290
+ if (!scope.endDate || !scope.startDate) return false;
255
291
  return (date.isBefore(moment(scope.endDate)) && date.isAfter(moment(scope.startDate)));
256
292
  };
257
293
 
@@ -301,45 +337,80 @@ angular.module('niceElements')
301
337
  return date.day(0).hour(0).minute(0).second(0).millisecond(0);
302
338
  }
303
339
 
304
-
305
-
306
340
  // ------------------ Build month ------------------
307
- function _buildMonth(scope, start, month) {
308
- scope.weeks = [];
309
- let done = false, date = start.clone().startOf('week').isoWeekday(1), monthIndex = date.month(), count = 0;
310
- date.add(1, "w");
311
- while (!done) {
312
- scope.weeks.push({ days: _buildWeek(date.clone(), month) });
313
- date.add(1, "w");
314
- done = count++ > 2 && monthIndex !== date.month();
315
- monthIndex = date.month();
341
+ function _buildMonth() {
342
+ scope.selectedYear = scope.innerDate.year();
343
+ scope.selectedMonth = scope.innerDate.month();
344
+
345
+ scope.days = [];
346
+
347
+ // 1. Get the first day of the currently viewed month
348
+ const firstDayOfMonth = new Date(
349
+ scope.innerDate.year(),
350
+ scope.innerDate.month(),
351
+ 1
352
+ );
353
+
354
+ // 2. Calculate the offset (0 = Sunday, 1 = Monday, etc.)
355
+ // If your calendar starts on Monday, we adjust the JS Sunday (0) to 7
356
+ let startOffset = firstDayOfMonth.getDay();
357
+ if (startOffset === 0) startOffset = 7; // Treat Sunday as 7
358
+ startOffset -= 1; // Adjust so Monday = 0
359
+
360
+ // 3. We always want to show a standard 6-week grid (42 days)
361
+ // We start the loop from 1 minus the offset
362
+ for (let d = 1 - startOffset; d <= 42 - startOffset; d++) {
363
+ scope.days.push(
364
+ _buildDay(
365
+ scope.innerDate.year(),
366
+ scope.innerDate.month(),
367
+ d
368
+ )
369
+ );
316
370
  }
317
371
  }
318
372
 
373
+ // ------------------ Build day ------------------
374
+ function _buildDay(year, month, day) {
375
+ const today = moment();
376
+ const date = moment().year(year).month(month).date(day);
377
+ return {
378
+ id: date.toString(),
379
+ date: date,
380
+ year: date.year(),
381
+ month: date.month(),
382
+ day: date.date(),
383
+ dayInWeek: date.day(),
384
+ isCurrentMonth: date.month() == scope.innerDate.month(),
385
+ isWeekday: date.day() == 0 || date.day() == 6,
386
+ isToday: _isSameDay(moment(), date),
387
+ selected: _isSameDay(scope.innerDate, date),
388
+ today: _isSameDay(today, date),
389
+ highlighted: _isHighlighted(date),
390
+ isDisabled: _isDisabledDate(date),
391
+ text: date.format('dddd, D.M.YYYY'),
392
+ name: date.format('D'),
393
+ };
394
+ }
395
+
396
+ function _isDisabledDate(date) {
397
+ // console.log(date.format('D.M.YYYY'), scope.minDate.format('D.M.YYYY'), scope.maxDate.format('D.M.YYYY'));
398
+ if (scope.minDate && date.isBefore(scope.minDate)) return true;
399
+ if (scope.maxDate && date.isAfter(scope.maxDate)) return true;
400
+ return false;
401
+ }
319
402
 
320
- // ------------------ Build week ------------------
321
- function _buildWeek(date, month) {
322
- const days = [];
323
- for (let i = 0; i < 7; i++) {
324
- const day = {
325
- name: date.format("dd"),
326
- number: date.date(),
327
- isCurrentMonth: date.month() === month.month(),
328
- isToday: date.isSame(new Date(), "day"),
329
- isWeekday: date.weekday() == 0 || date.weekday() == 6,
330
- date: date
331
- };
332
-
333
- if (scope.minDate) day.isDisabled = date.isBefore(moment(scope.minDate));
334
- if (scope.maxDate) day.isDisabled = date.isAfter(moment(scope.maxDate));
335
- if (scope.minDate && scope.maxDate) day.isDisabled = !date.isBetween(moment(scope.minDate), moment(scope.maxDate));
336
-
337
- days.push(day);
338
- date = date.clone();
339
- date.add(1, "d");
340
- }
403
+ function _isHighlighted(date) {
404
+ // if (props.highlightTo && isWithinInterval(date, { end: props.highlightTo, start: selected.value })) return true;
405
+ return false;
406
+ }
341
407
 
342
- return days;
408
+ function _isSameDay(date1, date2) {
409
+ return (
410
+ date1.date() == date2.date() &&
411
+ date1.month() == date2.month() &&
412
+ date1.year() == date2.year()
413
+ );
343
414
  }
344
415
  }
345
416
  };