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.
Files changed (43) hide show
  1. package/dist/pui9-components.common.js +75007 -52512
  2. package/dist/pui9-components.css +9 -2
  3. package/package-lock.json +6651 -6827
  4. package/package.json +22 -26
  5. package/src/components/PuiCauDialog.vue +192 -0
  6. package/src/components/PuiCheckbox.vue +25 -4
  7. package/src/components/PuiCodeEditor.vue +2 -1
  8. package/src/components/PuiDateField.vue +653 -614
  9. package/src/components/PuiField.vue +1 -1
  10. package/src/components/PuiFileUpload.vue +275 -0
  11. package/src/components/PuiFileUploadGroup.vue +241 -0
  12. package/src/components/PuiFilter.vue +54 -52
  13. package/src/components/PuiFilterGroup.vue +179 -179
  14. package/src/components/PuiFilterRule.vue +481 -162
  15. package/src/components/PuiFormFooter.vue +5 -38
  16. package/src/components/PuiFormTooltip.vue +50 -0
  17. package/src/components/PuiMasterDetail.vue +18 -11
  18. package/src/components/PuiModalDialog.vue +4 -1
  19. package/src/components/PuiModalDialogForm.vue +5 -1
  20. package/src/components/PuiMultiSelect.vue +383 -280
  21. package/src/components/PuiNumberField.vue +216 -285
  22. package/src/components/PuiRichTextEditor.vue +43 -44
  23. package/src/components/PuiSelect.vue +382 -355
  24. package/src/components/PuiSelectDetailDialog.vue +10 -3
  25. package/src/components/PuiSelectorList.vue +169 -0
  26. package/src/components/PuiSort.vue +98 -0
  27. package/src/components/PuiSpinnerField.vue +101 -121
  28. package/src/components/PuiTextField.vue +374 -258
  29. package/src/index.js +8 -0
  30. package/src/main.js +1 -0
  31. package/src/mixins/PuiFormComponentMixin.js +2 -8
  32. package/src/mixins/PuiSortMixin.js +136 -0
  33. package/src/mixins/PuiUtilsNumberMixin.js +15 -5
  34. package/src/plugins/vuetify.js +2 -1
  35. package/src/utils.js +10 -0
  36. package/dist/demo.html +0 -10
  37. package/dist/pui9-components.common.js.map +0 -1
  38. package/dist/pui9-components.umd.js +0 -86432
  39. package/dist/pui9-components.umd.js.map +0 -1
  40. package/dist/pui9-components.umd.min.js +0 -308
  41. package/dist/pui9-components.umd.min.js.map +0 -1
  42. package/src/mixins/PuiFilterMixin.js +0 -157
  43. package/src/mixins/PuiMultiSelectMixin.js +0 -106
@@ -1,92 +1,75 @@
1
1
  <template>
2
- <v-layout wrap class="pb-1 pt-1 mb-1 puiFilterGroup" @mouseover.stop="showGroupBtns = true" @mouseout="showGroupBtns = false">
3
- <v-flex xs12 v-if="isGroup0">
4
- <v-toolbar height="48" class="elevation-0 bottomtoolbar pt-1 pb-1">
5
- <v-btn v-if="disabled === false" class="btnAddGroup elevation-0" @click="addSubGroup()">
6
- <v-icon small>fa fa-layer-group</v-icon>
7
- <span>{{ $t('addGroup') }}</span>
8
- </v-btn>
9
- <v-spacer></v-spacer>
10
- </v-toolbar>
11
- </v-flex>
12
- <v-flex xs12 v-if="(isGroup0 && groups.length > 1) || !isGroup0">
13
- <v-layout wrap class="puiFilterGroup__groupOperator pt-1 pl-3">
14
- <v-flex xs4 align-self-center>
15
- <span>{{ $t('labelGroup') }}</span>
16
- </v-flex>
17
- <v-flex xs2>
18
- <v-select
19
- :label="$t('or')"
20
- append-icon="fa fa-angle-down"
21
- solo
22
- flat
23
- hide-details
24
- :items="groupOperators"
25
- v-model="groupOp"
2
+ <v-container class="pa-2 mb-2 puiFilterGroup" @mouseover.stop="showGroupBtns = true" @mouseout="showGroupBtns = false">
3
+ <!-- Operador lógico para el grupo -->
4
+ <v-col xs="12" class="pa-0 mb-n2 d-flex">
5
+ <span class="pa-0 pt-2 pr-3">{{ $t('labelGroup') }}</span>
6
+ <v-select
7
+ v-model="filterGroupModel.groupOp"
8
+ class="pr-2"
9
+ style="max-width: 100px !important"
10
+ :items="groupOperators"
11
+ :label="$t('or')"
12
+ append-icon="fa fa-angle-down"
13
+ :disabled="disabled"
14
+ solo
15
+ flat
16
+ hide-details
17
+ ></v-select>
18
+ </v-col>
19
+
20
+ <!-- Selects reglas -->
21
+ <v-col cols="12" v-if="filterGroupModel.rules && filterGroupModel.rules.length > 0">
22
+ <v-row v-for="(rule, index) in filterGroupModel.rules" :key="index">
23
+ <v-col xs12 class="pt-2 pa-0 pl-0 pr-2 d-flex">
24
+ <pui-filter-rule
25
+ :ref="`rule${index}`"
26
+ :ruleIndexProp="index"
27
+ :groupName="groupName"
28
+ :columnsProp="columnsProp"
29
+ :filterColumnValues="filterColumnValues"
30
+ :filterRuleProp="rule"
26
31
  :disabled="disabled"
27
- ></v-select>
28
- </v-flex>
29
- </v-layout>
30
- </v-flex>
31
- <v-layout v-if="!isGroup0" wrap>
32
- <v-flex xs12>
33
- <v-layout v-for="(rule, i) in rules" :key="i">
34
- <v-flex xs11>
35
- <pui-filter-rule
36
- :ref="`rule${i}`"
37
- :ruleIndex="i"
38
- :columns="columns"
39
- :fieldProp="rule.field"
40
- :opProp="rule.op"
41
- :dataProp="rule.data"
42
- :group="groupName"
43
- :ruleOperators="groupOperators"
44
- :disabled="disabled"
45
- ></pui-filter-rule>
46
- </v-flex>
47
- <v-flex xs1 v-if="disabled === false">
48
- <v-list-item>
49
- <v-icon class="pointer" small @click.native="removeRule(i)">fa fa-trash-alt</v-icon>
50
- </v-list-item>
51
- </v-flex>
52
- </v-layout>
53
- </v-flex>
54
- </v-layout>
55
- <v-layout wrap v-if="groups.length > 0" class="full-width">
32
+ @change="onFilterRuleChanges(index)"
33
+ ></pui-filter-rule>
34
+ <v-icon v-if="disabled === false" class="mt-2 ml-2 mr-n1" small v-ripple="false" @click="removeRule(index)"
35
+ >fa fa-trash-alt</v-icon
36
+ >
37
+ </v-col>
38
+ </v-row>
39
+ </v-col>
40
+
41
+ <!-- Filter group -->
42
+ <v-col cols="12" v-if="filterGroupModel.groups.length > 0" class="pa-0 pt-4">
56
43
  <pui-filter-group
57
- v-for="(group, i) in groups"
58
- :groupOperators="groupOperators"
59
- :columns="columns"
60
- :groupName="groupName + '-' + i"
61
- :rulesProp="groupsProp ? groupsProp[i].rules : undefined"
62
- :groupOpProp="groupsProp ? groupsProp[i].groupOp : undefined"
63
- :groupsProp="groupsProp ? groupsProp[i].groups : undefined"
64
- :ref="`group${i}`"
65
- :key="i"
66
- :disabled="disabled"
44
+ v-for="(group, index) in filterGroupModel.groups"
45
+ :ref="`group${index}`"
46
+ :groupIndexProp="index"
47
+ :filterGroupProp="group"
48
+ :columnsProp="columnsProp"
49
+ :filterColumnValues="filterColumnValues"
67
50
  :showSubgroupBtn="showSubgroupBtn"
51
+ :disabled="disabled"
52
+ :key="index"
53
+ @change="onFilterGroupChanges(index)"
68
54
  ></pui-filter-group>
69
- </v-layout>
70
- <v-layout v-if="!isGroup0" wrap>
71
- <v-flex xs12>
72
- <v-toolbar height="32" class="elevation-0 puiFilterGroup__bottombar">
73
- <v-btn v-if="disabled === false" class="btnGroup btnAddRule elevation-0 ml-3" @click="addRule()">
74
- <v-icon small>far fa-plus</v-icon>
75
- <span>{{ $t('addRule') }}</span>
76
- </v-btn>
77
- <v-btn v-if="showSubgroupBtn && disabled === false" class="btnGroup btnAddGroup elevation-0" @click="addSubGroup()">
78
- <v-icon small>fa fa-layer-group</v-icon>
79
- <span>{{ $t('addSubGroup') }}</span>
80
- </v-btn>
81
- <v-btn v-if="!isFirstGroup && disabled === false" class="btnGroup btnRemGroup elevation-0" @click="removeGroup()">
82
- <v-icon small>fa fa-trash-alt</v-icon>
83
- <span>{{ $t('removeGroup') }}</span>
84
- </v-btn>
85
- <v-spacer></v-spacer>
86
- </v-toolbar>
87
- </v-flex>
88
- </v-layout>
89
- </v-layout>
55
+ </v-col>
56
+
57
+ <!-- Buttons acciones -->
58
+ <v-col cols="12" class="elevation-0" :class="isRootGroup && filterGroupModel.groups.length > 0 ? 'pa-0 pt-0' : 'pa-0 pt-3'">
59
+ <v-btn v-if="disabled === false" class="btnGroup btnAddRule elevation-0" @click="addRule">
60
+ <v-icon small>far fa-plus</v-icon>
61
+ <span>{{ $t('addRule') }}</span>
62
+ </v-btn>
63
+ <v-btn v-if="showSubgroupBtn && disabled === false" class="btnGroup btnAddGroup elevation-0 ml-1" @click="addSubGroup">
64
+ <v-icon small>fa fa-layer-group</v-icon>
65
+ <span>{{ $t('addSubGroup') }}</span>
66
+ </v-btn>
67
+ <v-btn v-if="!isRootGroup && disabled === false" class="btnGroup btnRemGroup elevation-0 ml-1" @click="removeGroup">
68
+ <v-icon small>fa fa-trash-alt</v-icon>
69
+ <span>{{ $t('removeGroup') }}</span>
70
+ </v-btn>
71
+ </v-col>
72
+ </v-container>
90
73
  </template>
91
74
 
92
75
  <script>
@@ -98,21 +81,24 @@ export default {
98
81
  PuiFilterRule
99
82
  },
100
83
  props: {
101
- columns: {
102
- type: Array,
103
- required: true
84
+ isRootGroup: {
85
+ type: Boolean,
86
+ default: false
104
87
  },
105
- groupName: {
106
- type: String
88
+ groupIndexProp: {
89
+ type: Number,
90
+ default: 0
107
91
  },
108
- rulesProp: {
109
- type: Array
92
+ filterGroupProp: {
93
+ required: true
110
94
  },
111
- groupOpProp: {
112
- type: String
95
+ columnsProp: {
96
+ type: Array,
97
+ required: true
113
98
  },
114
- groupsProp: {
115
- type: Array
99
+ filterColumnValues: {
100
+ type: Object,
101
+ required: false,
116
102
  },
117
103
  disabled: {
118
104
  type: Boolean,
@@ -124,9 +110,7 @@ export default {
124
110
  },
125
111
  data() {
126
112
  return {
127
- rules: [],
128
- groups: [],
129
- groupOp: 'or',
113
+ filterGroupModel: this.getDefaultFilterGroupModel(),
130
114
  showDeleteRule: null,
131
115
  showGroupBtns: null,
132
116
  groupOperators: [
@@ -142,93 +126,111 @@ export default {
142
126
  };
143
127
  },
144
128
  computed: {
145
- isFirstGroup() {
146
- if (this.groups.length === 1) {
147
- return true;
129
+ groupName() {
130
+ return this.isRootGroup ? this.groupIndexProp.toString() : this.$parent.groupName + '-' + this.groupIndexProp;
131
+ },
132
+ parentGroupName() {
133
+ return this.isRootGroup ? null : this.$parent.groupName;
134
+ }
135
+ },
136
+ watch: {
137
+ filterGroupProp() {
138
+ if (this.filterGroupProp) {
139
+ this.filterGroupModel = this.filterGroupProp;
140
+ this.filterGroupModel.groupOp ? '':this.filterGroupModel.groupOp = 'and';
141
+ this.filterGroupModel.groups ? '':this.filterGroupModel.groups = [];
142
+ this.filterGroupModel.rules ? '':this.filterGroupModel.rules = [];
148
143
  }
149
- return false;
150
144
  },
151
- isGroup0() {
152
- return this.groupName === '0';
145
+ filterGroupModel: {
146
+ deep: true,
147
+ handler() {
148
+ this.$emit('change', this.filterGroupModel);
149
+ }
153
150
  }
154
151
  },
155
152
  created() {
156
153
  this.translateGroupOperators();
157
- if (this.groupOpProp && this.groupsProp && this.rulesProp) {
158
- this.groupOp = this.groupOpProp;
159
- this.groups = this.groupsProp;
160
- this.rules = this.rulesProp;
161
- }
154
+ if (this.filterGroupProp) {
155
+ this.filterGroupModel = this.filterGroupProp;
156
+ this.filterGroupModel.groupOp ? '':this.filterGroupModel.groupOp = 'and';
157
+ this.filterGroupModel.groups ? '':this.filterGroupModel.groups = [];
158
+ this.filterGroupModel.rules ? '':this.filterGroupModel.rules = [];
159
+ }
162
160
  },
163
161
  mounted() {
164
162
  this.$puiEvents.$on('reset-filtering', this.reset);
165
163
  this.$puiEvents.$on(`groupRemoved-${this.groupName}`, this.onGroupRemoved);
166
- if (!this.groupsProp && this.isGroup0 === true && !this.groupComp) {
167
- this.addSubGroup();
168
- } else if (!this.groupsProp && this.groupName === '0-0' && this.rules.length === 0) {
164
+ this.$puiEvents.$on(`subGroupAdded-${this.groupName}`, this.onSubGroupAdded);
165
+
166
+ if (this.filterGroupModel.rules.length === 0 && this.filterGroupModel.groups.length === 0) {
169
167
  this.addRule();
170
168
  }
171
169
  },
172
170
  destroyed() {
173
- this.$puiEvents.$off('reset-filtering', this.reset);
171
+ this.$puiEvents.$off('reset-filtering');
174
172
  this.$puiEvents.$off(`groupRemoved-${this.groupName}`);
173
+ this.$puiEvents.$off(`subGroupAdded-${this.groupName}`);
175
174
  },
176
175
  methods: {
176
+ getUniqueIndex() {
177
+ let numberSTR = Math.random().toString().replace('.', Math.random().toString().replace('.', '').substring(0, 10)).substring(0, 20);
178
+ let numberInt = parseInt(numberSTR).toFixed();
179
+ let integer = parseInt(numberInt);
180
+ return integer;
181
+ },
177
182
  translateGroupOperators() {
178
183
  for (let i = 0, length = this.groupOperators.length; i < length; i++) {
179
184
  this.groupOperators[i].text = this.$t(this.groupOperators[i].text);
180
185
  }
181
186
  },
182
187
  reset() {
183
- this.rules = [];
184
- this.groups = [];
185
- for (var ruleOrGroup in this.$refs) {
186
- delete this.$refs[ruleOrGroup];
188
+ if(this.isRootGroup) {
189
+ this.filterGroupModel = this.getDefaultFilterGroupModel();
190
+ this.addRule();
187
191
  }
192
+
188
193
  },
189
- addRule() {
190
- this.rules.push({});
194
+ onGroupRemoved(index) {
195
+ //alert('soy el grupo ' + this.groupName + ` recibo el evento en el grupo ${this.groupName} con el indice ${index}`);
196
+ this.filterGroupModel.groups.splice(index, 1);
191
197
  },
192
- addSubGroup() {
193
- this.groups.push({});
198
+ onFilterGroupChanges(index) {
199
+ this.filterGroupModel.groups[index] = this.$refs[`group${index}`][0].filterGroupModel;
194
200
  },
195
- removeRule(i) {
196
- this.rules.splice(i, 1);
197
- delete this.$refs[`rule${i}`];
201
+ onFilterRuleChanges(index) {
202
+ this.filterGroupModel.rules[index] = this.$refs[`rule${index}`][0].filterRuleModel;
198
203
  },
199
- onGroupRemoved(i) {
200
- this.groups.splice(i, 1);
201
- delete this.$refs[`group${i}`];
202
- if (this.isGroup0 && this.groupsProp) {
203
- this.groups = this.groupsProp;
204
- }
204
+ addSubGroup() {
205
+ this.filterGroupModel.groups.push(this.getDefaultFilterGroupModel());
206
+ this.filterGroupModel.groups.at(-1).rules.push(PuiFilterRule.methods.getDefaultFilterRuleModel());
205
207
  },
206
208
  removeGroup() {
207
- //Obtenemos el indice de grupo de mismo
208
- const array = this.groupName.split('-');
209
- //el indice de grupo es el numero más a la derecha del nombre (separados por -)
210
- const index = array[array.length - 1];
211
- //el nombre del padre es el groupName quitandole '-' + index
212
- const parentGroupName = array.slice(0, -1).join('-') || array[0];
213
- //publicamos el evento y el grupo padre se encargará de borrar este grupo
214
- this.$puiEvents.$emit(`groupRemoved-${parentGroupName}`, index);
209
+ // alert('soy el grupo ' + this.groupName + ` mando el evento al grupo ${this.parentGroupName} con el indice ${this.groupIndexProp}`);
210
+ if (!this.isRootGroup) {
211
+ this.$puiEvents.$emit(`groupRemoved-${this.parentGroupName}`, this.groupIndexProp);
212
+ } else {
213
+ this.groupFilterModel.groups = [];
214
+ }
215
+ },
216
+ addRule() {
217
+ this.filterGroupModel.rules.push(PuiFilterRule.methods.getDefaultFilterRuleModel());
218
+ },
219
+ removeRule(index) {
220
+ this.filterGroupModel.rules.splice(index, 1);
221
+ },
222
+ getDefaultFilterGroupModel() {
223
+ return {
224
+ rules: [],
225
+ groups: [],
226
+ groupOp: 'and',
227
+ }
215
228
  }
216
229
  }
217
230
  };
218
231
  </script>
219
232
 
220
233
  <style lang="postcss" scoped>
221
- .dragger {
222
- height: 24px !important;
223
- width: 20px !important;
224
- min-width: 20px !important;
225
- padding-left: 3px !important;
226
- padding-right: 3px !important;
227
- color: var(--N-100) !important;
228
- cursor: move !important;
229
- &:hover {
230
- }
231
- }
232
234
  .btnGroup {
233
235
  height: 28px !important;
234
236
  color: var(--N-500);
@@ -237,51 +239,49 @@ export default {
237
239
  }
238
240
  }
239
241
  .puiFilterGroup {
240
- background-color: var(--N-10);
242
+ background-color: var(--N-0);
243
+ border-color: var(--N-100);
244
+ border-style: solid;
241
245
  border-radius: 5px;
246
+ border-width: 1px;
247
+
242
248
  &__groupOperator {
243
249
  height: 50px;
244
250
  }
245
251
  &__bottombar {
246
- }
247
- & .bottomtoolbar {
248
252
  background-color: transparent !important;
249
253
  }
250
254
  & .puiFilterGroup {
251
- background-color: var(--N-0);
252
- margin-left: 11px;
253
- margin-right: 5px;
254
- border-width: 1px;
255
- border-style: solid;
256
- border-color: var(--N-100);
257
- & .v-toolbar,
258
- .v-btn {
259
- background-color: var(--N-0);
255
+ background-color: var(--N-10);
256
+ & .v-btn {
257
+ background-color: var(--N-10);
260
258
  }
261
-
262
259
  & .puiFilterGroup {
263
- background-color: var(--N-10);
264
- margin-left: 11px;
265
- margin-right: 5px;
266
- & .v-toolbar,
267
- .v-btn {
268
- background-color: var(--N-10);
260
+ background-color: var(--N-0);
261
+ & .v-btn {
262
+ background-color: var(--N-0);
269
263
  }
270
264
  & .puiFilterGroup {
271
- background-color: var(--N-0);
272
- margin-left: 11px;
273
- margin-right: 5px;
274
- & .v-toolbar,
275
- .v-btn {
276
- background-color: var(--N-0);
265
+ background-color: var(--N-10);
266
+ & .v-btn {
267
+ background-color: var(--N-10);
277
268
  }
278
269
  & .puiFilterGroup {
279
- background-color: var(--N-10);
280
- margin-left: 11px;
281
- margin-right: 5px;
282
- & .v-toolbar,
283
- .v-btn {
270
+ background-color: var(--N-0);
271
+ & .v-btn {
272
+ background-color: var(--N-0);
273
+ }
274
+ & .puiFilterGroup {
284
275
  background-color: var(--N-10);
276
+ & .v-btn {
277
+ background-color: var(--N-10);
278
+ }
279
+ & .puiFilterGroup {
280
+ background-color: var(--N-0);
281
+ & .v-btn {
282
+ background-color: var(--N-0);
283
+ }
284
+ }
285
285
  }
286
286
  }
287
287
  }