pui9-components 1.16.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -0
- package/dist/demo.html +10 -0
- package/dist/pui9-components.common.js +81953 -0
- package/dist/pui9-components.common.js.map +1 -0
- package/dist/pui9-components.css +5 -0
- package/dist/pui9-components.umd.js +81963 -0
- package/dist/pui9-components.umd.js.map +1 -0
- package/dist/pui9-components.umd.min.js +308 -0
- package/dist/pui9-components.umd.min.js.map +1 -0
- package/package-lock.json +15945 -0
- package/package.json +78 -0
- package/src/App.vue +117 -0
- package/src/components/PuiCheckbox.vue +105 -0
- package/src/components/PuiCodeEditor.vue +123 -0
- package/src/components/PuiDateField.vue +1004 -0
- package/src/components/PuiField.vue +30 -0
- package/src/components/PuiFieldSet.vue +27 -0
- package/src/components/PuiFormFooter.vue +64 -0
- package/src/components/PuiFormFooterBtns.vue +118 -0
- package/src/components/PuiFormHeader.vue +25 -0
- package/src/components/PuiFormLoading.vue +12 -0
- package/src/components/PuiFormMiniAudit.vue +53 -0
- package/src/components/PuiMasterDetail.vue +96 -0
- package/src/components/PuiModalDialog.vue +87 -0
- package/src/components/PuiModalDialogForm.vue +205 -0
- package/src/components/PuiMultiSelect.vue +499 -0
- package/src/components/PuiNumberField.vue +503 -0
- package/src/components/PuiPasswordField.vue +105 -0
- package/src/components/PuiRadioGroup.vue +105 -0
- package/src/components/PuiRichTextEditor.vue +117 -0
- package/src/components/PuiSelect.vue +1638 -0
- package/src/components/PuiSelectDetailDialog.vue +106 -0
- package/src/components/PuiSelectTextService.vue +61 -0
- package/src/components/PuiSpinnerField.vue +484 -0
- package/src/components/PuiSwitch.vue +104 -0
- package/src/components/PuiTextArea.vue +203 -0
- package/src/components/PuiTextField.vue +272 -0
- package/src/dateTimeUtils.js +78 -0
- package/src/index.js +73 -0
- package/src/main.js +33 -0
- package/src/mixins/PuiFormComponentMixin.js +81 -0
- package/src/mixins/PuiMultiSelectMixin.js +106 -0
- package/src/mixins/PuiUtilsNumberMixin.js +19 -0
- package/src/plugins/vuetify.js +32 -0
- package/src/tests/TestAutocomplete.vue +138 -0
- package/src/tests/TestCodeEditor.vue +48 -0
- package/src/tests/TestField.vue +22 -0
- package/src/tests/TestFieldSet.vue +30 -0
- package/src/tests/TestInputCheckbox.vue +53 -0
- package/src/tests/TestInputDate.vue +146 -0
- package/src/tests/TestInputNumber.vue +77 -0
- package/src/tests/TestInputRadioGroup.vue +86 -0
- package/src/tests/TestInputSpinner.vue +77 -0
- package/src/tests/TestInputSwitch.vue +52 -0
- package/src/tests/TestInputText.vue +120 -0
- package/src/tests/TestInputTextArea.vue +73 -0
- package/src/tests/TestMultiSelect.vue +127 -0
- package/src/tests/TestPuiForm.vue +68 -0
- package/src/tests/TestRichTextEditor.vue +54 -0
- package/src/utils.js +148 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-switch
|
|
3
|
+
class="pui-switch"
|
|
4
|
+
:class="isRequired"
|
|
5
|
+
v-model="internalModel"
|
|
6
|
+
v-bind="allProps"
|
|
7
|
+
:rules="getRules"
|
|
8
|
+
:label="getLabel"
|
|
9
|
+
@change="updateValue"
|
|
10
|
+
:ripple="false"
|
|
11
|
+
:false-value="falseValue"
|
|
12
|
+
:true-value="trueValue"
|
|
13
|
+
:error="internalError"
|
|
14
|
+
></v-switch>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script>
|
|
18
|
+
import PuiFormComponentMixin from '../mixins/PuiFormComponentMixin';
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
name: 'PuiSwitch',
|
|
22
|
+
mixins: [PuiFormComponentMixin],
|
|
23
|
+
props: {
|
|
24
|
+
value: {
|
|
25
|
+
required: false
|
|
26
|
+
},
|
|
27
|
+
rules: {
|
|
28
|
+
type: Array,
|
|
29
|
+
default: () => {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
// falseValue en lugar de 'false-value' para que funcione. Lo mismo con el true
|
|
34
|
+
falseValue: {
|
|
35
|
+
type: [Boolean, String, Number],
|
|
36
|
+
default: false,
|
|
37
|
+
required: false
|
|
38
|
+
},
|
|
39
|
+
trueValue: {
|
|
40
|
+
type: [Boolean, String, Number],
|
|
41
|
+
default: true,
|
|
42
|
+
required: false
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
computed: {
|
|
46
|
+
getRules() {
|
|
47
|
+
const rules = [...this.rules];
|
|
48
|
+
if (this.required) {
|
|
49
|
+
var func = (value) => !!value || this.requiredMessage;
|
|
50
|
+
var func2 = () => !this.internalError;
|
|
51
|
+
var func3 = () => {
|
|
52
|
+
if (this.internalModel === false) {
|
|
53
|
+
return this.requiredMessage;
|
|
54
|
+
}
|
|
55
|
+
return true;
|
|
56
|
+
};
|
|
57
|
+
rules.push(func, func2, func3);
|
|
58
|
+
}
|
|
59
|
+
return rules;
|
|
60
|
+
},
|
|
61
|
+
isRequired() {
|
|
62
|
+
return { 'v-input--checkbox--required': this.required };
|
|
63
|
+
},
|
|
64
|
+
requiredMessage() {
|
|
65
|
+
return this.$t('pui9.error.field_selected');
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
watch: {
|
|
69
|
+
value(val) {
|
|
70
|
+
this.internalModel = val;
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
created() {
|
|
74
|
+
this.initialValue = this.value; // no se usa
|
|
75
|
+
this.internalModel = this.value;
|
|
76
|
+
|
|
77
|
+
// Hay que pasar el value a string para que si llega del servidor '1' (por poner un ejemplo) el
|
|
78
|
+
// switch lo detecte como activo
|
|
79
|
+
if (this.value && typeof this.value !== 'boolean') {
|
|
80
|
+
this.internalModel = this.value.toString();
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
methods: {
|
|
84
|
+
updateValue(value) {
|
|
85
|
+
this.$emit('input', value);
|
|
86
|
+
this.checkValue();
|
|
87
|
+
},
|
|
88
|
+
checkValue() {
|
|
89
|
+
this.clearMessages();
|
|
90
|
+
if (this.required) {
|
|
91
|
+
if (this.internalModel === false) {
|
|
92
|
+
this.showErrorMessage();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
clearMessages() {
|
|
97
|
+
this.internalError = false;
|
|
98
|
+
},
|
|
99
|
+
showErrorMessage() {
|
|
100
|
+
this.internalError = true;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
</script>
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- DESKTOP - TABLET -->
|
|
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;'"> </label>
|
|
8
|
+
<label v-else :class="getLabelRequiredClass">{{ getLabel }}</label>
|
|
9
|
+
</v-flex>
|
|
10
|
+
</v-layout>
|
|
11
|
+
<v-layout>
|
|
12
|
+
<v-flex xs12>
|
|
13
|
+
<v-textarea
|
|
14
|
+
v-model="internalModel"
|
|
15
|
+
v-bind="allProps"
|
|
16
|
+
:class="getEditedClass"
|
|
17
|
+
:rules="getRules"
|
|
18
|
+
solo
|
|
19
|
+
outlined
|
|
20
|
+
flat
|
|
21
|
+
single-line
|
|
22
|
+
auto-grow
|
|
23
|
+
@blur="updateValueLazy"
|
|
24
|
+
@input="updateValueRealtime"
|
|
25
|
+
:placeholder="getPlaceholder"
|
|
26
|
+
:error="internalError"
|
|
27
|
+
></v-textarea>
|
|
28
|
+
</v-flex>
|
|
29
|
+
</v-layout>
|
|
30
|
+
</div>
|
|
31
|
+
<div v-else class="ml-1 mr-1">
|
|
32
|
+
<v-layout>
|
|
33
|
+
<v-flex :class="labelColumnStyles ? labelColumnStyles : 'xs12 sm6 md4 xl3'">
|
|
34
|
+
<label :class="getLabelRequiredClass">{{ getLabel }}</label>
|
|
35
|
+
</v-flex>
|
|
36
|
+
<v-flex :class="valueColumnStyles ? valueColumnStyles : 'xs12 sm6 md8 xl9'">
|
|
37
|
+
<v-textarea
|
|
38
|
+
v-model="internalModel"
|
|
39
|
+
v-bind="allProps"
|
|
40
|
+
:class="getEditedClass"
|
|
41
|
+
:rules="getRules"
|
|
42
|
+
solo
|
|
43
|
+
outlined
|
|
44
|
+
flat
|
|
45
|
+
single-line
|
|
46
|
+
auto-grow
|
|
47
|
+
@blur="updateValueLazy"
|
|
48
|
+
@input="updateValueRealtime"
|
|
49
|
+
:placeholder="getPlaceholder"
|
|
50
|
+
:error="internalError"
|
|
51
|
+
></v-textarea>
|
|
52
|
+
</v-flex>
|
|
53
|
+
</v-layout>
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
<!-- MOBILE -->
|
|
57
|
+
<div v-else>
|
|
58
|
+
<v-layout>
|
|
59
|
+
<v-flex xs12>
|
|
60
|
+
<v-textarea
|
|
61
|
+
v-model="internalModel"
|
|
62
|
+
v-bind="allProps"
|
|
63
|
+
:class="getMobileClass"
|
|
64
|
+
:rules="getRules"
|
|
65
|
+
class="v-text-field--mobile"
|
|
66
|
+
:label="getLabel"
|
|
67
|
+
flat
|
|
68
|
+
auto-grow
|
|
69
|
+
@blur="updateValueLazy"
|
|
70
|
+
@input="updateValueRealtime"
|
|
71
|
+
:placeholder="getPlaceholder"
|
|
72
|
+
:error="internalError"
|
|
73
|
+
></v-textarea>
|
|
74
|
+
</v-flex>
|
|
75
|
+
</v-layout>
|
|
76
|
+
</div>
|
|
77
|
+
</template>
|
|
78
|
+
|
|
79
|
+
<script>
|
|
80
|
+
import PuiFormComponentMixin from '../mixins/PuiFormComponentMixin';
|
|
81
|
+
|
|
82
|
+
export default {
|
|
83
|
+
name: 'PuiTextArea',
|
|
84
|
+
mixins: [PuiFormComponentMixin],
|
|
85
|
+
data: () => ({
|
|
86
|
+
rules: []
|
|
87
|
+
}),
|
|
88
|
+
props: {
|
|
89
|
+
value: {
|
|
90
|
+
type: [String, Number],
|
|
91
|
+
required: false
|
|
92
|
+
},
|
|
93
|
+
realtime: {
|
|
94
|
+
type: Boolean,
|
|
95
|
+
required: false,
|
|
96
|
+
default: false
|
|
97
|
+
},
|
|
98
|
+
placeholder: {
|
|
99
|
+
type: String,
|
|
100
|
+
default: ' ',
|
|
101
|
+
required: false
|
|
102
|
+
},
|
|
103
|
+
noLazyModel: {
|
|
104
|
+
type: Boolean,
|
|
105
|
+
required: false,
|
|
106
|
+
default: false
|
|
107
|
+
},
|
|
108
|
+
labelColumnStyles: {
|
|
109
|
+
type: String,
|
|
110
|
+
required: false
|
|
111
|
+
},
|
|
112
|
+
valueColumnStyles: {
|
|
113
|
+
type: String,
|
|
114
|
+
required: false
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
computed: {
|
|
118
|
+
getLabelRequiredClass() {
|
|
119
|
+
return { 'v-label--required': this.required };
|
|
120
|
+
},
|
|
121
|
+
getEditedClass() {
|
|
122
|
+
return { 'v-text-field--edited': this.isEdited };
|
|
123
|
+
},
|
|
124
|
+
getMobileClass() {
|
|
125
|
+
return { 'v-text-field--edited': this.isEdited, 'v-text-field--required': this.required };
|
|
126
|
+
},
|
|
127
|
+
getRules() {
|
|
128
|
+
const rules = [...this.rules];
|
|
129
|
+
if (this.required) {
|
|
130
|
+
var func = (value) => !!value || this.requiredMessage;
|
|
131
|
+
var func2 = () => !this.internalError;
|
|
132
|
+
var func3 = () => {
|
|
133
|
+
if (this.internalModel === '' || this.internalModel === null) {
|
|
134
|
+
return this.requiredMessage;
|
|
135
|
+
}
|
|
136
|
+
return true;
|
|
137
|
+
};
|
|
138
|
+
rules.push(func, func2, func3);
|
|
139
|
+
}
|
|
140
|
+
return rules;
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
watch: {
|
|
144
|
+
value(val) {
|
|
145
|
+
if (!this.noLazyModel && !this.firstLazyLoad) {
|
|
146
|
+
this.initializeModel(val);
|
|
147
|
+
this.firstLazyLoad = true;
|
|
148
|
+
} else {
|
|
149
|
+
this.internalModel = val;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
created() {
|
|
154
|
+
if (this.noLazyModel) {
|
|
155
|
+
this.firstLazyLoad = true;
|
|
156
|
+
}
|
|
157
|
+
this.initialValue = this.value;
|
|
158
|
+
this.initializeModel(this.value);
|
|
159
|
+
},
|
|
160
|
+
methods: {
|
|
161
|
+
updateValueLazy() {
|
|
162
|
+
this.checkValue();
|
|
163
|
+
if (!this.realtime) {
|
|
164
|
+
this.internalModel = this.sanitizePuiFormHtmlText(this.internalModel);
|
|
165
|
+
if (this.internalModel === '' || this.internalModel === 'null' || this.internalModel === 'undefined') {
|
|
166
|
+
this.internalModel = undefined;
|
|
167
|
+
}
|
|
168
|
+
this.$emit('input', this.internalModel);
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
updateValueRealtime() {
|
|
172
|
+
this.checkValue();
|
|
173
|
+
if (this.realtime) {
|
|
174
|
+
this.internalModel = this.sanitizePuiFormHtmlText(this.internalModel);
|
|
175
|
+
if (this.internalModel === '' || this.internalModel === 'null' || this.internalModel === 'undefined') {
|
|
176
|
+
this.internalModel = undefined;
|
|
177
|
+
}
|
|
178
|
+
this.$emit('input', this.internalModel);
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
initializeModel(value) {
|
|
182
|
+
this.internalModel = value;
|
|
183
|
+
if (value !== null && !this.firstLazyLoad) {
|
|
184
|
+
this.firstLazyLoad = true;
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
checkValue() {
|
|
188
|
+
this.clearMessages();
|
|
189
|
+
if (this.required) {
|
|
190
|
+
if (this.internalModel === '' || this.internalModel === null) {
|
|
191
|
+
this.showErrorMessage();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
clearMessages() {
|
|
196
|
+
this.internalError = false;
|
|
197
|
+
},
|
|
198
|
+
showErrorMessage() {
|
|
199
|
+
this.internalError = true;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
</script>
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- DESKTOP - TABLET -->
|
|
3
|
+
<div v-if="!isMobile">
|
|
4
|
+
<div v-if="toplabel || !hasLabel" class="ml-1 mr-1">
|
|
5
|
+
<v-layout v-if="hasLabel">
|
|
6
|
+
<v-flex xs12>
|
|
7
|
+
<label v-if="getLabel === '$nbsp;'"> </label>
|
|
8
|
+
<label v-else :class="getLabelRequiredClass">{{ getLabel }}</label>
|
|
9
|
+
<v-tooltip top v-if="showTooltip">
|
|
10
|
+
<template v-slot:activator="{ on }">
|
|
11
|
+
<v-icon class="info-tooltip" size="14" 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>
|
|
23
|
+
</v-flex>
|
|
24
|
+
</v-layout>
|
|
25
|
+
<v-layout>
|
|
26
|
+
<v-flex xs12>
|
|
27
|
+
<v-text-field
|
|
28
|
+
v-model="internalModel"
|
|
29
|
+
v-bind="allProps"
|
|
30
|
+
:class="getEditedClass"
|
|
31
|
+
:rules="getRules"
|
|
32
|
+
solo
|
|
33
|
+
outlined
|
|
34
|
+
flat
|
|
35
|
+
@blur="updateValueLazy"
|
|
36
|
+
@input="updateValueRealtime"
|
|
37
|
+
:placeholder="getPlaceholder"
|
|
38
|
+
:error="internalError"
|
|
39
|
+
v-on="$listeners"
|
|
40
|
+
></v-text-field>
|
|
41
|
+
</v-flex>
|
|
42
|
+
</v-layout>
|
|
43
|
+
</div>
|
|
44
|
+
<div v-else class="ml-1 mr-1">
|
|
45
|
+
<v-layout>
|
|
46
|
+
<v-flex :class="labelColumnStyles ? labelColumnStyles : 'xs12 sm6 md4 xl3'">
|
|
47
|
+
<label :class="getLabelRequiredClass">{{ getLabel }}</label>
|
|
48
|
+
<v-tooltip top v-if="showTooltip">
|
|
49
|
+
<template v-slot:activator="{ on }">
|
|
50
|
+
<v-icon class="info-tooltip" size="14" v-on="on">fas fa-info-circle info-tooltip</v-icon>
|
|
51
|
+
</template>
|
|
52
|
+
<span>
|
|
53
|
+
<span v-if="this.description !== ''">
|
|
54
|
+
{{ this.description }}
|
|
55
|
+
<hr v-if="this.infoTooltipMessages.length > 0" />
|
|
56
|
+
</span>
|
|
57
|
+
<ul>
|
|
58
|
+
<li v-for="(message, index) in this.infoTooltipMessages" :key="index">{{ message }}</li>
|
|
59
|
+
</ul>
|
|
60
|
+
</span>
|
|
61
|
+
</v-tooltip>
|
|
62
|
+
</v-flex>
|
|
63
|
+
<v-flex :class="valueColumnStyles ? valueColumnStyles : 'xs12 sm6 md8 xl9'">
|
|
64
|
+
<v-text-field
|
|
65
|
+
v-model="internalModel"
|
|
66
|
+
v-bind="allProps"
|
|
67
|
+
:class="getEditedClass"
|
|
68
|
+
:rules="getRules"
|
|
69
|
+
solo
|
|
70
|
+
outlined
|
|
71
|
+
flat
|
|
72
|
+
@blur="updateValueLazy"
|
|
73
|
+
@input="updateValueRealtime"
|
|
74
|
+
:placeholder="getPlaceholder"
|
|
75
|
+
:error="internalError"
|
|
76
|
+
v-on="$listeners"
|
|
77
|
+
></v-text-field>
|
|
78
|
+
</v-flex>
|
|
79
|
+
</v-layout>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
<!-- MOBILE -->
|
|
83
|
+
<div v-else>
|
|
84
|
+
<v-layout>
|
|
85
|
+
<v-flex xs12>
|
|
86
|
+
<v-text-field
|
|
87
|
+
v-model="internalModel"
|
|
88
|
+
v-bind="allProps"
|
|
89
|
+
:class="getMobileClass"
|
|
90
|
+
:rules="getRules"
|
|
91
|
+
class="v-text-field--mobile"
|
|
92
|
+
flat
|
|
93
|
+
@blur="updateValueLazy"
|
|
94
|
+
@input="updateValueRealtime"
|
|
95
|
+
:placeholder="getPlaceholder"
|
|
96
|
+
:error="internalError"
|
|
97
|
+
v-on="$listeners"
|
|
98
|
+
></v-text-field>
|
|
99
|
+
</v-flex>
|
|
100
|
+
</v-layout>
|
|
101
|
+
</div>
|
|
102
|
+
</template>
|
|
103
|
+
|
|
104
|
+
<script>
|
|
105
|
+
import PuiFormComponentMixin from '../mixins/PuiFormComponentMixin';
|
|
106
|
+
|
|
107
|
+
export default {
|
|
108
|
+
name: 'PuiTextField',
|
|
109
|
+
mixins: [PuiFormComponentMixin],
|
|
110
|
+
data: () => ({
|
|
111
|
+
infoTooltipMessages: []
|
|
112
|
+
}),
|
|
113
|
+
props: {
|
|
114
|
+
value: {
|
|
115
|
+
type: [String, Number],
|
|
116
|
+
required: false
|
|
117
|
+
},
|
|
118
|
+
tooltip: {
|
|
119
|
+
type: Boolean,
|
|
120
|
+
required: false,
|
|
121
|
+
default: false
|
|
122
|
+
},
|
|
123
|
+
description: {
|
|
124
|
+
type: String,
|
|
125
|
+
required: false,
|
|
126
|
+
default: ''
|
|
127
|
+
},
|
|
128
|
+
realtime: {
|
|
129
|
+
type: Boolean,
|
|
130
|
+
required: false,
|
|
131
|
+
default: false
|
|
132
|
+
},
|
|
133
|
+
placeholder: {
|
|
134
|
+
type: String,
|
|
135
|
+
required: false,
|
|
136
|
+
default: ' '
|
|
137
|
+
},
|
|
138
|
+
noLazyModel: {
|
|
139
|
+
type: Boolean,
|
|
140
|
+
required: false,
|
|
141
|
+
default: false
|
|
142
|
+
},
|
|
143
|
+
readonly: {
|
|
144
|
+
type: Boolean,
|
|
145
|
+
required: false,
|
|
146
|
+
default: false
|
|
147
|
+
},
|
|
148
|
+
rules: {
|
|
149
|
+
type: Array,
|
|
150
|
+
default: () => {
|
|
151
|
+
return [];
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
maxlength: {
|
|
155
|
+
type: [Number, String],
|
|
156
|
+
required: false
|
|
157
|
+
},
|
|
158
|
+
labelColumnStyles: {
|
|
159
|
+
type: String,
|
|
160
|
+
required: false
|
|
161
|
+
},
|
|
162
|
+
valueColumnStyles: {
|
|
163
|
+
type: String,
|
|
164
|
+
required: false
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
computed: {
|
|
168
|
+
getMobileClass() {
|
|
169
|
+
return { 'v-text-field--edited': this.isEdited, 'v-text-field--required': this.required };
|
|
170
|
+
},
|
|
171
|
+
getLabelRequiredClass() {
|
|
172
|
+
return { 'v-label--required': this.required };
|
|
173
|
+
},
|
|
174
|
+
getEditedClass() {
|
|
175
|
+
return { 'v-text-field--edited': this.isEdited };
|
|
176
|
+
},
|
|
177
|
+
getRules() {
|
|
178
|
+
const rules = [...this.rules];
|
|
179
|
+
if (this.required) {
|
|
180
|
+
var func = (value) => !!value || this.requiredMessage;
|
|
181
|
+
var func2 = () => !this.internalError;
|
|
182
|
+
var func3 = () => {
|
|
183
|
+
if (this.internalModel === '' || this.internalModel === null) {
|
|
184
|
+
return this.requiredMessage;
|
|
185
|
+
}
|
|
186
|
+
return true;
|
|
187
|
+
};
|
|
188
|
+
rules.push(func, func2, func3);
|
|
189
|
+
}
|
|
190
|
+
return rules;
|
|
191
|
+
},
|
|
192
|
+
compPlaceholder() {
|
|
193
|
+
if (this.placeholder && this.placeholder.length > 0) {
|
|
194
|
+
return this.placeholder;
|
|
195
|
+
}
|
|
196
|
+
return ' ';
|
|
197
|
+
},
|
|
198
|
+
showTooltip() {
|
|
199
|
+
if (!this.tooltip || this.getLabel === '' || this.getLabel === null) {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
return (this.infoTooltipMessages.length > 0 || this.description !== '') && this.tooltip;
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
watch: {
|
|
206
|
+
value(val) {
|
|
207
|
+
if (!this.noLazyModel && !this.firstLazyLoad) {
|
|
208
|
+
this.initializeModel(val);
|
|
209
|
+
this.firstLazyLoad = true;
|
|
210
|
+
} else {
|
|
211
|
+
this.internalModel = val;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
created() {
|
|
216
|
+
if (this.noLazyModel) {
|
|
217
|
+
this.firstLazyLoad = true;
|
|
218
|
+
}
|
|
219
|
+
this.initialValue = this.value;
|
|
220
|
+
this.initializeModel(this.value);
|
|
221
|
+
|
|
222
|
+
this.getInfoTooltip();
|
|
223
|
+
},
|
|
224
|
+
methods: {
|
|
225
|
+
getInfoTooltip() {
|
|
226
|
+
if (this.maxlength) {
|
|
227
|
+
this.infoTooltipMessages.push(`${this.$t('pui9.error.field_maxlength')} ${this.maxlength}`);
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
updateValueLazy() {
|
|
231
|
+
this.checkValue();
|
|
232
|
+
if (!this.realtime) {
|
|
233
|
+
this.internalModel = this.sanitizePuiFormHtmlText(this.internalModel);
|
|
234
|
+
if (this.internalModel === '' || this.internalModel === 'null' || this.internalModel === 'undefined') {
|
|
235
|
+
this.internalModel = undefined;
|
|
236
|
+
}
|
|
237
|
+
this.$emit('input', this.internalModel);
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
updateValueRealtime() {
|
|
241
|
+
this.checkValue();
|
|
242
|
+
if (this.realtime) {
|
|
243
|
+
this.internalModel = this.sanitizePuiFormHtmlText(this.internalModel);
|
|
244
|
+
if (this.internalModel === '' || this.internalModel === 'null' || this.internalModel === 'undefined') {
|
|
245
|
+
this.internalModel = undefined;
|
|
246
|
+
}
|
|
247
|
+
this.$emit('input', this.internalModel);
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
initializeModel(value) {
|
|
251
|
+
this.internalModel = value;
|
|
252
|
+
if (value !== null && !this.firstLazyLoad) {
|
|
253
|
+
this.firstLazyLoad = true;
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
checkValue() {
|
|
257
|
+
this.clearMessages();
|
|
258
|
+
if (this.required) {
|
|
259
|
+
if (this.internalModel === '' || this.internalModel === null) {
|
|
260
|
+
this.showErrorMessage();
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
clearMessages() {
|
|
265
|
+
this.internalError = false;
|
|
266
|
+
},
|
|
267
|
+
showErrorMessage() {
|
|
268
|
+
this.internalError = true;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
</script>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
|
|
3
|
+
/// //////////////// MOMENTJS TIME SUPPORT
|
|
4
|
+
export default {
|
|
5
|
+
getLocalDateNowMillis: () => {
|
|
6
|
+
return moment();
|
|
7
|
+
},
|
|
8
|
+
getLocalDateNow: (format) => {
|
|
9
|
+
var f = 'YYYY-MM-DD';
|
|
10
|
+
if (format) {
|
|
11
|
+
f = format;
|
|
12
|
+
}
|
|
13
|
+
return moment().format(f);
|
|
14
|
+
},
|
|
15
|
+
formatDate: (date, format) => {
|
|
16
|
+
return moment(date).format(format);
|
|
17
|
+
},
|
|
18
|
+
getLocalTimeNow: (format) => {
|
|
19
|
+
var f = 'HH:mm:ss';
|
|
20
|
+
if (format) {
|
|
21
|
+
f = format;
|
|
22
|
+
}
|
|
23
|
+
return moment().format(f);
|
|
24
|
+
},
|
|
25
|
+
getLocalDate: (date) => {
|
|
26
|
+
if (date) {
|
|
27
|
+
return moment(date).format();
|
|
28
|
+
}
|
|
29
|
+
return date;
|
|
30
|
+
},
|
|
31
|
+
getLocalFormattedDateFromMillis: (millis, isoFormat) => {
|
|
32
|
+
return moment(millis).format(isoFormat);
|
|
33
|
+
},
|
|
34
|
+
getLocalFormattedDate: (date, isoFormat) => {
|
|
35
|
+
if (date) {
|
|
36
|
+
return moment(date).format(isoFormat);
|
|
37
|
+
}
|
|
38
|
+
return date;
|
|
39
|
+
},
|
|
40
|
+
isLocalDateValid: (date) => {
|
|
41
|
+
return moment(date).isValid();
|
|
42
|
+
},
|
|
43
|
+
isLocalDateBefore: (date, date2) => {
|
|
44
|
+
var d2 = moment(date2);
|
|
45
|
+
return moment(date).isBefore(d2);
|
|
46
|
+
},
|
|
47
|
+
isLocalDateSameOrBefore: (date, date2) => {
|
|
48
|
+
var d2 = moment(date2);
|
|
49
|
+
return moment(date).isSameOrBefore(d2);
|
|
50
|
+
},
|
|
51
|
+
isLocalDateAfter: (date, date2) => {
|
|
52
|
+
var d2 = moment(date2);
|
|
53
|
+
return moment(date).isAfter(d2);
|
|
54
|
+
},
|
|
55
|
+
isLocalDateSameOrAfter: (date, date2) => {
|
|
56
|
+
var d2 = moment(date2);
|
|
57
|
+
return moment(date).isSameOrAfter(d2);
|
|
58
|
+
},
|
|
59
|
+
isLocalDateEqual: (date, date2) => {
|
|
60
|
+
var d2 = moment(date2);
|
|
61
|
+
return moment(date).isSame(d2);
|
|
62
|
+
},
|
|
63
|
+
getUTCDate: (date) => {
|
|
64
|
+
return moment.utc(date).format();
|
|
65
|
+
},
|
|
66
|
+
getUTCOffset: () => {
|
|
67
|
+
return moment().utcOffset();
|
|
68
|
+
},
|
|
69
|
+
getUTCDateNow: () => {
|
|
70
|
+
return moment.utc().format();
|
|
71
|
+
},
|
|
72
|
+
addDaysToLocalDate(date, numberOfDays) {
|
|
73
|
+
return moment(date).add(numberOfDays, 'days').utc().format();
|
|
74
|
+
},
|
|
75
|
+
getMomentFromDate(date) {
|
|
76
|
+
return moment(date);
|
|
77
|
+
}
|
|
78
|
+
};
|