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
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-card class="puiFileUpload pa-4" outlined>
|
|
3
|
+
<v-row v-if="descriptionEnabled">
|
|
4
|
+
<v-col cols="12" class="pb-0 mb-n4">
|
|
5
|
+
<pui-text-field
|
|
6
|
+
v-if="value"
|
|
7
|
+
:id="puiFileUploadId + '_description'"
|
|
8
|
+
:label="$t('form.puidocument.description')"
|
|
9
|
+
v-model="internalDescription"
|
|
10
|
+
maxlength="100"
|
|
11
|
+
toplabel
|
|
12
|
+
required
|
|
13
|
+
noeditable
|
|
14
|
+
:disabled="disabled || uploaded"
|
|
15
|
+
@input="update()"
|
|
16
|
+
></pui-text-field>
|
|
17
|
+
</v-col>
|
|
18
|
+
</v-row>
|
|
19
|
+
<v-row>
|
|
20
|
+
<v-col cols="12" class="py-0">
|
|
21
|
+
<!--<pui-text-field :label="$t('form.puidocument.filename')" v-model="fileUploadModel.filenameorig" toplabel required disabled></pui-text-field>-->
|
|
22
|
+
<input type="file" v-show="false" ref="document" @change="onFilePicked" />
|
|
23
|
+
</v-col>
|
|
24
|
+
<v-col cols="12">
|
|
25
|
+
<v-container
|
|
26
|
+
v-if = "!uploaded"
|
|
27
|
+
:id="puiFileUploadId + '_fileUploadContainer'"
|
|
28
|
+
class="drop align-center py-4"
|
|
29
|
+
@dragover.prevent
|
|
30
|
+
@dragenter="setStyle"
|
|
31
|
+
@dragleave="removeStyle"
|
|
32
|
+
@drop="onDrop"
|
|
33
|
+
>
|
|
34
|
+
<span v-if="!selectedFile" @dragenter="setStyle">
|
|
35
|
+
<span class="label-file ma-4" @dragenter="setStyle">{{ $t('form.puidocument.dropfilehere') }}</span>
|
|
36
|
+
</span>
|
|
37
|
+
<span v-if="selectedFile" @dragenter="setStyle">
|
|
38
|
+
<span class="label-file ma-4" @dragenter="setStyle">
|
|
39
|
+
<i :class="selectedFileType" style="font-size: 20px; color: black" @dragenter="setStyle"></i> {{
|
|
40
|
+
selectedFileName
|
|
41
|
+
}}
|
|
42
|
+
</span>
|
|
43
|
+
</span>
|
|
44
|
+
</v-container>
|
|
45
|
+
|
|
46
|
+
<v-container v-else
|
|
47
|
+
:id="puiFileUploadId + '_fileUploadContainer'"
|
|
48
|
+
class="drop align-center py-4"
|
|
49
|
+
@dragover.prevent
|
|
50
|
+
@drop.prevent
|
|
51
|
+
>
|
|
52
|
+
<span v-if="selectedFile">
|
|
53
|
+
<span class="label-file ma-4">
|
|
54
|
+
<i :class="selectedFileType" style="font-size: 20px; color: black"></i> {{
|
|
55
|
+
selectedFileName
|
|
56
|
+
}}
|
|
57
|
+
</span>
|
|
58
|
+
</span>
|
|
59
|
+
</v-container>
|
|
60
|
+
</v-col>
|
|
61
|
+
<v-col cols="12" class="pt-0 d-flex justify-end">
|
|
62
|
+
<slot name="customButton"></slot>
|
|
63
|
+
<v-btn v-if="!uploaded && !disabled" color="primary" @click="$refs.document.click()">
|
|
64
|
+
<span>{{ $t('form.puidocument.selectfile') }}</span>
|
|
65
|
+
</v-btn>
|
|
66
|
+
<v-btn v-if="uploaded" color="primary" @click="downloadEvent()">
|
|
67
|
+
<span>{{ $t('form.puidocument.downloadfile') }}</span>
|
|
68
|
+
</v-btn>
|
|
69
|
+
</v-col>
|
|
70
|
+
</v-row>
|
|
71
|
+
</v-card>
|
|
72
|
+
</template>
|
|
73
|
+
|
|
74
|
+
<script>
|
|
75
|
+
export default {
|
|
76
|
+
name: 'PuiFileUpload',
|
|
77
|
+
props: {
|
|
78
|
+
id: {
|
|
79
|
+
required: false
|
|
80
|
+
},
|
|
81
|
+
value: {
|
|
82
|
+
required: false
|
|
83
|
+
},
|
|
84
|
+
maxSize: {
|
|
85
|
+
required: false
|
|
86
|
+
},
|
|
87
|
+
descriptionEnabled: {
|
|
88
|
+
type: Boolean,
|
|
89
|
+
default: false,
|
|
90
|
+
required: false
|
|
91
|
+
},
|
|
92
|
+
disabled: {
|
|
93
|
+
type: Boolean,
|
|
94
|
+
default: false,
|
|
95
|
+
required: false
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
data() {
|
|
99
|
+
return {
|
|
100
|
+
puiFileUploadId: this.id,
|
|
101
|
+
internalDescription: null,
|
|
102
|
+
compressImage: {
|
|
103
|
+
maxResolution: null,
|
|
104
|
+
quality: null
|
|
105
|
+
},
|
|
106
|
+
fileTypes: {
|
|
107
|
+
'image/png': 'fas fa-file-image',
|
|
108
|
+
'image/jpeg': 'fas fa-file-image',
|
|
109
|
+
'application/pdf': 'fas fa-file-pdf',
|
|
110
|
+
'application/vnd.ms-excel': 'fas fa-file-excel',
|
|
111
|
+
'application/vnd.oasis.opendocument.spreadsheet': 'fas fa-file-excel',
|
|
112
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'fas fa-file-excel',
|
|
113
|
+
'application/msword': 'fas fa-file-word',
|
|
114
|
+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document': 'fas fa-file-word',
|
|
115
|
+
'application/vnd.oasis.opendocument.text': 'fas fa-file-word',
|
|
116
|
+
'application/vnd.ms-powerpoint': 'fas fa-file-powerpoint',
|
|
117
|
+
'application/vnd.openxmlformats-officedocument.presentationml.presentation': 'fas fa-file-powerpoint',
|
|
118
|
+
'application/vnd.oasis.opendocument.presentation': 'fas fa-file-powerpoint',
|
|
119
|
+
'text/xml': 'fas fa-file-alt',
|
|
120
|
+
'text/plain': 'fas fa-file-alt'
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
},
|
|
124
|
+
computed: {
|
|
125
|
+
selectedFile: {
|
|
126
|
+
get: function () {
|
|
127
|
+
return this.value && this.value.selectedFile;
|
|
128
|
+
},
|
|
129
|
+
set: function (newValue) {
|
|
130
|
+
this.value.selectedFile = newValue;
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
selectedFileName() {
|
|
134
|
+
if (this.value && this.value.selectedFile) {
|
|
135
|
+
return this.value.selectedFile.name;
|
|
136
|
+
}
|
|
137
|
+
return '';
|
|
138
|
+
},
|
|
139
|
+
selectedFileType() {
|
|
140
|
+
if (this.value && this.value.selectedFile && this.value.selectedFile.type) {
|
|
141
|
+
return this.fileTypes[this.value.selectedFile.type];
|
|
142
|
+
}
|
|
143
|
+
return '';
|
|
144
|
+
},
|
|
145
|
+
uploaded() {
|
|
146
|
+
return this.value.idDocument != null;
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
watch: {
|
|
150
|
+
value(v) {
|
|
151
|
+
if (v == null || v == undefined) {
|
|
152
|
+
this.$emit('input', this.getEmptyFileUploadModel());
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
'value.description'(v) {
|
|
156
|
+
this.internalDescription = v;
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
created() {
|
|
160
|
+
if (this.value == null || this.value == undefined) {
|
|
161
|
+
this.$emit('input', this.getEmptyFileUploadModel());
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
mounted() {
|
|
165
|
+
this.internalDescription = this.value.description;
|
|
166
|
+
},
|
|
167
|
+
methods: {
|
|
168
|
+
getEmptyFileUploadModel() {
|
|
169
|
+
return {
|
|
170
|
+
description: null,
|
|
171
|
+
selectedFile: null,
|
|
172
|
+
idDocument: null
|
|
173
|
+
};
|
|
174
|
+
},
|
|
175
|
+
/*send(formData) {
|
|
176
|
+
const fileData = new window.FormData();
|
|
177
|
+
fileData.append('files', this.selectedFile, this.selectedFile.name);
|
|
178
|
+
|
|
179
|
+
this.$puiRequests.uploadFileRequest(
|
|
180
|
+
'/issueTicket',
|
|
181
|
+
fileData,
|
|
182
|
+
(response) => {
|
|
183
|
+
alert(response);
|
|
184
|
+
this.dialog = false;
|
|
185
|
+
},
|
|
186
|
+
(error) => {
|
|
187
|
+
alert(error);
|
|
188
|
+
this.dialog = false;
|
|
189
|
+
},
|
|
190
|
+
formData // as parameters
|
|
191
|
+
);
|
|
192
|
+
},*/
|
|
193
|
+
setStyle() {
|
|
194
|
+
document.getElementById(this.puiFileUploadId + '_fileUploadContainer').className = 'container drop align-center py-4 highlight';
|
|
195
|
+
},
|
|
196
|
+
removeStyle(e) {
|
|
197
|
+
if (e.target.id == this.puiFileUploadId + '_fileUploadContainer') {
|
|
198
|
+
document.getElementById(this.puiFileUploadId + '_fileUploadContainer').className = 'container drop align-center py-4';
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
onFilePicked(e) {
|
|
202
|
+
const files = e.target.files;
|
|
203
|
+
if (files[0] !== undefined) {
|
|
204
|
+
this.onFileDropped(files[0]);
|
|
205
|
+
} else {
|
|
206
|
+
this.selectedFile = null;
|
|
207
|
+
this.$emit('input', this.getEmptyFileUploadModel());
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
onDrop(e) {
|
|
211
|
+
e.stopPropagation();
|
|
212
|
+
e.preventDefault();
|
|
213
|
+
this.removeStyle(e);
|
|
214
|
+
const files = e.dataTransfer.files;
|
|
215
|
+
this.onFileDropped(files[0]);
|
|
216
|
+
},
|
|
217
|
+
onFileDropped(file) {
|
|
218
|
+
if (this.disabled) {
|
|
219
|
+
return
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (this.descriptionEnabled && (this.value.description == null || this.value.description == '' || this.value.description == undefined)) {
|
|
223
|
+
this.$puiNotify.error(this.$t('form.puidocument.descriptionNeeded'));
|
|
224
|
+
return
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const self = this;
|
|
228
|
+
const fr = new window.FileReader();
|
|
229
|
+
|
|
230
|
+
fr.addEventListener('load', (event) => {
|
|
231
|
+
if (fr.result === 'data:') {
|
|
232
|
+
// empty file selected
|
|
233
|
+
self.selectedFile = null;
|
|
234
|
+
} else if (file.size > self.maxSize * 1024) {
|
|
235
|
+
self.selectedFile = null;
|
|
236
|
+
this.$puiNotify.error(this.$t('form.puidocument.maxSizeExceeded', { maxsize: self.maxSize }));
|
|
237
|
+
} else if (file.type === 'image/png' || file.type === 'image/jpeg') {
|
|
238
|
+
const afterCompressImageFile = function (newFile) {
|
|
239
|
+
// newFile is the compress image that will be sent to the server...
|
|
240
|
+
self.selectedFile = newFile;
|
|
241
|
+
};
|
|
242
|
+
this.$puiUtils.compressImageFile(
|
|
243
|
+
file,
|
|
244
|
+
event,
|
|
245
|
+
self.compressImage.maxResolution,
|
|
246
|
+
self.compressImage.quality,
|
|
247
|
+
afterCompressImageFile
|
|
248
|
+
);
|
|
249
|
+
} else {
|
|
250
|
+
// file is the file that will be sent to the server...
|
|
251
|
+
self.selectedFile = file;
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
fr.readAsDataURL(file);
|
|
256
|
+
|
|
257
|
+
fr.onloadend = () => {
|
|
258
|
+
//console.log('DONE', fr.readyState); // readyState will be 2
|
|
259
|
+
this.$puiEvents.$emit(`onPuiFileUpload_selectedFile`, { id: this.puiFileUploadId });
|
|
260
|
+
};
|
|
261
|
+
},
|
|
262
|
+
customEvent() {
|
|
263
|
+
this.$puiEvents.$emit(`onPuiFileUpload_customEvent`, { id: this.puiFileUploadId });
|
|
264
|
+
},
|
|
265
|
+
downloadEvent() {
|
|
266
|
+
this.$puiEvents.$emit(`onPuiFileUpload_downloadFile`, { id: this.puiFileUploadId });
|
|
267
|
+
},
|
|
268
|
+
update() {
|
|
269
|
+
let updatedModel = {...this.value};
|
|
270
|
+
updatedModel.description = this.internalDescription;
|
|
271
|
+
this.$emit('input', updatedModel);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
</script>
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-container>
|
|
3
|
+
<v-row>
|
|
4
|
+
<v-col :cols="12" class="d-flex justify-end py-0" v-if="!disabled">
|
|
5
|
+
<v-btn v-if="this.slotsAvailableToRemove" text outlined small @click="removeFileUpload()">
|
|
6
|
+
<v-icon small>fas fa-minus-circle</v-icon>
|
|
7
|
+
</v-btn>
|
|
8
|
+
<v-btn v-if="this.slotsAvailable" text outlined small @click="addFileUpload">
|
|
9
|
+
<v-icon small>fas fa-plus-circle</v-icon>
|
|
10
|
+
</v-btn>
|
|
11
|
+
</v-col>
|
|
12
|
+
</v-row>
|
|
13
|
+
<v-row ref="fileUploads">
|
|
14
|
+
<v-col :cols="fileUploadCounter > 1 ? 6 : 12" v-for="index in fileUploadCounter" :key="getFileUploadId(index)">
|
|
15
|
+
<v-container v-if="customTab" class="pa-0">
|
|
16
|
+
<v-tabs v-model="tabActive[index]" slider-color="white" class="mt-n3" ref="tabs">
|
|
17
|
+
<v-tab :href="`#tab${index}_1`" :ref="`tab${index}_1`">{{ $t('form.puidocument.fileupload') }}</v-tab>
|
|
18
|
+
<v-tab :href="`#tab${index}_2`" :ref="`tab${index}_2`">{{ customTab }}</v-tab>
|
|
19
|
+
|
|
20
|
+
<v-tab-item :value="`tab${index}_1`" class="mt-2">
|
|
21
|
+
<pui-file-upload
|
|
22
|
+
:id="getFileUploadId(index)"
|
|
23
|
+
:ref="getFileUploadId(index)"
|
|
24
|
+
v-model="model.files[index - 1]"
|
|
25
|
+
:maxSize="maxSize"
|
|
26
|
+
:descriptionEnabled="descriptionEnabled"
|
|
27
|
+
@input="emitInputUpdate(model.files)"
|
|
28
|
+
:disabled="disabled"
|
|
29
|
+
:key="getFileUploadId(index)"
|
|
30
|
+
>
|
|
31
|
+
<template v-slot:customButton v-if="customButton">
|
|
32
|
+
<v-btn
|
|
33
|
+
class="mr-2"
|
|
34
|
+
color="primary"
|
|
35
|
+
@click="$puiEvents.$emit(`onPuiFileUpload_customEvent`, { id: getFileUploadId(index) })"
|
|
36
|
+
>
|
|
37
|
+
{{ customButton }}
|
|
38
|
+
</v-btn>
|
|
39
|
+
</template>
|
|
40
|
+
</pui-file-upload>
|
|
41
|
+
</v-tab-item>
|
|
42
|
+
<v-tab-item :value="`tab${index}_2`" class="mt-2">
|
|
43
|
+
<slot name="customTab"></slot>
|
|
44
|
+
</v-tab-item>
|
|
45
|
+
</v-tabs>
|
|
46
|
+
</v-container>
|
|
47
|
+
<v-container v-else class="pa-0">
|
|
48
|
+
<pui-file-upload
|
|
49
|
+
:id="getFileUploadId(index)"
|
|
50
|
+
:ref="getFileUploadId(index)"
|
|
51
|
+
v-model="model.files[index - 1]"
|
|
52
|
+
:maxSize="maxSize"
|
|
53
|
+
:descriptionEnabled="descriptionEnabled"
|
|
54
|
+
@input="emitInputUpdate(model.files)"
|
|
55
|
+
:disabled="disabled"
|
|
56
|
+
:key="getFileUploadId(index)"
|
|
57
|
+
>
|
|
58
|
+
<template v-slot:customButton v-if="customButton">
|
|
59
|
+
<v-btn
|
|
60
|
+
class="mr-2"
|
|
61
|
+
color="primary"
|
|
62
|
+
@click="$puiEvents.$emit(`onPuiFileUpload_customEvent`, { id: getFileUploadId(index) })"
|
|
63
|
+
>
|
|
64
|
+
{{ customButton }}
|
|
65
|
+
</v-btn>
|
|
66
|
+
</template>
|
|
67
|
+
</pui-file-upload>
|
|
68
|
+
</v-container>
|
|
69
|
+
</v-col>
|
|
70
|
+
</v-row>
|
|
71
|
+
</v-container>
|
|
72
|
+
</template>
|
|
73
|
+
|
|
74
|
+
<script>
|
|
75
|
+
import PuiFileUpload from './PuiFileUpload.vue';
|
|
76
|
+
|
|
77
|
+
export default {
|
|
78
|
+
name: 'PuiFileUploadGroup',
|
|
79
|
+
components: { PuiFileUpload },
|
|
80
|
+
props: {
|
|
81
|
+
value: {
|
|
82
|
+
required: false
|
|
83
|
+
},
|
|
84
|
+
minDocuments: {
|
|
85
|
+
type: Number,
|
|
86
|
+
default: 1,
|
|
87
|
+
required: false
|
|
88
|
+
},
|
|
89
|
+
maxDocuments: {
|
|
90
|
+
type: Number,
|
|
91
|
+
default: 0,
|
|
92
|
+
required: false
|
|
93
|
+
},
|
|
94
|
+
maxSize: {
|
|
95
|
+
type: Number,
|
|
96
|
+
required: false
|
|
97
|
+
},
|
|
98
|
+
descriptionEnabled: {
|
|
99
|
+
type: Boolean,
|
|
100
|
+
default: false,
|
|
101
|
+
required: false
|
|
102
|
+
},
|
|
103
|
+
customTab: {
|
|
104
|
+
type: String,
|
|
105
|
+
default: null,
|
|
106
|
+
required: false
|
|
107
|
+
},
|
|
108
|
+
customButton: {
|
|
109
|
+
type: String,
|
|
110
|
+
default: null,
|
|
111
|
+
required: false
|
|
112
|
+
},
|
|
113
|
+
disabled: {
|
|
114
|
+
type: Boolean,
|
|
115
|
+
default: false,
|
|
116
|
+
required: false
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
data() {
|
|
120
|
+
return {
|
|
121
|
+
puiFileUploadGroupId: this.$attrs.id,
|
|
122
|
+
tabActive: [],
|
|
123
|
+
model: null,
|
|
124
|
+
fileUploadCounter: 0
|
|
125
|
+
};
|
|
126
|
+
},
|
|
127
|
+
computed: {
|
|
128
|
+
emptySlots() {
|
|
129
|
+
return this.model.files.filter((file) => {
|
|
130
|
+
return file.description == null && file.idDocument == null && file.selectedFile == null;
|
|
131
|
+
}).length;
|
|
132
|
+
},
|
|
133
|
+
filledSlots() {
|
|
134
|
+
return this.model.files.filter((file) => {
|
|
135
|
+
return file.description != null && file.idDocument != null && file.selectedFile != null;
|
|
136
|
+
}).length;
|
|
137
|
+
},
|
|
138
|
+
slotsAvailable() {
|
|
139
|
+
return this.maxDocuments == 0 || this.model.files.length < this.maxDocuments;
|
|
140
|
+
},
|
|
141
|
+
slotsAvailableToRemove() {
|
|
142
|
+
return this.emptySlots > 0 && this.filledSlots + this.emptySlots > this.minDocuments;
|
|
143
|
+
},
|
|
144
|
+
slotsEmptyToReplace() {
|
|
145
|
+
for (let file of this.model.files) {
|
|
146
|
+
if (this.isEmptyModel(file)) {
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
watch: {
|
|
154
|
+
value(v) {
|
|
155
|
+
this.fileUploadCounter = v.length;
|
|
156
|
+
this.model.files = v;
|
|
157
|
+
},
|
|
158
|
+
'model.files': {
|
|
159
|
+
handler() {
|
|
160
|
+
this.$emit('input',this.model.files);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
created() {
|
|
165
|
+
this.setInitialValues();
|
|
166
|
+
},
|
|
167
|
+
methods: {
|
|
168
|
+
setInitialValues() {
|
|
169
|
+
this.model = this.getEmptyModel();
|
|
170
|
+
this.fileUploadCounter = 0;
|
|
171
|
+
for (let initial = 0; initial < this.minDocuments; initial++) {
|
|
172
|
+
if (this.slotsAvailable) {
|
|
173
|
+
this.addFileUpload();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
getEmptyModel() {
|
|
178
|
+
return {
|
|
179
|
+
files: []
|
|
180
|
+
};
|
|
181
|
+
},
|
|
182
|
+
validateFileUploads() {
|
|
183
|
+
let validation = true;
|
|
184
|
+
const self = this;
|
|
185
|
+
this.model.files.forEach((file) => {
|
|
186
|
+
if (file.selectedFile == null) {
|
|
187
|
+
self.$puiNotify.error(self.$t('puicau.fileValidation'));
|
|
188
|
+
validation = false;
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
return validation;
|
|
193
|
+
},
|
|
194
|
+
// provoca redibujado en el v-for de puiFileUploadGroup por el cambio de key y pérdida de foco en el input
|
|
195
|
+
getUniqueIndex() {
|
|
196
|
+
let numberSTR = Math.random().toString().replace('.', Math.random().toString().replace('.', '').substring(0, 10)).substring(0, 20);
|
|
197
|
+
let numberInt = parseInt(numberSTR).toFixed();
|
|
198
|
+
let integer = parseInt(numberInt);
|
|
199
|
+
return integer;
|
|
200
|
+
},
|
|
201
|
+
getFileUploadId(index) {
|
|
202
|
+
return `${this.puiFileUploadGroupId}_fileUpload_${index}`;
|
|
203
|
+
},
|
|
204
|
+
addFileUpload(value) {
|
|
205
|
+
if (this.slotsEmptyToReplace && !this.isEmptyModel(value)) {
|
|
206
|
+
this.replaceFileUpload(value);
|
|
207
|
+
} else if (this.slotsAvailable) {
|
|
208
|
+
if (!this.isEmptyModel(value)) {
|
|
209
|
+
this.fileUploadCounter++;
|
|
210
|
+
this.model.files.push(value);
|
|
211
|
+
} else {
|
|
212
|
+
this.fileUploadCounter++;
|
|
213
|
+
this.model.files.push(PuiFileUpload.methods.getEmptyFileUploadModel());
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
isEmptyModel(value) {
|
|
218
|
+
return value == null || (value.description == null && value.idDocument == null && value.selectedFile == null);
|
|
219
|
+
},
|
|
220
|
+
replaceFileUpload(value) {
|
|
221
|
+
for (let file of this.model.files) {
|
|
222
|
+
if (file.description == null && file.idDocument == null && file.selectedFile == null) {
|
|
223
|
+
Object.assign(file, value);
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
removeFileUpload() {
|
|
229
|
+
this.fileUploadCounter--;
|
|
230
|
+
this.model.files.pop();
|
|
231
|
+
},
|
|
232
|
+
reset() {
|
|
233
|
+
this.fileUploadCounter = 0;
|
|
234
|
+
this.model.files = [];
|
|
235
|
+
},
|
|
236
|
+
emitInputUpdate(value) {
|
|
237
|
+
this.$emit('input', value);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
</script>
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
<v-container class="puiFilterGroup pa-0">
|
|
3
|
+
<pui-filter-group
|
|
4
|
+
v-if="columns.length > 0"
|
|
5
|
+
ref="group0"
|
|
6
|
+
:columnsProp="columns"
|
|
7
|
+
:filterColumnValues="filterColumnValues"
|
|
8
|
+
:filterGroupProp="filterModel"
|
|
9
|
+
:disabled="disabled"
|
|
10
|
+
:showSubgroupBtn="showSubgroupBtn"
|
|
11
|
+
isRootGroup
|
|
12
|
+
@change="onFilterGroupChanges"
|
|
13
|
+
></pui-filter-group>
|
|
14
|
+
</v-container>
|
|
13
15
|
</template>
|
|
14
16
|
|
|
15
17
|
<script>
|
|
16
|
-
import PuiFilterGroup from './PuiFilterGroup';
|
|
18
|
+
import PuiFilterGroup from './PuiFilterGroup.vue';
|
|
17
19
|
|
|
18
20
|
export default {
|
|
19
21
|
name: 'PuiFilter',
|
|
@@ -22,80 +24,80 @@ export default {
|
|
|
22
24
|
},
|
|
23
25
|
data() {
|
|
24
26
|
return {
|
|
27
|
+
filterModel: null,
|
|
25
28
|
showSubgroupBtn: true
|
|
26
29
|
};
|
|
27
30
|
},
|
|
28
31
|
props: {
|
|
29
|
-
|
|
30
|
-
type: Object,
|
|
32
|
+
filterProp: {
|
|
33
|
+
//type: Object,
|
|
31
34
|
required: true
|
|
32
35
|
},
|
|
33
36
|
columns: {
|
|
34
37
|
type: Array,
|
|
35
38
|
required: true
|
|
36
39
|
},
|
|
40
|
+
filterColumnValues: {
|
|
41
|
+
type: Object,
|
|
42
|
+
required: false
|
|
43
|
+
},
|
|
37
44
|
disabled: {
|
|
38
45
|
type: Boolean,
|
|
39
46
|
required: true
|
|
40
47
|
}
|
|
41
48
|
},
|
|
49
|
+
watch: {
|
|
50
|
+
filterProp() {
|
|
51
|
+
this.filterModel = this.filterProp;
|
|
52
|
+
},
|
|
53
|
+
filterModel: {
|
|
54
|
+
deep: true,
|
|
55
|
+
handler() {
|
|
56
|
+
this.$emit('change', this.filterModel);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
created() {
|
|
61
|
+
this.filterModel = this.filterProp;
|
|
62
|
+
},
|
|
42
63
|
methods: {
|
|
43
64
|
retrieveGroupsData() {
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
return name.startsWith('rule');
|
|
47
|
-
};
|
|
65
|
+
// validation - al menos una regla por filtro
|
|
66
|
+
|
|
48
67
|
let validFilter = true;
|
|
49
68
|
let almenosUnaRegla = false;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (isRule(ruleOrGroup) === true) {
|
|
69
|
+
const validate = (filterGroupModel) => {
|
|
70
|
+
if (filterGroupModel) {
|
|
71
|
+
for (const index in filterGroupModel.rules) {
|
|
54
72
|
almenosUnaRegla = true;
|
|
55
|
-
|
|
56
|
-
const rule = {
|
|
57
|
-
field: ruleComponent.field,
|
|
58
|
-
op: ruleComponent.op,
|
|
59
|
-
data: ruleComponent.data
|
|
60
|
-
};
|
|
73
|
+
let rule = filterGroupModel.rules[index];
|
|
61
74
|
if (!rule.field || !rule.op || (!rule.data && rule.op !== 'nn' && rule.op !== 'nu')) {
|
|
62
|
-
|
|
75
|
+
this.$puiNotify.warning(this.$t('puidatatables.not-valid-rule-error'));
|
|
63
76
|
validFilter = false;
|
|
64
77
|
return;
|
|
65
78
|
}
|
|
66
|
-
if (rule.op === 'in' || rule.op === 'ni') {
|
|
79
|
+
if (typeof rule.data !== 'object' && (rule.op === 'in' || rule.op === 'ni')) {
|
|
67
80
|
rule.data = rule.data.split(',');
|
|
68
81
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const subgroupComponent = groupComponent.$refs[ruleOrGroup][0];
|
|
73
|
-
if (subgroupComponent instanceof Object) {
|
|
74
|
-
const group = {
|
|
75
|
-
groupOp: subgroupComponent.groupOp,
|
|
76
|
-
rules: [],
|
|
77
|
-
groups: []
|
|
78
|
-
};
|
|
79
|
-
groupFilterObject.groups.push(group);
|
|
80
|
-
processGroup(subgroupComponent, group);
|
|
81
|
-
}
|
|
82
|
+
}
|
|
83
|
+
for (const index in filterGroupModel.groups) {
|
|
84
|
+
validate(filterGroupModel.groups[index]);
|
|
82
85
|
}
|
|
83
86
|
}
|
|
84
87
|
};
|
|
88
|
+
this.filterModel && validate(this.filterModel);
|
|
85
89
|
|
|
86
|
-
const internalFilter = {
|
|
87
|
-
rules: [],
|
|
88
|
-
groups: [],
|
|
89
|
-
groupOp: this.$refs.group0.groupOp
|
|
90
|
-
};
|
|
91
|
-
//empezamos por el grupo 0
|
|
92
|
-
processGroup(this.$refs.group0, internalFilter);
|
|
93
90
|
if (almenosUnaRegla === false) {
|
|
94
|
-
|
|
91
|
+
this.$puiNotify.warning(this.$t('puidatatables.no-rules-error'));
|
|
92
|
+
return null;
|
|
95
93
|
} else if (validFilter === true) {
|
|
96
|
-
return
|
|
94
|
+
return this.filterModel;
|
|
97
95
|
}
|
|
96
|
+
|
|
98
97
|
return null;
|
|
98
|
+
},
|
|
99
|
+
onFilterGroupChanges() {
|
|
100
|
+
this.filterModel = this.$refs.group0.filterGroupModel;
|
|
99
101
|
}
|
|
100
102
|
}
|
|
101
103
|
};
|