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,106 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<pui-modal-dialog
|
|
3
|
+
:titleText="titleText"
|
|
4
|
+
:messageText="messageText"
|
|
5
|
+
:okText="okText"
|
|
6
|
+
:cancelText="cancelText"
|
|
7
|
+
:widthDialog="widthDialog"
|
|
8
|
+
:dialogName="dialogName"
|
|
9
|
+
ref="modalForm"
|
|
10
|
+
>
|
|
11
|
+
<template slot="message">
|
|
12
|
+
<component :is="componentName" :pk="componentPk" :method="componentMethod" isModalDialog></component>
|
|
13
|
+
</template>
|
|
14
|
+
</pui-modal-dialog>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script>
|
|
18
|
+
export default {
|
|
19
|
+
name: 'PuiSelectDetailDialog',
|
|
20
|
+
props: {
|
|
21
|
+
parentId: {
|
|
22
|
+
type: String,
|
|
23
|
+
required: true
|
|
24
|
+
},
|
|
25
|
+
componentLabel: {
|
|
26
|
+
type: String,
|
|
27
|
+
required: true
|
|
28
|
+
},
|
|
29
|
+
componentName: {
|
|
30
|
+
type: String,
|
|
31
|
+
required: true
|
|
32
|
+
},
|
|
33
|
+
componentPk: {
|
|
34
|
+
type: String,
|
|
35
|
+
required: true
|
|
36
|
+
},
|
|
37
|
+
componentMethod: {
|
|
38
|
+
type: String,
|
|
39
|
+
required: true
|
|
40
|
+
},
|
|
41
|
+
modelName: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: null,
|
|
44
|
+
required: false
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
data() {
|
|
48
|
+
return {
|
|
49
|
+
titleText: this.componentLabel,
|
|
50
|
+
messageText: '',
|
|
51
|
+
okText: this.componentMethod !== 'read' ? this.$t('form.save') : this.$t('form.ok'),
|
|
52
|
+
cancelText: this.componentMethod !== 'read' ? this.$t('form.cancel') : null,
|
|
53
|
+
widthDialog: window.innerWidth * 0.9,
|
|
54
|
+
dialogName: this.componentName + '_' + this.parentId + '_popup'
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
mounted() {
|
|
58
|
+
var self = this;
|
|
59
|
+
this.$puiEvents.$on(`pui-modalDialog-${this.dialogName}-ok`, () => {
|
|
60
|
+
if (self.componentMethod === 'read') {
|
|
61
|
+
this.$puiEvents.$emit(`pui-modalDialog-${self.dialogName}-hide`);
|
|
62
|
+
} else {
|
|
63
|
+
const form = self.getFormComponent(self.$refs.modalForm.$children[0]);
|
|
64
|
+
if (form) {
|
|
65
|
+
form.$parent.save(true);
|
|
66
|
+
this.$puiEvents.$on(`onPui-insertRow-dataTable-${self.modelName}`, (data) => {
|
|
67
|
+
this.$puiEvents.$emit(`pui-modalDialog-${self.dialogName}-hide`, data);
|
|
68
|
+
});
|
|
69
|
+
this.$puiEvents.$on(`onPui-editRow-dataTable-${self.modelName}`, (data) => {
|
|
70
|
+
this.$puiEvents.$emit(`pui-modalDialog-${self.dialogName}-hide`, data);
|
|
71
|
+
});
|
|
72
|
+
} else {
|
|
73
|
+
this.$puiEvents.$emit(`pui-modalDialog-${self.dialogName}-hide`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
this.$puiEvents.$on(`pui-modalDialog-${this.dialogName}-cancel`, () => {
|
|
78
|
+
this.$puiEvents.$emit(`pui-modalDialog-${self.dialogName}-hide`);
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
destroyed() {
|
|
82
|
+
this.$puiEvents.$off(`pui-modalDialog-${this.dialogName}-ok`);
|
|
83
|
+
this.$puiEvents.$off(`pui-modalDialog-${this.dialogName}-cancel`);
|
|
84
|
+
if (this.modelName) {
|
|
85
|
+
this.$puiEvents.$off(`onPui-insertRow-dataTable-${this.modelName}`);
|
|
86
|
+
this.$puiEvents.$off(`onPui-editRow-dataTable-${this.modelName}`);
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
methods: {
|
|
90
|
+
getFormComponent(component) {
|
|
91
|
+
if (!component) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
if (component.validate && component.$options && component.$options._componentTag === 'v-form') {
|
|
95
|
+
return component;
|
|
96
|
+
}
|
|
97
|
+
for (let i = 0, childrenLength = component.$children.length; i < childrenLength; i++) {
|
|
98
|
+
const child = this.getFormComponent(component.$children[i]);
|
|
99
|
+
if (child && child.validate && child.$options && child.$options._componentTag === 'v-form') {
|
|
100
|
+
return child;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
</script>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-list-item-title v-if="type === 'item'" v-html="text" :title="text" :style="'white-space: unset !important;'"></v-list-item-title>
|
|
3
|
+
<span v-else class="pr-2" :class="compClass">{{ text }}</span>
|
|
4
|
+
</template>
|
|
5
|
+
|
|
6
|
+
<script>
|
|
7
|
+
export default {
|
|
8
|
+
name: 'PuiSelectTextService',
|
|
9
|
+
data: () => ({}),
|
|
10
|
+
props: {
|
|
11
|
+
item: {
|
|
12
|
+
type: [Object, String, Number],
|
|
13
|
+
required: true
|
|
14
|
+
},
|
|
15
|
+
type: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: 'item',
|
|
18
|
+
required: false
|
|
19
|
+
},
|
|
20
|
+
itemText: {
|
|
21
|
+
type: [Function, String, Array],
|
|
22
|
+
required: true
|
|
23
|
+
},
|
|
24
|
+
truncate: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: false,
|
|
27
|
+
required: false
|
|
28
|
+
},
|
|
29
|
+
writing: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: false,
|
|
32
|
+
required: false
|
|
33
|
+
},
|
|
34
|
+
disabled: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: false,
|
|
37
|
+
required: false
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
computed: {
|
|
41
|
+
text() {
|
|
42
|
+
let customText;
|
|
43
|
+
if (this.itemText instanceof Function) {
|
|
44
|
+
customText = this.itemText(this.item);
|
|
45
|
+
} else if (Array.isArray(this.itemText)) {
|
|
46
|
+
customText = this.itemText.slice(1).reduce((a, b) => {
|
|
47
|
+
return `${a} - ${b}`;
|
|
48
|
+
}, this.itemText[0]);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return customText || this.item[this.itemText];
|
|
52
|
+
},
|
|
53
|
+
compClass() {
|
|
54
|
+
return {
|
|
55
|
+
'puiselect-text-truncate': this.truncate && !this.writing && !this.disabled,
|
|
56
|
+
'puiselect-text': !this.writing
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
</script>
|
|
@@ -0,0 +1,484 @@
|
|
|
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;'"> </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
|
+
@keyup="validateNumber"
|
|
30
|
+
v-bind="allProps"
|
|
31
|
+
:class="getEditedClass"
|
|
32
|
+
:outline="!isMobile"
|
|
33
|
+
@blur="updateValueLazy"
|
|
34
|
+
:style="getCompStyle"
|
|
35
|
+
solo
|
|
36
|
+
outlined
|
|
37
|
+
flat
|
|
38
|
+
type="number"
|
|
39
|
+
:messages="internalMessages"
|
|
40
|
+
class="pui-spinner-inline"
|
|
41
|
+
:placeholder="getPlaceholder"
|
|
42
|
+
:error-messages="internalErrorMessages"
|
|
43
|
+
:error="internalError"
|
|
44
|
+
></v-text-field>
|
|
45
|
+
|
|
46
|
+
<v-btn
|
|
47
|
+
icon
|
|
48
|
+
class="primary--text pui-spinner-btnCtrl pui-spinner-btnCtrl_minus ml-0 pl-0 pr-0 mt-0"
|
|
49
|
+
:class="{ 'pui-spinner-btnCtrl_disabled': isBtnSubstractDisable }"
|
|
50
|
+
:ripple="!isBtnSubstractDisable"
|
|
51
|
+
@click="downValue"
|
|
52
|
+
>
|
|
53
|
+
<v-icon>fal fa-minus</v-icon>
|
|
54
|
+
</v-btn>
|
|
55
|
+
<v-btn
|
|
56
|
+
icon
|
|
57
|
+
class="primary--text pui-spinner-btnCtrl pui-spinner-btnCtrl_plus mr-0 pl-0 pr-0 mt-0"
|
|
58
|
+
:class="{ 'pui-spinner-btnCtrl_disabled': isBtnAddDisable }"
|
|
59
|
+
:ripple="!isBtnAddDisable"
|
|
60
|
+
@click="upValue"
|
|
61
|
+
>
|
|
62
|
+
<v-icon>fal fa-plus</v-icon>
|
|
63
|
+
</v-btn>
|
|
64
|
+
</v-flex>
|
|
65
|
+
</v-layout>
|
|
66
|
+
</div>
|
|
67
|
+
<div v-else class="ml-1 mr-1">
|
|
68
|
+
<v-layout>
|
|
69
|
+
<v-flex :class="labelColumnStyles ? labelColumnStyles : 'xs12 sm6 md4 xl3'">
|
|
70
|
+
<label :class="getLabelRequiredClass">{{ getLabel }}</label>
|
|
71
|
+
<v-tooltip top v-if="showTooltip">
|
|
72
|
+
<template v-slot:activator="{ on }">
|
|
73
|
+
<v-icon class="info-tooltip" size="14" v-on="on">fas fa-info-circle info-tooltip</v-icon>
|
|
74
|
+
</template>
|
|
75
|
+
<span>
|
|
76
|
+
<span v-if="this.description !== ''">
|
|
77
|
+
{{ this.description }}
|
|
78
|
+
<hr />
|
|
79
|
+
</span>
|
|
80
|
+
<ul>
|
|
81
|
+
<li v-for="(message, index) in this.infoTooltipMessages" :key="index">{{ message }}</li>
|
|
82
|
+
</ul>
|
|
83
|
+
</span>
|
|
84
|
+
</v-tooltip>
|
|
85
|
+
</v-flex>
|
|
86
|
+
<v-flex :class="valueColumnStyles ? valueColumnStyles : 'xs12 sm6 md8 xl9'">
|
|
87
|
+
<v-text-field
|
|
88
|
+
v-model="internalModel"
|
|
89
|
+
@keyup="validateNumber"
|
|
90
|
+
v-bind="allProps"
|
|
91
|
+
:class="getEditedClass"
|
|
92
|
+
:solo="!isMobile"
|
|
93
|
+
:outline="!isMobile"
|
|
94
|
+
@blur="updateValueLazy"
|
|
95
|
+
:style="getCompStyle"
|
|
96
|
+
flat
|
|
97
|
+
single-line
|
|
98
|
+
type="number"
|
|
99
|
+
:messages="internalMessages"
|
|
100
|
+
class="elevation-0 pui-spinner-inline"
|
|
101
|
+
:placeholder="getPlaceholder"
|
|
102
|
+
:error-messages="internalErrorMessages"
|
|
103
|
+
:error="internalError"
|
|
104
|
+
></v-text-field>
|
|
105
|
+
<v-btn
|
|
106
|
+
depressed
|
|
107
|
+
class="primary--text pui-spinner-inline white ml-0 pui-spinner-btnCtrl pui-spinner-btnCtrl_minus pl-0 pr-0 mt-0"
|
|
108
|
+
:class="{ 'pui-spinner-btnCtrl_disabled': isBtnSubstractDisable }"
|
|
109
|
+
:ripple="!isBtnSubstractDisable"
|
|
110
|
+
@click="downValue"
|
|
111
|
+
>
|
|
112
|
+
<v-icon>fal fa-minus</v-icon>
|
|
113
|
+
</v-btn>
|
|
114
|
+
<v-btn
|
|
115
|
+
depressed
|
|
116
|
+
class="primary--text pui-spinner-inline white mr-0 pui-spinner-btnCtrl pui-spinner-btnCtrl_plus pl-0 pr-0 ml-1 mt-0"
|
|
117
|
+
:class="{ 'pui-spinner-btnCtrl_disabled': isBtnAddDisable }"
|
|
118
|
+
:ripple="!isBtnAddDisable"
|
|
119
|
+
@click="upValue"
|
|
120
|
+
>
|
|
121
|
+
<v-icon>fal fa-plus</v-icon>
|
|
122
|
+
</v-btn>
|
|
123
|
+
</v-flex>
|
|
124
|
+
</v-layout>
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
<!-- MOBILE -->
|
|
128
|
+
<div v-else>
|
|
129
|
+
<v-flex xs12>
|
|
130
|
+
<label :class="getLabelRequiredClass">{{ getLabel }}</label>
|
|
131
|
+
</v-flex>
|
|
132
|
+
<v-flex xs12>
|
|
133
|
+
<v-text-field
|
|
134
|
+
v-model="internalModel"
|
|
135
|
+
@keyup="validateNumber"
|
|
136
|
+
v-bind="allProps"
|
|
137
|
+
:class="getEditedClass"
|
|
138
|
+
:solo="!isMobile"
|
|
139
|
+
:outline="!isMobile"
|
|
140
|
+
@blur="updateValueLazy"
|
|
141
|
+
flat
|
|
142
|
+
single-line
|
|
143
|
+
type="number"
|
|
144
|
+
:messages="internalMessages"
|
|
145
|
+
class="pui-spinner-hideBtns pui-spinner-inline v-text-field--mobile"
|
|
146
|
+
:placeholder="getPlaceholder"
|
|
147
|
+
:error-messages="internalErrorMessages"
|
|
148
|
+
:error="internalError"
|
|
149
|
+
></v-text-field>
|
|
150
|
+
<v-btn
|
|
151
|
+
depressed
|
|
152
|
+
class="primary--text pui-spinner-inline white ml-0 pui-spinner-btnCtrl pui-spinner-btnCtrl_minus pl-0 pr-0 mt-0"
|
|
153
|
+
:class="{ 'pui-spinner-btnCtrl_disabled': isBtnSubstractDisable }"
|
|
154
|
+
:ripple="!isBtnSubstractDisable"
|
|
155
|
+
@click="downValue"
|
|
156
|
+
>
|
|
157
|
+
<v-icon>fal fa-minus</v-icon>
|
|
158
|
+
</v-btn>
|
|
159
|
+
<v-btn
|
|
160
|
+
depressed
|
|
161
|
+
class="primary--text pui-spinner-inline white mr-0 pui-spinner-btnCtrl pui-spinner-btnCtrl_plus pl-0 pr-0 ml-1 mt-0"
|
|
162
|
+
:class="{ 'pui-spinner-btnCtrl_disabled': isBtnAddDisable }"
|
|
163
|
+
:ripple="!isBtnAddDisable"
|
|
164
|
+
@click="upValue"
|
|
165
|
+
>
|
|
166
|
+
<v-icon>fal fa-plus</v-icon>
|
|
167
|
+
</v-btn>
|
|
168
|
+
</v-flex>
|
|
169
|
+
</div>
|
|
170
|
+
</template>
|
|
171
|
+
|
|
172
|
+
<script>
|
|
173
|
+
import PuiUtilsNumberMixin from '../mixins/PuiUtilsNumberMixin';
|
|
174
|
+
import PuiFormComponentMixin from '../mixins/PuiFormComponentMixin';
|
|
175
|
+
|
|
176
|
+
export default {
|
|
177
|
+
name: 'PuiSpinnerField',
|
|
178
|
+
mixins: [PuiUtilsNumberMixin, PuiFormComponentMixin],
|
|
179
|
+
data: () => ({
|
|
180
|
+
initialValue: 0,
|
|
181
|
+
internalModel: 0,
|
|
182
|
+
minValue: Number.MIN_SAFE_INTEGER,
|
|
183
|
+
maxValue: Number.MAX_SAFE_INTEGER,
|
|
184
|
+
disableBtnAdd: false,
|
|
185
|
+
disableBtnSubstract: false,
|
|
186
|
+
internalMessages: [],
|
|
187
|
+
internalErrorMessages: [],
|
|
188
|
+
infoTooltipMessages: []
|
|
189
|
+
}),
|
|
190
|
+
props: {
|
|
191
|
+
value: {
|
|
192
|
+
type: [Number],
|
|
193
|
+
required: false
|
|
194
|
+
},
|
|
195
|
+
max: {
|
|
196
|
+
type: [String, Number],
|
|
197
|
+
default: () => {
|
|
198
|
+
return Number.MAX_SAFE_INTEGER;
|
|
199
|
+
},
|
|
200
|
+
required: false
|
|
201
|
+
},
|
|
202
|
+
min: {
|
|
203
|
+
type: [String, Number],
|
|
204
|
+
default: () => {
|
|
205
|
+
return Number.MIN_SAFE_INTEGER;
|
|
206
|
+
},
|
|
207
|
+
required: false
|
|
208
|
+
},
|
|
209
|
+
title: {
|
|
210
|
+
type: [String],
|
|
211
|
+
default: '',
|
|
212
|
+
required: false
|
|
213
|
+
},
|
|
214
|
+
tooltip: {
|
|
215
|
+
type: [Boolean],
|
|
216
|
+
default: false,
|
|
217
|
+
required: false
|
|
218
|
+
},
|
|
219
|
+
description: {
|
|
220
|
+
type: [String],
|
|
221
|
+
default: '',
|
|
222
|
+
required: false
|
|
223
|
+
},
|
|
224
|
+
noLazyModel: {
|
|
225
|
+
type: [Boolean],
|
|
226
|
+
default: false,
|
|
227
|
+
required: false
|
|
228
|
+
},
|
|
229
|
+
placeholder: {
|
|
230
|
+
type: [String],
|
|
231
|
+
default: ' ',
|
|
232
|
+
required: false
|
|
233
|
+
},
|
|
234
|
+
width: {
|
|
235
|
+
type: [String, Number],
|
|
236
|
+
default: '90',
|
|
237
|
+
required: false
|
|
238
|
+
},
|
|
239
|
+
labelColumnStyles: {
|
|
240
|
+
type: [String],
|
|
241
|
+
required: false
|
|
242
|
+
},
|
|
243
|
+
valueColumnStyles: {
|
|
244
|
+
type: [String],
|
|
245
|
+
required: false
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
methods: {
|
|
249
|
+
getInfoTooltip() {
|
|
250
|
+
if (this.max !== Number.MAX_SAFE_INTEGER) {
|
|
251
|
+
this.infoTooltipMessages.push(this.$t('pui9.components.spinnerField.overmaxvalue') + ': ' + this.max);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (this.min !== Number.MIN_SAFE_INTEGER) {
|
|
255
|
+
this.infoTooltipMessages.push(this.$t('pui9.components.spinnerField.overminvalue') + ': ' + this.min);
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
updateValueLazy() {
|
|
259
|
+
if (!this.internalError) {
|
|
260
|
+
this.$emit('input', this.internalModel);
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
validateNumber(evt) {
|
|
264
|
+
var valNum = evt.target.valueAsNumber;
|
|
265
|
+
var wrong = isNaN(valNum);
|
|
266
|
+
if (!wrong) {
|
|
267
|
+
this.clearErrorMessage();
|
|
268
|
+
this.checkNumber(valNum);
|
|
269
|
+
} else {
|
|
270
|
+
this.showWrongNumberMessage();
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
checkNumber(val) {
|
|
274
|
+
var isInt = this.checkInteger(val);
|
|
275
|
+
if (isInt) {
|
|
276
|
+
var intVal = parseInt(val);
|
|
277
|
+
const validated = this.validateMinMax(intVal);
|
|
278
|
+
if (validated) {
|
|
279
|
+
this.internalModel = intVal;
|
|
280
|
+
}
|
|
281
|
+
} else {
|
|
282
|
+
var int = parseInt(val);
|
|
283
|
+
if (!isNaN(int)) {
|
|
284
|
+
const validated = this.validateMinMax(int);
|
|
285
|
+
if (validated) {
|
|
286
|
+
this.internalModel = int;
|
|
287
|
+
}
|
|
288
|
+
} else {
|
|
289
|
+
this.showWrongNumberMessage();
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
validateMinMax(num) {
|
|
294
|
+
var ok = true;
|
|
295
|
+
if (num) {
|
|
296
|
+
if (num > this.maxValue) {
|
|
297
|
+
this.internalModel = this.maxValue;
|
|
298
|
+
this.showErrorMessageOverMaxvalue();
|
|
299
|
+
ok = false;
|
|
300
|
+
} else {
|
|
301
|
+
this.disableBtnAdd = false;
|
|
302
|
+
}
|
|
303
|
+
if (num < this.minValue) {
|
|
304
|
+
this.internalModel = this.minValue;
|
|
305
|
+
this.showErrorMessageOverMinvalue();
|
|
306
|
+
ok = false;
|
|
307
|
+
} else {
|
|
308
|
+
this.disableBtnSubstract = false;
|
|
309
|
+
}
|
|
310
|
+
} else {
|
|
311
|
+
this.resetBtns();
|
|
312
|
+
}
|
|
313
|
+
return ok;
|
|
314
|
+
},
|
|
315
|
+
upValue() {
|
|
316
|
+
if (!this.disableBtnAdd) {
|
|
317
|
+
this.internalModel++;
|
|
318
|
+
this.clearErrorMessage();
|
|
319
|
+
this.$emit('input', this.internalModel);
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
downValue() {
|
|
323
|
+
if (!this.disableBtnSubstract) {
|
|
324
|
+
this.internalModel--;
|
|
325
|
+
this.clearErrorMessage();
|
|
326
|
+
this.$emit('input', this.internalModel);
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
checkBtnAddDisable() {
|
|
330
|
+
if (this.disabled || this.internalModel >= this.max) {
|
|
331
|
+
this.disableBtnAdd = true;
|
|
332
|
+
return true;
|
|
333
|
+
}
|
|
334
|
+
this.disableBtnAdd = false;
|
|
335
|
+
return false;
|
|
336
|
+
},
|
|
337
|
+
checkBtnSubstarctDisable() {
|
|
338
|
+
if (this.disabled || this.internalModel <= this.min) {
|
|
339
|
+
this.disableBtnSubstract = true;
|
|
340
|
+
return true;
|
|
341
|
+
}
|
|
342
|
+
this.disableBtnSubstract = false;
|
|
343
|
+
return false;
|
|
344
|
+
},
|
|
345
|
+
showErrorMessageOverMaxvalue() {
|
|
346
|
+
var message = this.$t('pui9.components.spinnerField.overmaxvalue') + ' ' + this.maxValue;
|
|
347
|
+
this.internalMessages = [message];
|
|
348
|
+
},
|
|
349
|
+
showErrorMessageOverMinvalue() {
|
|
350
|
+
var message = this.$t('pui9.components.spinnerField.overminvalue') + ' ' + this.minValue;
|
|
351
|
+
this.internalMessages = [message];
|
|
352
|
+
},
|
|
353
|
+
showWrongNumberMessage() {
|
|
354
|
+
var message = this.$t('pui9.components.spinnerField.wrongnumber');
|
|
355
|
+
this.internalError = true;
|
|
356
|
+
this.internalErrorMessages = [message];
|
|
357
|
+
},
|
|
358
|
+
clearErrorMessage() {
|
|
359
|
+
this.internalMessages = [];
|
|
360
|
+
this.internalErrorMessages = [];
|
|
361
|
+
this.internalError = false;
|
|
362
|
+
},
|
|
363
|
+
resetBtns() {
|
|
364
|
+
this.disableBtnAdd = false;
|
|
365
|
+
this.disableBtnSubstract = false;
|
|
366
|
+
this.clearErrorMessage();
|
|
367
|
+
},
|
|
368
|
+
initializeModel(value) {
|
|
369
|
+
if (this.min !== null && this.min !== undefined) {
|
|
370
|
+
const minVal = parseInt(this.min);
|
|
371
|
+
if (!isNaN(minVal)) {
|
|
372
|
+
if (minVal < this.maxValue) {
|
|
373
|
+
this.minValue = minVal;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
if (this.max !== null && this.max !== undefined) {
|
|
378
|
+
const maxVal = parseInt(this.max);
|
|
379
|
+
if (!isNaN(maxVal)) {
|
|
380
|
+
if (maxVal > this.minValue) {
|
|
381
|
+
this.maxValue = maxVal;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
if (value === null) {
|
|
387
|
+
this.initialValue = 0;
|
|
388
|
+
this.internalModel = 0;
|
|
389
|
+
} else {
|
|
390
|
+
var noNullValue = value ? parseInt(value) : 0;
|
|
391
|
+
this.initialValue = noNullValue;
|
|
392
|
+
this.internalModel = noNullValue;
|
|
393
|
+
|
|
394
|
+
if (this.internalModel < this.minValue) {
|
|
395
|
+
this.internalModel = this.minValue;
|
|
396
|
+
this.initialValue = this.minValue;
|
|
397
|
+
}
|
|
398
|
+
this.firstLazyLoad = true;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
computed: {
|
|
403
|
+
getMobileClass() {
|
|
404
|
+
return { 'v-text-field--edited': this.isEdited, 'v-text-field--required': this.required };
|
|
405
|
+
},
|
|
406
|
+
getLabelRequiredClass() {
|
|
407
|
+
return { 'v-label--required': this.required };
|
|
408
|
+
},
|
|
409
|
+
getEditedClass() {
|
|
410
|
+
return { 'v-text-field--edited': this.isEdited };
|
|
411
|
+
},
|
|
412
|
+
getCompStyle() {
|
|
413
|
+
var inputWidth = this.width;
|
|
414
|
+
if (this.value && !isNaN(parseInt(this.value))) {
|
|
415
|
+
var numLength = this.value.toString().length;
|
|
416
|
+
var newle = numLength * 13;
|
|
417
|
+
const sufPref = this.allProps.suffix || this.allProps.prefix;
|
|
418
|
+
if (sufPref) newle += sufPref.length * 13;
|
|
419
|
+
if (newle > inputWidth) {
|
|
420
|
+
inputWidth = newle;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
return { width: inputWidth + 'px' };
|
|
424
|
+
},
|
|
425
|
+
isBtnAddDisable() {
|
|
426
|
+
return this.checkBtnAddDisable();
|
|
427
|
+
},
|
|
428
|
+
isBtnSubstractDisable() {
|
|
429
|
+
return this.checkBtnSubstarctDisable();
|
|
430
|
+
},
|
|
431
|
+
showTooltip() {
|
|
432
|
+
if (!this.tooltip || this.getLabel === '' || this.getLabel === null) {
|
|
433
|
+
return false;
|
|
434
|
+
}
|
|
435
|
+
return (this.infoTooltipMessages.length > 0 || this.description !== '') && this.tooltip;
|
|
436
|
+
}
|
|
437
|
+
},
|
|
438
|
+
created() {
|
|
439
|
+
if (this.noLazyModel) {
|
|
440
|
+
this.firstLazyLoad = true;
|
|
441
|
+
}
|
|
442
|
+
this.initializeModel(this.value);
|
|
443
|
+
|
|
444
|
+
this.getInfoTooltip();
|
|
445
|
+
},
|
|
446
|
+
watch: {
|
|
447
|
+
value(val) {
|
|
448
|
+
if (!this.noLazyModel && !this.firstLazyLoad) {
|
|
449
|
+
this.initializeModel(val);
|
|
450
|
+
this.firstLazyLoad = true;
|
|
451
|
+
} else {
|
|
452
|
+
this.internalModel = val;
|
|
453
|
+
}
|
|
454
|
+
},
|
|
455
|
+
min(newVal) {
|
|
456
|
+
if (newVal !== null && newVal !== undefined) {
|
|
457
|
+
const minVal = parseInt(newVal);
|
|
458
|
+
if (!isNaN(minVal)) {
|
|
459
|
+
if (minVal < this.maxValue) {
|
|
460
|
+
this.minValue = minVal;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
} else {
|
|
464
|
+
this.minValue = Number.MIN_SAFE_INTEGER;
|
|
465
|
+
}
|
|
466
|
+
},
|
|
467
|
+
max(newVal) {
|
|
468
|
+
if (newVal !== null && newVal !== undefined) {
|
|
469
|
+
const maxVal = parseInt(newVal);
|
|
470
|
+
if (!isNaN(maxVal)) {
|
|
471
|
+
if (maxVal > this.minValue) {
|
|
472
|
+
this.maxValue = maxVal;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
} else {
|
|
476
|
+
this.maxValue = Number.MAX_SAFE_INTEGER;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
},
|
|
480
|
+
destroyed() {
|
|
481
|
+
// No hay que eliminar el evento de onPuiTreeMenuItemSelected
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
</script>
|