pui9-components 2.0.7 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/pui9-components.common.js +5403 -22189
  2. package/dist/pui9-components.css +3 -6
  3. package/package-lock.json +635 -774
  4. package/package.json +1 -5
  5. package/src/App.vue +0 -117
  6. package/src/components/PuiAutocomplete.vue +0 -196
  7. package/src/components/PuiCauDialog.vue +0 -192
  8. package/src/components/PuiCheckbox.vue +0 -126
  9. package/src/components/PuiCodeEditor.vue +0 -124
  10. package/src/components/PuiDateField.vue +0 -1043
  11. package/src/components/PuiField.vue +0 -30
  12. package/src/components/PuiFieldSet.vue +0 -27
  13. package/src/components/PuiFileUpload.vue +0 -275
  14. package/src/components/PuiFileUploadGroup.vue +0 -241
  15. package/src/components/PuiFilter.vue +0 -104
  16. package/src/components/PuiFilterGroup.vue +0 -291
  17. package/src/components/PuiFilterRule.vue +0 -683
  18. package/src/components/PuiFormFooter.vue +0 -48
  19. package/src/components/PuiFormFooterBtns.vue +0 -118
  20. package/src/components/PuiFormHeader.vue +0 -25
  21. package/src/components/PuiFormLoading.vue +0 -14
  22. package/src/components/PuiFormMiniAudit.vue +0 -53
  23. package/src/components/PuiFormTooltip.vue +0 -50
  24. package/src/components/PuiMasterDetail.vue +0 -103
  25. package/src/components/PuiModalDialog.vue +0 -91
  26. package/src/components/PuiModalDialogForm.vue +0 -209
  27. package/src/components/PuiMultiSelect.vue +0 -636
  28. package/src/components/PuiNumberField.vue +0 -434
  29. package/src/components/PuiPasswordField.vue +0 -105
  30. package/src/components/PuiRadioGroup.vue +0 -105
  31. package/src/components/PuiRichTextEditor.vue +0 -116
  32. package/src/components/PuiSelect.vue +0 -1675
  33. package/src/components/PuiSelectDetailDialog.vue +0 -113
  34. package/src/components/PuiSelectTextService.vue +0 -61
  35. package/src/components/PuiSelectorList.vue +0 -169
  36. package/src/components/PuiSort.vue +0 -98
  37. package/src/components/PuiSpinnerField.vue +0 -464
  38. package/src/components/PuiSwitch.vue +0 -104
  39. package/src/components/PuiTextArea.vue +0 -204
  40. package/src/components/PuiTextField.vue +0 -389
  41. package/src/dateTimeUtils.js +0 -78
  42. package/src/index.js +0 -89
  43. package/src/main.js +0 -34
  44. package/src/mixins/PuiFormComponentMixin.js +0 -77
  45. package/src/mixins/PuiSortMixin.js +0 -136
  46. package/src/mixins/PuiUtilsNumberMixin.js +0 -29
  47. package/src/plugins/vuetify.js +0 -33
  48. package/src/tests/TestAutocomplete.vue +0 -138
  49. package/src/tests/TestCodeEditor.vue +0 -48
  50. package/src/tests/TestField.vue +0 -22
  51. package/src/tests/TestFieldSet.vue +0 -30
  52. package/src/tests/TestInputCheckbox.vue +0 -53
  53. package/src/tests/TestInputDate.vue +0 -146
  54. package/src/tests/TestInputNumber.vue +0 -77
  55. package/src/tests/TestInputRadioGroup.vue +0 -86
  56. package/src/tests/TestInputSpinner.vue +0 -77
  57. package/src/tests/TestInputSwitch.vue +0 -52
  58. package/src/tests/TestInputText.vue +0 -120
  59. package/src/tests/TestInputTextArea.vue +0 -73
  60. package/src/tests/TestMultiSelect.vue +0 -127
  61. package/src/tests/TestPuiForm.vue +0 -68
  62. package/src/tests/TestRichTextEditor.vue +0 -54
  63. package/src/tests/unit/PuiCheckbox.spec.js +0 -86
  64. package/src/tests/unit/PuiTextArea.spec.js +0 -62
  65. package/src/tests/unit/PuiTextField.spec.js +0 -119
  66. package/src/tests/unit/index.js +0 -5
  67. package/src/utils.js +0 -158
@@ -1,30 +0,0 @@
1
- <template>
2
- <div>
3
- <v-layout>
4
- <v-flex xs12>
5
- <span style="font-weight: 600">{{ label }}</span>
6
- </v-flex>
7
- </v-layout>
8
- <v-layout>
9
- <v-flex xs12>{{ value }}</v-flex>
10
- </v-layout>
11
- </div>
12
- </template>
13
-
14
- <script>
15
- export default {
16
- name: 'PuiField',
17
- props: {
18
- label: {
19
- type: String,
20
- required: true,
21
- default: ''
22
- },
23
- value: {
24
- type: [String, Number],
25
- required: true,
26
- default: ''
27
- }
28
- }
29
- };
30
- </script>
@@ -1,27 +0,0 @@
1
- <template>
2
- <fieldset class="pt-1 pb-1 pl-2 pr-2 ml-1 mr-1 mb-1" :class="getStyleComp">
3
- <legend>{{ title }}</legend>
4
- <slot></slot>
5
- </fieldset>
6
- </template>
7
-
8
- <script>
9
- export default {
10
- name: 'PuiFieldSet',
11
- props: {
12
- title: {
13
- type: String,
14
- default: ''
15
- },
16
- highlighted: {
17
- type: Boolean,
18
- default: false
19
- }
20
- },
21
- computed: {
22
- getStyleComp() {
23
- return { highlighted: this.highlighted };
24
- }
25
- }
26
- };
27
- </script>
@@ -1,275 +0,0 @@
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>&nbsp;&nbsp;{{
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>&nbsp;&nbsp;{{
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>
@@ -1,241 +0,0 @@
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,104 +0,0 @@
1
- <template>
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>
15
- </template>
16
-
17
- <script>
18
- import PuiFilterGroup from './PuiFilterGroup.vue';
19
-
20
- export default {
21
- name: 'PuiFilter',
22
- components: {
23
- PuiFilterGroup
24
- },
25
- data() {
26
- return {
27
- filterModel: null,
28
- showSubgroupBtn: true
29
- };
30
- },
31
- props: {
32
- filterProp: {
33
- //type: Object,
34
- required: true
35
- },
36
- columns: {
37
- type: Array,
38
- required: true
39
- },
40
- filterColumnValues: {
41
- type: Object,
42
- required: false
43
- },
44
- disabled: {
45
- type: Boolean,
46
- required: true
47
- }
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
- },
63
- methods: {
64
- retrieveGroupsData() {
65
- // validation - al menos una regla por filtro
66
-
67
- let validFilter = true;
68
- let almenosUnaRegla = false;
69
- const validate = (filterGroupModel) => {
70
- if (filterGroupModel) {
71
- for (const index in filterGroupModel.rules) {
72
- almenosUnaRegla = true;
73
- let rule = filterGroupModel.rules[index];
74
- if (!rule.field || !rule.op || (!rule.data && rule.op !== 'nn' && rule.op !== 'nu')) {
75
- this.$puiNotify.warning(this.$t('puidatatables.not-valid-rule-error'));
76
- validFilter = false;
77
- return;
78
- }
79
- if (typeof rule.data !== 'object' && (rule.op === 'in' || rule.op === 'ni')) {
80
- rule.data = rule.data.split(',');
81
- }
82
- }
83
- for (const index in filterGroupModel.groups) {
84
- validate(filterGroupModel.groups[index]);
85
- }
86
- }
87
- };
88
- this.filterModel && validate(this.filterModel);
89
-
90
- if (almenosUnaRegla === false) {
91
- this.$puiNotify.warning(this.$t('puidatatables.no-rules-error'));
92
- return null;
93
- } else if (validFilter === true) {
94
- return this.filterModel;
95
- }
96
-
97
- return null;
98
- },
99
- onFilterGroupChanges() {
100
- this.filterModel = this.$refs.group0.filterGroupModel;
101
- }
102
- }
103
- };
104
- </script>