pui9-components 2.0.8 → 3.0.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 (67) hide show
  1. package/dist/pui9-components.common.js +5050 -22036
  2. package/dist/pui9-components.css +3 -6
  3. package/package-lock.json +81 -221
  4. package/package.json +1 -5
  5. package/src/App.vue +0 -117
  6. package/src/components/PuiAutocomplete.vue +0 -196
  7. package/src/components/PuiCauDialog.vue +0 -192
  8. package/src/components/PuiCheckbox.vue +0 -126
  9. package/src/components/PuiCodeEditor.vue +0 -124
  10. package/src/components/PuiDateField.vue +0 -1043
  11. package/src/components/PuiField.vue +0 -30
  12. package/src/components/PuiFieldSet.vue +0 -27
  13. package/src/components/PuiFileUpload.vue +0 -275
  14. package/src/components/PuiFileUploadGroup.vue +0 -241
  15. package/src/components/PuiFilter.vue +0 -104
  16. package/src/components/PuiFilterGroup.vue +0 -291
  17. package/src/components/PuiFilterRule.vue +0 -683
  18. package/src/components/PuiFormFooter.vue +0 -48
  19. package/src/components/PuiFormFooterBtns.vue +0 -118
  20. package/src/components/PuiFormHeader.vue +0 -25
  21. package/src/components/PuiFormLoading.vue +0 -14
  22. package/src/components/PuiFormMiniAudit.vue +0 -53
  23. package/src/components/PuiFormTooltip.vue +0 -50
  24. package/src/components/PuiMasterDetail.vue +0 -103
  25. package/src/components/PuiModalDialog.vue +0 -91
  26. package/src/components/PuiModalDialogForm.vue +0 -209
  27. package/src/components/PuiMultiSelect.vue +0 -636
  28. package/src/components/PuiNumberField.vue +0 -434
  29. package/src/components/PuiPasswordField.vue +0 -105
  30. package/src/components/PuiRadioGroup.vue +0 -105
  31. package/src/components/PuiRichTextEditor.vue +0 -116
  32. package/src/components/PuiSelect.vue +0 -1675
  33. package/src/components/PuiSelectDetailDialog.vue +0 -113
  34. package/src/components/PuiSelectTextService.vue +0 -61
  35. package/src/components/PuiSelectorList.vue +0 -169
  36. package/src/components/PuiSort.vue +0 -98
  37. package/src/components/PuiSpinnerField.vue +0 -464
  38. package/src/components/PuiSwitch.vue +0 -104
  39. package/src/components/PuiTextArea.vue +0 -204
  40. package/src/components/PuiTextField.vue +0 -389
  41. package/src/dateTimeUtils.js +0 -78
  42. package/src/index.js +0 -89
  43. package/src/main.js +0 -34
  44. package/src/mixins/PuiFormComponentMixin.js +0 -77
  45. package/src/mixins/PuiSortMixin.js +0 -136
  46. package/src/mixins/PuiUtilsNumberMixin.js +0 -29
  47. package/src/plugins/vuetify.js +0 -33
  48. package/src/tests/TestAutocomplete.vue +0 -138
  49. package/src/tests/TestCodeEditor.vue +0 -48
  50. package/src/tests/TestField.vue +0 -22
  51. package/src/tests/TestFieldSet.vue +0 -30
  52. package/src/tests/TestInputCheckbox.vue +0 -53
  53. package/src/tests/TestInputDate.vue +0 -146
  54. package/src/tests/TestInputNumber.vue +0 -77
  55. package/src/tests/TestInputRadioGroup.vue +0 -86
  56. package/src/tests/TestInputSpinner.vue +0 -77
  57. package/src/tests/TestInputSwitch.vue +0 -52
  58. package/src/tests/TestInputText.vue +0 -120
  59. package/src/tests/TestInputTextArea.vue +0 -73
  60. package/src/tests/TestMultiSelect.vue +0 -127
  61. package/src/tests/TestPuiForm.vue +0 -68
  62. package/src/tests/TestRichTextEditor.vue +0 -54
  63. package/src/tests/unit/PuiCheckbox.spec.js +0 -86
  64. package/src/tests/unit/PuiTextArea.spec.js +0 -62
  65. package/src/tests/unit/PuiTextField.spec.js +0 -119
  66. package/src/tests/unit/index.js +0 -5
  67. package/src/utils.js +0 -158
@@ -1,1043 +0,0 @@
1
- <template>
2
- <!-- DESKTOP -->
3
- <div v-if="!isMobile">
4
- <div v-if="toplabel" class="ml-1 mr-1">
5
- <v-layout>
6
- <v-flex xs12>
7
- <label v-if="getLabel === '$nbsp;'">&nbsp;</label>
8
- <label v-else :class="getLabelRequiredClass">{{ getLabel }}</label>
9
- <pui-form-tooltip v-bind="{ tooltipDescription, tooltipIcon }" v-if="showTooltip" ref="tooltip"></pui-form-tooltip>
10
- </v-flex>
11
- </v-layout>
12
- <v-layout>
13
- <v-flex xs12>
14
- <v-layout>
15
- <v-flex :xs7="showTime" :xs12="!showTime">
16
- <!-- use attach on v-menu but it does not working at the moment... -->
17
- <!-- :attach="`#${attach !== null ? attach : defaultId}`" -->
18
- <v-menu
19
- :close-on-content-click="false"
20
- v-model="dateMenuModel"
21
- :nudge-right="40"
22
- transition="scale-transition"
23
- offset-y
24
- min-width="290px"
25
- :disabled="disabled"
26
- :key="refresher"
27
- ><template v-slot:activator="{ on, attrs }">
28
- <v-text-field
29
- :ref="`dateField${attach !== null ? attach : defaultId}`"
30
- :id="`${attach !== null ? attach : defaultId}`"
31
- v-on="on"
32
- v-bind="attrs"
33
- v-model="internalDateFieldModel"
34
- :class="getEditedDateClass"
35
- :rules="getDateRules"
36
- append-icon="far fa-calendar-day"
37
- clearable
38
- solo
39
- outlined
40
- flat
41
- :readonly="disableTextInput"
42
- :disabled="disabled"
43
- :mask="getDateMask"
44
- :error="internalDateError"
45
- :error-messages="internalDateErrorMessage"
46
- :placeholder="getDatePlaceholder"
47
- @input="updateDateFieldModel"
48
- @click:append="dateMenuModel = true"
49
- @click:clear="internalDatePickerModel = null"
50
- @focus="allValidations()"
51
- ></v-text-field>
52
- </template>
53
- <v-date-picker
54
- v-model="internalDatePickerModel"
55
- :first-day-of-week="1"
56
- :locale="getLocale"
57
- v-bind="allProps"
58
- :disabled="disabled"
59
- :min="minDateValue"
60
- :max="maxDateValue"
61
- color="var(--primarycolor)"
62
- ></v-date-picker>
63
- </v-menu>
64
- </v-flex>
65
- <v-flex :xs5="showTime" :xs0="!showTime">
66
- <v-menu
67
- v-if="showTime"
68
- :close-on-content-click="false"
69
- v-model="timeMenuModel"
70
- :nudge-right="40"
71
- transition="scale-transition"
72
- offset-y
73
- min-width="150px"
74
- :disabled="disabled"
75
- :key="refresher"
76
- >
77
- <template v-slot:activator="{ on, attrs }">
78
- <v-text-field
79
- v-on="on"
80
- v-bind="attrs"
81
- :ref="`timeField${attach !== null ? attach : defaultId}`"
82
- v-model="internalTimeFieldModel"
83
- :class="getEditedTimeClass"
84
- :rules="getTimeRules"
85
- append-icon="fa-clock"
86
- clearable
87
- solo
88
- outlined
89
- flat
90
- :readonly="disableTextInput"
91
- :disabled="disabled"
92
- class="ml-1"
93
- :mask="getTimeMask"
94
- :error="internalTimeError"
95
- :error-messages="internalTimeErrorMessage"
96
- :placeholder="getTimePlaceholder"
97
- @input="updateTimeFieldModel"
98
- @click:append="timeMenuModel = true"
99
- @click:clear="internalTimePickerModel = null"
100
- @focus="allValidations()"
101
- ></v-text-field>
102
- </template>
103
- <v-time-picker
104
- v-if="timeMenuModel"
105
- v-model="internalTimePickerModel"
106
- v-bind="allProps"
107
- :disabled="disabled"
108
- :min="minTimeValueForPicker"
109
- :max="maxTimeValueForPicker"
110
- format="24hr"
111
- :use-seconds="timesecs"
112
- color="var(--primarycolor)"
113
- @click:hour="timeMenuModel = true"
114
- @click:minute="timeMenuModel = timesecs"
115
- @click:second="timeMenuModel = false"
116
- ></v-time-picker>
117
- </v-menu>
118
- </v-flex>
119
- </v-layout>
120
- </v-flex>
121
- </v-layout>
122
- </div>
123
- <div v-else class="ml-1 mr-1">
124
- <v-layout>
125
- <v-flex :class="labelColumnStyles ? labelColumnStyles : 'xs12 sm6 md4 xl3'">
126
- <label :class="getLabelRequiredClass">{{ getLabel }}</label>
127
- <pui-form-tooltip v-bind="{ tooltipDescription, tooltipIcon }" v-if="showTooltip" ref="tooltip"></pui-form-tooltip>
128
- </v-flex>
129
- <v-flex :class="valueColumnStyles ? valueColumnStyles : 'xs12 sm6 md8 xl9'">
130
- <v-layout>
131
- <v-flex :xs7="showTime" :xs12="!showTime">
132
- <v-menu
133
- :close-on-content-click="false"
134
- v-model="dateMenuModel"
135
- :nudge-right="40"
136
- transition="scale-transition"
137
- offset-y
138
- min-width="290px"
139
- :disabled="disabled"
140
- :key="refresher"
141
- >
142
- <template v-slot:activator="{ on, attrs }">
143
- <v-text-field
144
- :ref="`dateField${attach !== null ? attach : defaultId}`"
145
- :id="`${attach !== null ? attach : defaultId}`"
146
- v-on="on"
147
- v-bind="attrs"
148
- v-model="internalDateFieldModel"
149
- :class="getEditedDateClass"
150
- class="ml-2"
151
- :rules="getDateRules"
152
- append-icon="far fa-calendar-day"
153
- clearable
154
- solo
155
- outlined
156
- flat
157
- :readonly="disableTextInput"
158
- :disabled="disabled"
159
- :mask="getDateMask"
160
- :error="internalDateError"
161
- :error-messages="internalDateErrorMessage"
162
- :placeholder="getDatePlaceholder"
163
- @input="updateDateFieldModel"
164
- @click:append="dateMenuModel = true"
165
- @click:clear="internalDatePickerModel = null"
166
- @focus="allValidations()"
167
- ></v-text-field>
168
- </template>
169
- <v-date-picker
170
- v-model="internalDatePickerModel"
171
- :first-day-of-week="1"
172
- :locale="getLocale"
173
- v-bind="allProps"
174
- :disabled="disabled"
175
- :min="minDateValue"
176
- :max="maxDateValue"
177
- color="var(--primarycolor)"
178
- ></v-date-picker>
179
- </v-menu>
180
- </v-flex>
181
- <v-flex :xs5="showTime" :xs0="!showTime">
182
- <v-menu
183
- v-if="showTime"
184
- :close-on-content-click="false"
185
- v-model="timeMenuModel"
186
- :nudge-right="40"
187
- transition="scale-transition"
188
- offset-y
189
- min-width="150px"
190
- :disabled="disabled"
191
- >
192
- <template v-slot:activator="{ on, attrs }">
193
- <v-text-field
194
- v-on="on"
195
- v-bind="attrs"
196
- :ref="`timeField${attach !== null ? attach : defaultId}`"
197
- v-model="internalTimeFieldModel"
198
- :class="getEditedTimeClass"
199
- class="ml-1"
200
- :rules="getTimeRules"
201
- append-icon="fa-clock"
202
- clearable
203
- solo
204
- outlined
205
- flat
206
- :readonly="disableTextInput"
207
- :disabled="disabled"
208
- :mask="getTimeMask"
209
- :error="internalTimeError"
210
- :error-messages="internalTimeErrorMessage"
211
- :placeholder="getTimePlaceholder"
212
- @input="updateTimeFieldModel"
213
- @click:append="timeMenuModel = true"
214
- @click:clear="internalTimePickerModel = null"
215
- @focus="allValidations()"
216
- ></v-text-field>
217
- </template>
218
- <v-time-picker
219
- v-if="timeMenuModel"
220
- v-model="internalTimePickerModel"
221
- v-bind="allProps"
222
- :disabled="disabled"
223
- :min="minTimeValueForPicker"
224
- :max="maxTimeValueForPicker"
225
- format="24hr"
226
- :use-seconds="timesecs"
227
- color="var(--primarycolor)"
228
- @click:hour="timeMenuModel = true"
229
- @click:minute="timeMenuModel = timesecs"
230
- @click:second="timeMenuModel = false"
231
- ></v-time-picker>
232
- </v-menu>
233
- </v-flex>
234
- </v-layout>
235
- </v-flex>
236
- </v-layout>
237
- </div>
238
- </div>
239
- <!-- MOBILE -->
240
- <div v-else>
241
- <v-layout>
242
- <v-flex xs12>
243
- <v-layout>
244
- <v-flex :xs7="showTime" :xs12="!showTime">
245
- <v-menu
246
- :close-on-content-click="false"
247
- v-model="dateMenuModel"
248
- :nudge-right="40"
249
- transition="scale-transition"
250
- offset-y
251
- min-width="290px"
252
- :disabled="disabled"
253
- :key="refresher"
254
- ><template v-slot:activator="{ on, attrs }">
255
- <v-text-field
256
- :ref="`dateField${attach !== null ? attach : defaultId}`"
257
- :id="`${attach !== null ? attach : defaultId}`"
258
- v-on="on"
259
- v-bind="attrs"
260
- v-model="internalDateFieldModel"
261
- append-icon="far fa-calendar-day"
262
- :class="getMobileClass"
263
- :rules="getDateRules"
264
- class="v-text-field--mobile"
265
- :disabled="disabled"
266
- :label="getLabel"
267
- :mask="getDateMask"
268
- :error="internalDateError"
269
- :error-messages="internalDateErrorMessage"
270
- :placeholder="getDatePlaceholder"
271
- @input="updateDateFieldModel"
272
- @click:append="dateMenuModel = true"
273
- @click:clear="internalDatePickerModel = null"
274
- @focus="allValidations()"
275
- ></v-text-field>
276
- </template>
277
- <v-date-picker
278
- v-model="internalDatePickerModel"
279
- :first-day-of-week="1"
280
- :locale="getLocale"
281
- v-bind="allProps"
282
- :disabled="disabled"
283
- :min="minDateValue"
284
- :max="maxDateValue"
285
- color="var(--primarycolor)"
286
- ></v-date-picker>
287
- </v-menu>
288
- </v-flex>
289
- <v-flex :xs5="showTime" :xs0="!showTime">
290
- <v-menu
291
- v-if="showTime"
292
- :close-on-content-click="false"
293
- v-model="timeMenuModel"
294
- :nudge-right="40"
295
- transition="scale-transition"
296
- offset-y
297
- min-width="150px"
298
- :disabled="disabled"
299
- >
300
- <template v-slot:activator="{ on, attrs }">
301
- <v-text-field
302
- v-on="on"
303
- v-bind="attrs"
304
- :ref="`timeField${attach !== null ? attach : defaultId}`"
305
- v-model="internalTimeFieldModel"
306
- :class="getEditedTimeClass"
307
- class="ml-1"
308
- :rules="getTimeRules"
309
- append-icon="fa-clock"
310
- :disabled="disabled"
311
- :mask="getTimeMask"
312
- :error="internalTimeError"
313
- :error-messages="internalTimeErrorMessage"
314
- :placeholder="getTimePlaceholder"
315
- @input="updateTimeFieldModel"
316
- @click:append="timeMenuModel = true"
317
- @click:clear="internalTimePickerModel = null"
318
- @focus="allValidations()"
319
- ></v-text-field>
320
- </template>
321
- <v-time-picker
322
- v-if="timeMenuModel"
323
- v-model="internalTimePickerModel"
324
- v-bind="allProps"
325
- :disabled="disabled"
326
- :min="minTimeValueForPicker"
327
- :max="maxTimeValueForPicker"
328
- format="24hr"
329
- :use-seconds="timesecs"
330
- color="var(--primarycolor)"
331
- @click:hour="timeMenuModel = true"
332
- @click:minute="timeMenuModel = timesecs"
333
- @click:second="timeMenuModel = false"
334
- ></v-time-picker>
335
- </v-menu>
336
- </v-flex>
337
- </v-layout>
338
- </v-flex>
339
- </v-layout>
340
- </div>
341
- </template>
342
-
343
- <script>
344
- import moment from 'moment';
345
- import PuiFormComponentMixin from '../mixins/PuiFormComponentMixin';
346
- import dateTimeUtils from '../dateTimeUtils';
347
-
348
- export default {
349
- name: 'PuiDateField',
350
- mixins: [PuiFormComponentMixin],
351
- props: {
352
- disableTextInput: {
353
- type: Boolean,
354
- default: false,
355
- required: false
356
- },
357
- value: {
358
- type: [Number, Date, String],
359
- required: false
360
- },
361
- today: {
362
- type: Boolean,
363
- default: false,
364
- required: false
365
- },
366
- time: {
367
- type: Boolean,
368
- default: false,
369
- required: false
370
- },
371
- tooltip: {
372
- type: Boolean,
373
- required: false,
374
- default: false
375
- },
376
- tooltipDescription: {
377
- type: String,
378
- required: false
379
- },
380
- tooltipIcon: {
381
- type: String,
382
- required: false
383
- },
384
- timesecs: {
385
- type: Boolean,
386
- default: false,
387
- required: false
388
- },
389
- rules: {
390
- type: Array,
391
- default: () => {
392
- return [];
393
- }
394
- },
395
- isoDateFormat: {
396
- type: String,
397
- required: false
398
- },
399
- min: {
400
- type: [Number, Date, String],
401
- required: false
402
- },
403
- max: {
404
- type: [Number, Date, String],
405
- required: false
406
- },
407
- labelColumnStyles: {
408
- type: String,
409
- required: false
410
- },
411
- valueColumnStyles: {
412
- type: String,
413
- required: false
414
- },
415
- attach: {
416
- type: String,
417
- default: null,
418
- required: false
419
- }
420
- },
421
- data: () => ({
422
- debug: false,
423
- defaultId: `id_${Math.random().toString().replace('.', '')}`,
424
- firstLoad: true,
425
- internalUTCModel: null,
426
- internalDatePickerModel: null,
427
- internalDateFieldModel: null,
428
- internalTimePickerModel: null,
429
- internalTimeFieldModel: null,
430
- initialDateValue: null,
431
- initialTimeValue: null,
432
- dateMenuModel: false,
433
- timeMenuModel: false,
434
- internalDatePickerFormat: 'YYYY-MM-DD',
435
- internalDateError: false,
436
- internalTimeError: false,
437
- internalDateErrorMessage: '',
438
- internalTimeErrorMessage: '',
439
- refresher: 0
440
- }),
441
- computed: {
442
- minDateValue() {
443
- return this.min ? moment(this.min).format(this.internalDatePickerFormat) : null;
444
- },
445
- maxDateValue() {
446
- return this.max ? moment(this.max).format(this.internalDatePickerFormat) : null;
447
- },
448
- minTimeValueForPicker() {
449
- return this.min && this.minDateSameDay ? moment(this.min).format(this.ISOtimeFormat) : null;
450
- },
451
- maxTimeValueForPicker() {
452
- return this.max && this.maxDateSameDay ? moment(this.max).format(this.ISOtimeFormat) : null;
453
- },
454
- minTimeValueForValidation() {
455
- return this.min ? moment(this.min).format(this.ISOtimeFormat) : null;
456
- },
457
- maxTimeValueForValidation() {
458
- return this.max ? moment(this.max).format(this.ISOtimeFormat) : null;
459
- },
460
- minDateSameDay() {
461
- return this.min ? this.internalDatePickerModel == this.minDateValue : null;
462
- },
463
- maxDateSameDay() {
464
- return this.max ? this.internalDatePickerModel == this.maxDateValue : null;
465
- },
466
- minDateValidation() {
467
- this.debug && console.log('minDateValidation ' + this.label, moment(this.internalDatePickerModel));
468
- this.debug && console.log('minDateValidation ' + this.label, moment(this.minDateValue));
469
- return this.min ? this.minDateSameDay || moment(this.internalDatePickerModel).isSame(moment(this.minDateValue)) || moment(this.internalDatePickerModel).isAfter(moment(this.minDateValue)) : null;
470
- },
471
- maxDateValidation() {
472
- this.debug && console.log('maxDateValidation ' + this.label, moment(this.internalDatePickerModel));
473
- this.debug && console.log('maxDateValidation ' + this.label, moment(this.maxDateValue));
474
- return this.max ? this.maxDateSameDay || moment(this.internalDatePickerModel).isSame(moment(this.maxDateValue)) || moment(this.internalDatePickerModel).isBefore(moment(this.maxDateValue)) : null;
475
- },
476
- minTimeValidation() {
477
- let prefix = this.internalDatePickerModel ? this.internalDatePickerModel + 'T' : Date() + 'T';
478
- this.debug && console.log('minTimeValidation ' + this.label, moment(prefix + this.internalTimePickerModel));
479
- this.debug && console.log('minTimeValidation ' + this.label, moment(this.minDateValue + 'T' + this.minTimeValueForValidation));
480
- return this.min ? moment(prefix + this.internalTimePickerModel).isSame(moment(this.minDateValue + 'T' + this.minTimeValueForValidation)) || moment(prefix + this.internalTimePickerModel).isAfter(moment(this.minDateValue + 'T' + this.minTimeValueForValidation)) : null;
481
- },
482
- maxTimeValidation() {
483
- let prefix = this.internalDatePickerModel ? this.internalDatePickerModel + 'T' : Date() + 'T';
484
- this.debug && console.log('maxTimeValidation ' + this.label, moment(prefix + this.internalTimePickerModel));
485
- this.debug && console.log('maxTimeValidation ' + this.label, moment(this.maxDateValue + 'T' + this.maxTimeValueForValidation));
486
- return this.max ? moment(prefix + this.internalTimePickerModel).isSame(moment(this.maxDateValue + 'T' + this.maxTimeValueForValidation)) || moment(prefix + this.internalTimePickerModel).isBefore(moment(this.maxDateValue + 'T' + this.maxTimeValueForValidation)) : null;
487
- },
488
- ISOdateFormat() {
489
- return this.isoDateFormat || (this.$store && this.$store.getters && this.$store.getters.dateFormat) || 'DD/MM/YYYY';
490
- },
491
- ISOtimeFormat() {
492
- return this.timesecs ? 'HH:mm:ss' : 'HH:mm'; // (this.$store && this.$store.getters && this.$store.getters.timeFormat)
493
- },
494
- getDateRules() {
495
- const rules = [...this.rules];
496
- if (this.required) {
497
- var func = (value) => !!value || this.requiredMessage;
498
- rules.push(func);
499
- }
500
- var func2 = () => !this.internalDateError || this.internalDateErrorMessage;
501
- rules.push(func2);
502
- return rules;
503
- },
504
- getTimeRules() {
505
- const rules = [...this.rules];
506
- if (this.required) {
507
- var func = (value) => !!value || this.requiredMessage;
508
- rules.push(func);
509
- }
510
- var func2 = () => !this.internalTimeError || this.internalTimeErrorMessage;
511
- rules.push(func2);
512
- return rules;
513
- },
514
- showTime() {
515
- return this.time || this.timesecs;
516
- },
517
- allowedTimeLength() {
518
- return this.timesecs ? 8 : 5;
519
- },
520
- getDateMask() {
521
- // const defaultMask = '##/##/####',
522
-
523
- let mask = this.ISOdateFormat.replace(/Y/g, '#');
524
- mask = mask.replace(/M/g, '#');
525
- mask = mask.replace(/D/g, '#');
526
-
527
- return mask;
528
- },
529
- getTimeMask() {
530
- if (this.time) {
531
- return '##:##';
532
- } else if (this.timesecs) {
533
- return '##:##:##';
534
- }
535
- return '##:##:##';
536
- },
537
- getMobileClass() {
538
- return { 'v-text-field--edited': this.isEdited, 'v-text-field--required': this.required };
539
- },
540
- getLabelRequiredClass() {
541
- return { 'v-label--required': this.required };
542
- },
543
- getEditedDateClass() {
544
- return { 'v-text-field--edited': this.isEditedDate };
545
- },
546
- getEditedTimeClass() {
547
- return { 'v-text-field--edited': this.isEditedTime };
548
- },
549
- isEditedDate() {
550
- if (this.noeditable || this.disabled || this.readonly) {
551
- return false;
552
- } else {
553
- const newDate = this.internalDateFieldModel;
554
- if (this.initialDateValue !== newDate) {
555
- return true;
556
- }
557
- return false;
558
- }
559
- },
560
- isEditedTime() {
561
- if (this.noeditable || this.disabled || this.readonly) {
562
- return false;
563
- } else {
564
- const newTime = this.internalTimeFieldModel;
565
- if (this.initialTimeValue !== newTime) {
566
- return true;
567
- }
568
- return false;
569
- }
570
- },
571
- getDatePlaceholder() {
572
- return this.ISOdateFormat;
573
- },
574
- getTimePlaceholder() {
575
- return this.time ? this.ISOtimeFormat : '';
576
- },
577
- showTooltip() {
578
- if (this.getLabel === '' || this.getLabel === null) {
579
- return false;
580
- }
581
- return this.tooltipDescription || this.tooltip;
582
- }
583
- },
584
- watch: {
585
- value(val) {
586
- this.debug && console.log('watch value', val);
587
-
588
- if (this.firstLoad) {
589
- this.initializeModel(val);
590
- this.firstLoad = false;
591
- } else {
592
- this.setModel(val);
593
- }
594
- },
595
- internalDatePickerModel(val) {
596
- this.debug && console.log('watch internalDatePickerModel', val);
597
-
598
- if (val != null) {
599
- let formattedDate = dateTimeUtils.getLocalFormattedDate(val, this.ISOdateFormat);
600
- if (formattedDate != this.internalDateFieldModel) {
601
- this.updateDateFieldModel(formattedDate);
602
- }
603
- }
604
- },
605
- internalTimePickerModel(val) {
606
- this.debug && console.log('watch internalTimePickerModel', val);
607
-
608
- if (val != this.internalTimeFieldModel) {
609
- this.updateTimeFieldModel(val);
610
- }
611
- },
612
- internalDateErrorMessage() {
613
- this.$refs[`dateField${this.attach !== null ? this.attach : this.defaultId}`].validate();
614
- },
615
- internalTimeErrorMessage() {
616
- this.showTime && this.$refs[`timeField${this.attach !== null ? this.attach : this.defaultId}`].validate();
617
- },
618
- max() {
619
- this.allValidations();
620
- this.setTooltip();
621
- },
622
- min() {
623
- this.allValidations();
624
- this.setTooltip();
625
- }
626
- },
627
- created() {
628
- this.setInitialValues();
629
- this.initializeModel(this.value);
630
- },
631
- mounted() {
632
- this.setTooltip();
633
- },
634
- methods: {
635
- initializeModel(value) {
636
- if (value !== null && value !== undefined) {
637
- this.setModel(value);
638
- } else if (this.today) {
639
- let todayValue = dateTimeUtils.getLocalDateNow() + 'T' + dateTimeUtils.getLocalTimeNow();
640
- this.setModel(todayValue);
641
- }
642
- },
643
- setInitialValues() {
644
- this.firstLoad = false;
645
- this.initialValue = this.value;
646
- this.initialDateValue = this.internalDateFieldModel;
647
- this.initialTimeValue = this.internalTimeFieldModel;
648
- },
649
- setModel(val) {
650
- this.debug && console.log('setModel', val);
651
-
652
- if (val) {
653
- const newDateFieldModel = moment(val).format(this.ISOdateFormat);
654
- const newDatePickerModel = moment(val).format(this.internalDatePickerFormat);
655
- const newTimeModel = moment(val).format(this.ISOtimeFormat);
656
-
657
- this.debug && console.log('newDatePickerModel', newDatePickerModel);
658
- this.debug && console.log('newDateFieldModel', newDateFieldModel);
659
- this.debug && console.log('newTimeModel', newTimeModel);
660
-
661
- this.internalDatePickerModel = newDatePickerModel;
662
- this.internalDateFieldModel = newDateFieldModel;
663
- this.internalTimePickerModel = newTimeModel;
664
- this.internalTimeFieldModel = newTimeModel;
665
-
666
- this.allValidations();
667
- this.internalUTCModel = val;
668
- } else {
669
- this.internalDatePickerModel = null;
670
- this.internalDateFieldModel = null;
671
- this.internalTimePickerModel = null;
672
- this.internalTimeFieldModel = null;
673
- this.internalUTCModel = null;
674
- }
675
-
676
-
677
- },
678
- updateDateFieldModel(val) {
679
- this.debug && console.log('updateDateFieldModel', val);
680
- this.dateMenuModel = false;
681
-
682
- if (val) {
683
- if (val.length == 10) {
684
- this.internalDateFieldModel = val;
685
- this.internalDatePickerModel = dateTimeUtils.getLocalFormattedDate(
686
- moment(val, this.ISOdateFormat),
687
- this.internalDatePickerFormat
688
- );
689
- this.updateInternalUTCModel(this.internalDateFieldModel, this.internalTimeFieldModel);
690
- }
691
-
692
- if (val.length > 10) {
693
- this.internalDateFieldModel = val.substring(0, 10);
694
- this.updateInternalUTCModel(this.internalDateFieldModel, this.internalTimeFieldModel);
695
- this.refresher++;
696
- }
697
- } else {
698
- this.internalDateFieldModel = null;
699
- this.internalDatePickerModel = null;
700
- this.updateInternalUTCModel(null, this.internalTimeFieldModel);
701
- }
702
-
703
- this.clearDateErrorMessages();
704
- this.validateMinMaxDate(dateTimeUtils.getLocalFormattedDate(moment(this.internalDateFieldModel, this.ISOdateFormat)));
705
- this.validateDate(this.internalDateFieldModel);
706
- this.validateRequiredDate(this.internalDateFieldModel);
707
- },
708
- updateTimeFieldModel(val) {
709
- this.debug && console.log('updateTimeFieldModel ', val);
710
- //this.timeMenuModel = false;
711
-
712
- if (val) {
713
- if (val.length == 2 && val[1] == ':') {
714
- val = '0' + val[0] + ':';
715
- this.internalTimeFieldModel = val;
716
- }
717
-
718
- if (val.length == 2 && parseInt(val) > 24) {
719
- val = 23 + ':';
720
- this.internalTimeFieldModel = val;
721
- }
722
-
723
- if (val.length == 2) {
724
- val = val + ':';
725
- this.internalTimeFieldModel = val;
726
- }
727
-
728
- if (val.length == 5 && parseInt(val.substring(3, 5)) > 59) {
729
- val = val.substring(0, 2) + ':59';
730
- if (this.timesecs) {
731
- val = val + ':';
732
- }
733
- this.internalTimeFieldModel = val;
734
- }
735
-
736
- if (this.timesecs && val.length == 5) {
737
- val = val + ':';
738
- this.internalTimeFieldModel = val;
739
- }
740
-
741
- if (val.length == 8 && parseInt(val.substring(6, 8)) > 59) {
742
- val = val.substring(0, 5) + ':59';
743
- this.internalTimeFieldModel = val;
744
- }
745
-
746
- if (val.length == this.allowedTimeLength) {
747
- this.internalTimeFieldModel = val;
748
- this.internalTimePickerModel = val;
749
- this.updateInternalUTCModel(this.internalDateFieldModel, val);
750
- }
751
-
752
- if (val.length > this.allowedTimeLength) {
753
- this.internalTimeFieldModel = val.substring(0, this.allowedTimeLength);
754
- this.updateInternalUTCModel(this.internalDateFieldModel, this.internalTimeFieldModel);
755
- this.refresher++;
756
- }
757
- } else {
758
- this.internalTimeFieldModel = null;
759
- this.internalTimePickerModel = null;
760
- this.updateInternalUTCModel(this.internalDateFieldModel, null);
761
- }
762
-
763
- this.clearTimeErrorMessages();
764
- this.validateMinMaxTime(this.internalDateFieldModel + ' ' + this.internalTimeFieldModel);
765
- this.validateTime(this.internalTimeFieldModel);
766
- this.validateRequiredTime(this.internalTimeFieldModel);
767
- },
768
- updateInternalUTCModel(date, time) {
769
- this.debug && console.log('updateInternalUTCModel date', date);
770
- this.debug && console.log('updateInternalUTCModel time', time);
771
-
772
- if (date == null && time == null) {
773
- this.internalUTCModel = null;
774
- this.$emit('input', null);
775
- return;
776
- }
777
-
778
- if (time == null || time == undefined) {
779
- time = '00:00:00';
780
- }
781
-
782
- let localStringDate = date + ' ' + time;
783
- let internalUTCModel = moment(localStringDate, this.ISOdateFormat + this.ISOtimeFormat).utc().format();
784
-
785
- this.debug && console.log('localStringDate', localStringDate);
786
- this.debug && console.log('internalUTCModel', internalUTCModel);
787
-
788
- this.firstLoad = false;
789
- this.allValidations();
790
-
791
- if (this.validateUTCDate(internalUTCModel) & this.validateRequiredDate(date) & this.validateRequiredTime(time) & internalUTCModel != this.value) {
792
- this.internalUTCModel = internalUTCModel;
793
-
794
- if (internalUTCModel != this.value) {
795
- this.debug && console.log('emit internalUTCModel', internalUTCModel);
796
- this.$emit('input', internalUTCModel);
797
- }
798
- }
799
- },
800
- allValidations() {
801
- this.debug && console.log('allValidations');
802
-
803
- this.clearErrorMessages();
804
- this.internalDatePickerModel && this.validateMinMaxDate(dateTimeUtils.getLocalFormattedDate(moment(this.internalDatePickerModel, this.ISOdateFormat)));
805
- this.internalTimePickerModel && this.validateMinMaxTime(this.internalDateFieldModel + ' ' + this.internalTimePickerModel);
806
- this.internalUTCModel && this.validateUTCDate(this.internalUTCModel);
807
- this.internalDatePickerModel && this.validateRequiredDate(this.internalDatePickerModel);
808
- this.internalTimePickerModel && this.validateRequiredTime(this.internalTimePickerModel);
809
- },
810
- validateRequiredDate(date) {
811
- this.debug && console.log('validateRequiredDate', date);
812
-
813
- if (this.required && (date === undefined || date === null || date === '')) {
814
- this.showRequiredDateMessage();
815
- this.debug && console.log('validateRequiredDate', false);
816
- return false;
817
- }
818
-
819
- return true;
820
- },
821
- validateRequiredTime(time) {
822
- this.debug && console.log('validateRequiredTime', time);
823
-
824
- if (this.showTime && this.required && (time === undefined || time === null || time === '')) {
825
- this.showRequiredTimeMessage();
826
- this.debug && console.log('validateRequiredTime', false);
827
- return false;
828
- }
829
-
830
- return true;
831
- },
832
- validateDate(date) {
833
- this.debug && console.log('validateDate', date);
834
-
835
- if (!date && !this.required) {
836
- return true;
837
- }
838
-
839
- let validation = moment(date, this.ISOdateFormat).isValid();
840
-
841
- if (date && date.length != this.getDateMask.length || date == 'Invalid date' || date == 'Invalid dat' || date == 'Invalid da' || !validation) {
842
- this.showErrorDateMessage();
843
- this.debug && console.log('validateDate', false);
844
- return false;
845
- }
846
-
847
- return true;
848
- },
849
- validateTime(time) {
850
- this.debug && console.log('validateTime', time);
851
- if (this.showTime) {
852
- let timeRegex = new RegExp('^([0-1][0-9]|2[0-3]):([0-5][0-9])$');
853
- if (this.timesecs) {
854
- timeRegex = new RegExp('^([0-1][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$');
855
- }
856
-
857
- if (time == null) {
858
- return true;
859
- }
860
-
861
- if (time.match(timeRegex)) {
862
- return true;
863
- }
864
-
865
- this.showErrorTimeMessage();
866
- this.debug && console.log('validateTime', false);
867
- return false;
868
- }
869
- },
870
- validateUTCDate(fullDate) {
871
- this.debug && console.log('validateUTCDate', fullDate);
872
-
873
- let validation = moment(fullDate).isValid();
874
-
875
- if (fullDate == 'Invalid date' || fullDate == 'Invalid dat' || fullDate == 'Invalid da' || !validation) {
876
- this.debug && console.log('validateUTCDate', false);
877
- return false;
878
- }
879
-
880
- return true;
881
- },
882
- validateMinMaxDate(date) {
883
- this.debug && console.log('validateMinMaxDate ' + this.label, date);
884
-
885
- if (!date && !this.required) {
886
- return true;
887
- }
888
-
889
- if (this.max && !this.maxDateValidation) {
890
- this.showErrorMinMaxDateMessage();
891
- this.debug && console.log('validateMinMaxDate ' + this.label, false);
892
- return false;
893
- }
894
-
895
- if (this.min && !this.minDateValidation) {
896
- this.showErrorMinMaxDateMessage();
897
- this.debug && console.log('validateMinMaxDate ' + this.label, false);
898
- return false;
899
- }
900
-
901
- return true;
902
- },
903
- validateMinMaxTime(time) {
904
- this.debug && console.log('validateMinMaxTime ' + this.label, time);
905
-
906
- if (!time && !this.required) {
907
- return true;
908
- }
909
-
910
- if (this.max && !this.maxTimeValidation) {
911
- this.showErrorMinMaxTimeMessage();
912
- return false;
913
- }
914
-
915
- if (this.min && !this.minTimeValidation) {
916
- this.showErrorMinMaxTimeMessage();
917
- return false;
918
- }
919
-
920
- return true;
921
- },
922
- clearErrorMessages() {
923
- this.clearDateErrorMessages();
924
- this.clearTimeErrorMessages();
925
- },
926
- clearDateErrorMessages() {
927
- this.internalDateError = false;
928
- this.internalDateErrorMessage = '';
929
- },
930
- clearTimeErrorMessages() {
931
- this.internalTimeError = false;
932
- this.internalTimeErrorMessage = '';
933
- },
934
- showRequiredDateMessage() {
935
- this.internalDateError = true;
936
- this.internalDateErrorMessage = this.requiredMessage;
937
- },
938
- showRequiredTimeMessage() {
939
- this.internalTimeError = true;
940
- this.internalTimeErrorMessage = this.requiredMessage;
941
- },
942
- showErrorDateMessage() {
943
- this.internalDateError = true;
944
- this.internalDateErrorMessage =
945
- this.$t('pui9.components.dateField.errorDate') + ',' + this.$t('pui9.components.dateField.correctFormat') + ' ' + this.ISOdateFormat;
946
- },
947
- showErrorTimeMessage() {
948
- this.internalTimeError = true;
949
- this.internalTimeErrorMessage = this.$t('pui9.components.dateField.errorTime');
950
- },
951
- showErrorMinMaxDateMessage() {
952
- this.internalDateError = true;
953
- let dateformat = this.ISOdateFormat;
954
-
955
- var min = dateTimeUtils.getLocalFormattedDate(this.min, dateformat);
956
- var max = dateTimeUtils.getLocalFormattedDate(this.max, dateformat);
957
-
958
- if (this.min && this.max) {
959
- this.internalDateErrorMessage = this.internalTimeErrorMessage =
960
- this.$t('pui9.components.dateField.errorRangeDate') + min + ' ' + this.$t('pui9.components.dateField.and') + ' ' + max;
961
- } else if (this.min && !this.max) {
962
- this.internalDateErrorMessage = this.$t('pui9.components.dateField.errorMinDate') + min;
963
- } else {
964
- this.internalDateErrorMessage = this.$t('pui9.components.dateField.errorMaxDate') + max;
965
- }
966
- },
967
- showErrorMinMaxTimeMessage() {
968
- this.internalTimeError = true;
969
- let dateformat = this.ISOdateFormat + ' ' + this.ISOtimeFormat;
970
-
971
- var min = dateTimeUtils.getLocalFormattedDate(this.min, dateformat);
972
- var max = dateTimeUtils.getLocalFormattedDate(this.max, dateformat);
973
-
974
- if (this.min && this.max) {
975
- this.internalDateErrorMessage = this.internalTimeErrorMessage =
976
- this.$t('pui9.components.dateField.errorRangeDate') + min + ' ' + this.$t('pui9.components.dateField.and') + ' ' + max;
977
- } else if (this.min && !this.max) {
978
- this.internalTimeErrorMessage = this.$t('pui9.components.dateField.errorMinDate') + min;
979
- } else {
980
- this.internalTimeErrorMessage = this.$t('pui9.components.dateField.errorMaxDate') + max;
981
- }
982
- },
983
- getOffset() {
984
- var offset = dateTimeUtils.getUTCOffset();
985
- if (offset === 0) {
986
- return '+00:00';
987
- }
988
- var hour = offset / 60;
989
- if (hour) {
990
- if (hour && hour.toString().length === 1) {
991
- if (hour > 0) {
992
- return '+0' + hour + ':00';
993
- } else {
994
- return '-0' + hour + ':00';
995
- }
996
- } else if (hour && hour.toString().length === 2) {
997
- if (hour > 0) {
998
- return '+' + hour + ':00';
999
- } else {
1000
- return '-' + hour + ':00';
1001
- }
1002
- }
1003
- }
1004
- return '';
1005
- },
1006
- setTooltip() {
1007
- if (this.tooltip && this.$refs.tooltip) {
1008
- this.$refs.tooltip.clearMessages();
1009
-
1010
- if (this.showTime) {
1011
- this.$refs.tooltip.pushMessage(
1012
- this.$t('pui9.components.dateField.tooltipFormat') + this.ISOdateFormat + ' ' + this.ISOtimeFormat
1013
- );
1014
- } else {
1015
- this.$refs.tooltip.pushMessage(this.$t('pui9.components.dateField.tooltipFormat') + this.ISOdateFormat);
1016
- }
1017
-
1018
- if (this.max) {
1019
- let format = '';
1020
- if (this.showTime) {
1021
- format = this.ISOdateFormat + ' ' + this.ISOtimeFormat;
1022
- } else {
1023
- format = this.ISOdateFormat;
1024
- }
1025
- var localMaxDate = dateTimeUtils.getLocalFormattedDate(this.max, format);
1026
- this.$refs.tooltip.pushMessage(this.$t('pui9.components.dateField.tooltipMaxDate') + localMaxDate);
1027
- }
1028
-
1029
- if (this.min) {
1030
- let format = '';
1031
- if (this.showTime) {
1032
- format = this.ISOdateFormat + ' ' + this.ISOtimeFormat;
1033
- } else {
1034
- format = this.ISOdateFormat;
1035
- }
1036
- var localMinDate = dateTimeUtils.getLocalFormattedDate(this.min, format);
1037
- this.$refs.tooltip.pushMessage(this.$t('pui9.components.dateField.tooltipMinDate') + localMinDate);
1038
- }
1039
- }
1040
- }
1041
- }
1042
- };
1043
- </script>