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