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
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
<v-flex xs12>
|
|
7
7
|
<label v-if="getLabel === '$nbsp;'"> </label>
|
|
8
8
|
<label v-else :class="getLabelRequiredClass">{{ getLabel }}</label>
|
|
9
|
+
<pui-form-tooltip v-bind="{ tooltipDescription, tooltipIcon }" v-if="showTooltip" ref="tooltip"></pui-form-tooltip>
|
|
10
|
+
<v-btn v-if="copyClipboardEnabled && !multiple" style="color:var(--N-300)" class="pb-1" x-small text @click="copySelectedItemToClipboard">
|
|
11
|
+
<v-icon x-small>far fa-copy</v-icon>
|
|
12
|
+
</v-btn>
|
|
9
13
|
</v-flex>
|
|
10
14
|
</v-layout>
|
|
11
15
|
<v-layout>
|
|
@@ -24,7 +28,6 @@
|
|
|
24
28
|
:class="getEditedClass"
|
|
25
29
|
solo
|
|
26
30
|
flat
|
|
27
|
-
@click:append="menuArrow"
|
|
28
31
|
ref="arrowUp"
|
|
29
32
|
:attach="attach ? true : false"
|
|
30
33
|
:autocomplete="!filterServerSide"
|
|
@@ -45,10 +48,12 @@
|
|
|
45
48
|
:placeholder="getPlaceholder"
|
|
46
49
|
:filter="filter"
|
|
47
50
|
v-bind="allProps"
|
|
51
|
+
:hide-details="hideDetails"
|
|
48
52
|
@focus="focusValue"
|
|
49
53
|
@blur="checkValue"
|
|
54
|
+
@keydown="setDropDownDirection"
|
|
55
|
+
@click:append="menuArrow"
|
|
50
56
|
@click:clear="requestItems"
|
|
51
|
-
:hide-details="hideDetails"
|
|
52
57
|
>
|
|
53
58
|
<template slot="append-item" v-if="modelName">
|
|
54
59
|
<infinite-loading @infinite="loading === false && getMoreItemsFromPuiList(search)" ref="infiniteLoading">
|
|
@@ -78,7 +83,7 @@
|
|
|
78
83
|
<template v-else-if="multiple === true">
|
|
79
84
|
<v-chip color="grey lighten-2" :input-value="selected" label small tabindex="-1">
|
|
80
85
|
<pui-select-text-service :item="item" type="select" :itemText="itemText" />
|
|
81
|
-
<v-icon small @click.native.stop.prevent.capture="parent.selectItem(item)">
|
|
86
|
+
<v-icon v-if="!(disabled || readonly)" small @click.native.stop.prevent.capture="parent.selectItem(item)">fal fa-times</v-icon>
|
|
82
87
|
</v-chip>
|
|
83
88
|
</template>
|
|
84
89
|
<template v-else>
|
|
@@ -113,6 +118,10 @@
|
|
|
113
118
|
<v-layout>
|
|
114
119
|
<v-flex :class="labelColumnStyles ? labelColumnStyles : 'xs12 sm6 md4 xl3'">
|
|
115
120
|
<label :class="getLabelRequiredClass">{{ getLabel }}</label>
|
|
121
|
+
<pui-form-tooltip v-bind="{ tooltipDescription, tooltipIcon }" v-if="showTooltip" ref="tooltip"></pui-form-tooltip>
|
|
122
|
+
<v-btn v-if="copyClipboardEnabled && !multiple" style="color:var(--N-300)" class="pb-1" x-small text @click="copySelectedItemToClipboard">
|
|
123
|
+
<v-icon x-small>far fa-copy</v-icon>
|
|
124
|
+
</v-btn>
|
|
116
125
|
</v-flex>
|
|
117
126
|
<v-flex
|
|
118
127
|
:class="
|
|
@@ -129,7 +138,6 @@
|
|
|
129
138
|
:class="getEditedClass"
|
|
130
139
|
solo
|
|
131
140
|
flat
|
|
132
|
-
@click:append="menuArrow"
|
|
133
141
|
ref="arrowUp"
|
|
134
142
|
:attach="attach ? true : false"
|
|
135
143
|
:autocomplete="!filterServerSide"
|
|
@@ -151,10 +159,11 @@
|
|
|
151
159
|
:placeholder="getPlaceholder"
|
|
152
160
|
:filter="filter"
|
|
153
161
|
v-bind="allProps"
|
|
162
|
+
:hide-details="hideDetails"
|
|
154
163
|
@focus="focusValue"
|
|
155
164
|
@blur="checkValue"
|
|
165
|
+
@click:append="menuArrow"
|
|
156
166
|
@click:clear="requestItems"
|
|
157
|
-
:hide-details="hideDetails"
|
|
158
167
|
>
|
|
159
168
|
<template slot="append-item" v-if="modelName">
|
|
160
169
|
<infinite-loading @infinite="loading === false && getMoreItemsFromPuiList(search)" ref="infiniteLoading">
|
|
@@ -248,7 +257,6 @@
|
|
|
248
257
|
:class="getEditedClass"
|
|
249
258
|
solo
|
|
250
259
|
flat
|
|
251
|
-
@click:append="menuArrow"
|
|
252
260
|
ref="arrowUp"
|
|
253
261
|
:attach="attach ? true : false"
|
|
254
262
|
:autocomplete="!filterServerSide"
|
|
@@ -269,9 +277,10 @@
|
|
|
269
277
|
:placeholder="getPlaceholder"
|
|
270
278
|
:filter="filter"
|
|
271
279
|
v-bind="allProps"
|
|
280
|
+
:hide-details="hideDetails"
|
|
272
281
|
@focus="focusValue"
|
|
273
282
|
@blur="checkValue"
|
|
274
|
-
:
|
|
283
|
+
@click:append="menuArrow"
|
|
275
284
|
@click:clear="requestItems"
|
|
276
285
|
>
|
|
277
286
|
<template slot="append-item" v-if="modelName">
|
|
@@ -352,6 +361,11 @@ export default {
|
|
|
352
361
|
//TOFOLLOW
|
|
353
362
|
//https://github.com/vuetifyjs/vuetify/issues/5087 Al cerrar las chips del multiselect se abre el menú
|
|
354
363
|
name: 'PuiSelect',
|
|
364
|
+
inject: {
|
|
365
|
+
form: {
|
|
366
|
+
default: null
|
|
367
|
+
}
|
|
368
|
+
},
|
|
355
369
|
components: {
|
|
356
370
|
PuiSelectTextService,
|
|
357
371
|
PuiSelectDetailDialog,
|
|
@@ -511,7 +525,7 @@ export default {
|
|
|
511
525
|
required: false
|
|
512
526
|
},
|
|
513
527
|
/* Type: String
|
|
514
|
-
Instead of providing the items, if controller is provided it will get the items by calling this web service in @
|
|
528
|
+
Instead of providing the items, if controller is provided it will get the items by calling this web service in @getItemsFromPuiList */
|
|
515
529
|
controller: {
|
|
516
530
|
type: String,
|
|
517
531
|
default: '/puisearch',
|
|
@@ -611,6 +625,23 @@ export default {
|
|
|
611
625
|
type: Boolean,
|
|
612
626
|
default: true,
|
|
613
627
|
required: false
|
|
628
|
+
},
|
|
629
|
+
tooltipDescription: {
|
|
630
|
+
type: String,
|
|
631
|
+
required: false
|
|
632
|
+
},
|
|
633
|
+
tooltipIcon: {
|
|
634
|
+
type: String,
|
|
635
|
+
required: false
|
|
636
|
+
},
|
|
637
|
+
singleItemAutoselect: {
|
|
638
|
+
type: Boolean,
|
|
639
|
+
required: false
|
|
640
|
+
},
|
|
641
|
+
copyClipboard: {
|
|
642
|
+
type: Boolean,
|
|
643
|
+
default: null,
|
|
644
|
+
required: false
|
|
614
645
|
}
|
|
615
646
|
},
|
|
616
647
|
data() {
|
|
@@ -633,7 +664,6 @@ export default {
|
|
|
633
664
|
internalErrorMessages: '',
|
|
634
665
|
selected: false,
|
|
635
666
|
initialItemsToSelect: [],
|
|
636
|
-
internalController: null,
|
|
637
667
|
previousSelectedItems: undefined,
|
|
638
668
|
doingThings: false,
|
|
639
669
|
itemManuallySelected: false,
|
|
@@ -641,140 +671,22 @@ export default {
|
|
|
641
671
|
firstLoad: true,
|
|
642
672
|
requestDataPromise: undefined,
|
|
643
673
|
selectedItemsEventFirstLoad: true,
|
|
644
|
-
internalQueryFields: []
|
|
674
|
+
internalQueryFields: [],
|
|
675
|
+
singleItemAutoselectEnabled: false,
|
|
676
|
+
valid: true
|
|
645
677
|
};
|
|
646
678
|
},
|
|
647
|
-
watch: {
|
|
648
|
-
modelName(modelName) {
|
|
649
|
-
if (modelName && this.isEmpty(this.theItems)) {
|
|
650
|
-
const theModel = this.$store.getters.getModelByName(modelName);
|
|
651
|
-
this.internalController = this.controller || theModel.url.list;
|
|
652
|
-
this.internalController && this.getItemsFromPuiList();
|
|
653
|
-
this.internalQueryFields = !this.isEmpty(this.queryFields) ? this.queryFields : theModel.columns?.map(c => c.name);
|
|
654
|
-
}
|
|
655
|
-
},
|
|
656
|
-
itemsToSelect: {
|
|
657
|
-
handler(newValue) {
|
|
658
|
-
if (this.isMultiSelect === true) {
|
|
659
|
-
this.trackItemsToSelect === true && this.selectItems();
|
|
660
|
-
} else {
|
|
661
|
-
this.reactiveHandler(newValue);
|
|
662
|
-
}
|
|
663
|
-
},
|
|
664
|
-
deep: true
|
|
665
|
-
},
|
|
666
|
-
fixedFilterWatcher: {
|
|
667
|
-
handler(newFilter, oldFilter) {
|
|
668
|
-
if (newFilter === oldFilter) {
|
|
669
|
-
return;
|
|
670
|
-
}
|
|
671
|
-
this.previousSelectedItems = this.previousSelectedItems || this.selectedItems;
|
|
672
|
-
this.resetItems();
|
|
673
|
-
this.filterItems();
|
|
674
|
-
},
|
|
675
|
-
deep: true
|
|
676
|
-
},
|
|
677
|
-
filterMapWatcher: {
|
|
678
|
-
handler(newFilter, oldFilter) {
|
|
679
|
-
if (newFilter === oldFilter) {
|
|
680
|
-
return;
|
|
681
|
-
}
|
|
682
|
-
this.resetItems(JSON.parse(newFilter));
|
|
683
|
-
this.filterItems(null);
|
|
684
|
-
},
|
|
685
|
-
deep: true
|
|
686
|
-
},
|
|
687
|
-
loading(newValue, oldValue) {
|
|
688
|
-
if (newValue === false && oldValue === true && !this.isEmpty(this.previousSelectedItems)) {
|
|
689
|
-
this.selectPreviousValidItems();
|
|
690
|
-
this.previousSelectedItems = undefined;
|
|
691
|
-
}
|
|
692
|
-
},
|
|
693
|
-
search(newValue, oldValue) {
|
|
694
|
-
if (this.multiple && this.isEmpty(newValue) && this.isEmpty(oldValue)) {
|
|
695
|
-
return;
|
|
696
|
-
}
|
|
697
|
-
this.searchable && this.filterItems(newValue);
|
|
698
|
-
},
|
|
699
|
-
selectedItems(newVal) {
|
|
700
|
-
if (this.reactive) {
|
|
701
|
-
if (this.firstLoad) {
|
|
702
|
-
this.firstLoad = false;
|
|
703
|
-
} else if (!this.itemProgrammaticallySelected) {
|
|
704
|
-
this.itemManuallySelected = true;
|
|
705
|
-
} else {
|
|
706
|
-
this.itemProgrammaticallySelected = false;
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
this.clearMessages();
|
|
710
|
-
if (this.modelFormMapping) {
|
|
711
|
-
this.$emit('input', this.replaceMapping());
|
|
712
|
-
} else {
|
|
713
|
-
this.$emit('input', newVal);
|
|
714
|
-
}
|
|
715
|
-
this.$emit('change', newVal);
|
|
716
|
-
|
|
717
|
-
if (this.emitSelectedItemsEventOnFirstLoad || !this.selectedItemsEventFirstLoad) {
|
|
718
|
-
this.$puiEvents.$emit(`onPuiSelect_selectedItems-${this.puiSelectId}`, { id: this.puiSelectId, model: newVal });
|
|
719
|
-
}
|
|
720
|
-
this.selectedItemsEventFirstLoad = false;
|
|
721
|
-
if (this.attach && this.puiSelectId && !this.multiple && newVal) {
|
|
722
|
-
// Need for browser to recalculate correctly getBoundingClientSelectPosition
|
|
723
|
-
document.getElementById(this.puiSelectId).click();
|
|
724
|
-
}
|
|
725
|
-
},
|
|
726
|
-
disabled(newVal) {
|
|
727
|
-
this.newDisabled = newVal;
|
|
728
|
-
if (newVal) {
|
|
729
|
-
this.clearMessages();
|
|
730
|
-
}
|
|
731
|
-
},
|
|
732
|
-
detailComponentName(newValue, oldValue) {
|
|
733
|
-
if (!this.isEmpty(oldValue)) {
|
|
734
|
-
this.$puiEvents.$off(`pui-modalDialog-${oldValue}_${this.puiSelectId}_popup-hide`);
|
|
735
|
-
}
|
|
736
|
-
if (!this.isEmpty(newValue)) {
|
|
737
|
-
const self = this;
|
|
738
|
-
this.$puiEvents.$on(`pui-modalDialog-${newValue}_${this.puiSelectId}_popup-hide`, (data) => {
|
|
739
|
-
self.showDetailComponent = false;
|
|
740
|
-
if (data) {
|
|
741
|
-
const newItem = {};
|
|
742
|
-
const itemValues = this.itemValue;
|
|
743
|
-
itemValues.forEach((pkValue) => {
|
|
744
|
-
newItem[pkValue] = data[pkValue];
|
|
745
|
-
});
|
|
746
|
-
self.itemsToSelect[0] = newItem;
|
|
747
|
-
self.onPuiSelectItemsToSelect = [newItem];
|
|
748
|
-
self.getSelectedItemsFromPuiList();
|
|
749
|
-
}
|
|
750
|
-
});
|
|
751
|
-
}
|
|
752
|
-
},
|
|
753
|
-
queryFields(queryFields) {
|
|
754
|
-
if (!this.isEmpty(queryFields)) {
|
|
755
|
-
this.internalQueryFields = queryFields;
|
|
756
|
-
} else if (this.modelName) {
|
|
757
|
-
const theModel = this.$store.getters.getModelByName(this.modelName);
|
|
758
|
-
this.internalQueryFields = theModel.columns?.map(c => c.name);
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
},
|
|
762
679
|
computed: {
|
|
763
680
|
allProps() {
|
|
764
681
|
const propsWithoutLabel = { ...this.$props };
|
|
765
682
|
delete propsWithoutLabel.label;
|
|
766
683
|
return { ...this.$attrs, propsWithoutLabel };
|
|
767
684
|
},
|
|
768
|
-
|
|
769
|
-
return this.$
|
|
685
|
+
theModel() {
|
|
686
|
+
return this.$store.getters.getModelByName(this.modelName);
|
|
770
687
|
},
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
return 'FromPuiList';
|
|
774
|
-
} else if (this.internalController) {
|
|
775
|
-
return 'FromService';
|
|
776
|
-
}
|
|
777
|
-
return '';
|
|
688
|
+
internalController() {
|
|
689
|
+
return this.controller; // || this.theModel.url.list;
|
|
778
690
|
},
|
|
779
691
|
fixedFilterWatcher() {
|
|
780
692
|
return JSON.stringify(this.fixedFilter);
|
|
@@ -789,7 +701,7 @@ export default {
|
|
|
789
701
|
return this.$t('pui9.components.select.all-items-showed');
|
|
790
702
|
},
|
|
791
703
|
isDisabled() {
|
|
792
|
-
if (!this.
|
|
704
|
+
if (!this.hasEmptyValue(this.newDisabled)) {
|
|
793
705
|
return this.newDisabled;
|
|
794
706
|
}
|
|
795
707
|
return this.disabled;
|
|
@@ -856,19 +768,7 @@ export default {
|
|
|
856
768
|
return null;
|
|
857
769
|
},
|
|
858
770
|
getRules() {
|
|
859
|
-
|
|
860
|
-
if (this.required) {
|
|
861
|
-
var func = (value) => !!value || this.requiredMessage;
|
|
862
|
-
var func2 = () => !this.internalError || (Array.isArray(this.internalErrorMessages) && this.internalErrorMessages.length > 0);
|
|
863
|
-
var func3 = () => {
|
|
864
|
-
if (this.isEmpty(this.selectedItems)) {
|
|
865
|
-
return this.requiredMessage;
|
|
866
|
-
}
|
|
867
|
-
return true;
|
|
868
|
-
};
|
|
869
|
-
rules.push(func, func2, func3);
|
|
870
|
-
}
|
|
871
|
-
return rules;
|
|
771
|
+
return [...this.rules];
|
|
872
772
|
},
|
|
873
773
|
isEdited() {
|
|
874
774
|
if (this.noeditable || this.disabled || this.readonly || this.selected === false) {
|
|
@@ -879,39 +779,230 @@ export default {
|
|
|
879
779
|
},
|
|
880
780
|
isMenuOpened() {
|
|
881
781
|
return this.$refs.arrowUp ? this.$refs.arrowUp.isMenuActive || this.$refs.arrowUp.isFocused : false;
|
|
782
|
+
},
|
|
783
|
+
showTooltip() {
|
|
784
|
+
if (this.getLabel === '' || this.getLabel === null) {
|
|
785
|
+
return false;
|
|
786
|
+
}
|
|
787
|
+
return this.tooltipDescription || this.tooltip;
|
|
788
|
+
},
|
|
789
|
+
copyClipboardEnabled() {
|
|
790
|
+
return this.copyClipboard != null ? this.copyClipboard : this.$store.state.components.copyClipboardSelect;
|
|
791
|
+
}
|
|
792
|
+
},
|
|
793
|
+
watch: {
|
|
794
|
+
modelName(modelName) {
|
|
795
|
+
if (modelName && this.hasEmptyValue(this.theItems)) {
|
|
796
|
+
this.setInternalQueryFields();
|
|
797
|
+
this.getItemsFromPuiList();
|
|
798
|
+
}
|
|
799
|
+
},
|
|
800
|
+
itemsToSelect: {
|
|
801
|
+
handler(newValue) {
|
|
802
|
+
this.reactiveHandler(newValue);
|
|
803
|
+
},
|
|
804
|
+
deep: true
|
|
805
|
+
},
|
|
806
|
+
fixedFilterWatcher: {
|
|
807
|
+
handler(newFilter, oldFilter) {
|
|
808
|
+
if (newFilter === oldFilter) {
|
|
809
|
+
return;
|
|
810
|
+
}
|
|
811
|
+
this.previousSelectedItems = this.previousSelectedItems || this.selectedItems;
|
|
812
|
+
this.resetItems();
|
|
813
|
+
this.filterItems();
|
|
814
|
+
},
|
|
815
|
+
deep: true
|
|
816
|
+
},
|
|
817
|
+
filterMapWatcher: {
|
|
818
|
+
handler(newFilter, oldFilter) {
|
|
819
|
+
if (newFilter === oldFilter) {
|
|
820
|
+
return;
|
|
821
|
+
}
|
|
822
|
+
this.resetItems(JSON.parse(newFilter));
|
|
823
|
+
this.filterItems(null);
|
|
824
|
+
},
|
|
825
|
+
deep: true
|
|
826
|
+
},
|
|
827
|
+
loading(newValue, oldValue) {
|
|
828
|
+
if (newValue === false && oldValue === true && !this.hasEmptyValue(this.previousSelectedItems)) {
|
|
829
|
+
this.selectPreviousValidItems();
|
|
830
|
+
this.previousSelectedItems = undefined;
|
|
831
|
+
}
|
|
832
|
+
},
|
|
833
|
+
search(newValue, oldValue) {
|
|
834
|
+
if (this.multiple && this.hasEmptyValue(newValue) && this.hasEmptyValue(oldValue)) {
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
this.searchable && this.filterItems(newValue);
|
|
838
|
+
},
|
|
839
|
+
selectedItems(newVal) {
|
|
840
|
+
if (this.reactive) {
|
|
841
|
+
if (this.firstLoad) {
|
|
842
|
+
this.firstLoad = false;
|
|
843
|
+
} else if (!this.itemProgrammaticallySelected) {
|
|
844
|
+
this.itemManuallySelected = true;
|
|
845
|
+
} else {
|
|
846
|
+
this.itemProgrammaticallySelected = false;
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
this.clearMessages();
|
|
850
|
+
if (this.modelFormMapping) {
|
|
851
|
+
this.$emit('input', this.replaceMapping());
|
|
852
|
+
} else {
|
|
853
|
+
this.$emit('input', newVal);
|
|
854
|
+
}
|
|
855
|
+
this.$emit('change', newVal);
|
|
856
|
+
|
|
857
|
+
if (this.emitSelectedItemsEventOnFirstLoad || !this.selectedItemsEventFirstLoad) {
|
|
858
|
+
this.$puiEvents.$emit(`onPuiSelect_selectedItems-${this.puiSelectId}`, { id: this.puiSelectId, model: newVal });
|
|
859
|
+
}
|
|
860
|
+
this.selectedItemsEventFirstLoad = false;
|
|
861
|
+
if (this.attach && this.puiSelectId && !this.multiple && newVal) {
|
|
862
|
+
// Need for browser to recalculate correctly getBoundingClientSelectPosition
|
|
863
|
+
document.getElementById(this.puiSelectId).click();
|
|
864
|
+
}
|
|
865
|
+
},
|
|
866
|
+
disabled(newVal) {
|
|
867
|
+
this.newDisabled = newVal;
|
|
868
|
+
if (newVal) {
|
|
869
|
+
this.clearMessages();
|
|
870
|
+
}
|
|
871
|
+
},
|
|
872
|
+
detailComponentName(newValue, oldValue) {
|
|
873
|
+
if (!this.hasEmptyValue(oldValue)) {
|
|
874
|
+
this.$puiEvents.$off(`pui-modalDialog-${oldValue}_${this.puiSelectId}_popup-hide`);
|
|
875
|
+
}
|
|
876
|
+
if (!this.hasEmptyValue(newValue)) {
|
|
877
|
+
const self = this;
|
|
878
|
+
this.$puiEvents.$on(`pui-modalDialog-${newValue}_${this.puiSelectId}_popup-hide`, (data) => {
|
|
879
|
+
self.showDetailComponent = false;
|
|
880
|
+
if (data) {
|
|
881
|
+
const newItem = {};
|
|
882
|
+
const itemValues = this.itemValue;
|
|
883
|
+
itemValues.forEach((pkValue) => {
|
|
884
|
+
newItem[pkValue] = data[pkValue];
|
|
885
|
+
});
|
|
886
|
+
self.itemsToSelect[0] = newItem;
|
|
887
|
+
self.onPuiSelectItemsToSelect = [newItem];
|
|
888
|
+
self.getSelectedItemsFromPuiList();
|
|
889
|
+
}
|
|
890
|
+
});
|
|
891
|
+
}
|
|
892
|
+
},
|
|
893
|
+
theItems() {
|
|
894
|
+
if (this.singleItemAutoselectEnabled && this.theItems.length == 1) {
|
|
895
|
+
this.selectedItems = this.theItems[0];
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
},
|
|
899
|
+
created() {
|
|
900
|
+
// v-form injected
|
|
901
|
+
this.form && this.form.register(this);
|
|
902
|
+
|
|
903
|
+
this.puiSelectId = this.$attrs.id;
|
|
904
|
+
this.isMobile = this.$store.getters.isMobile;
|
|
905
|
+
|
|
906
|
+
//TODO poner itemValues como un array si viene de string, para unificar simplificar donde haya comprobaciones itemValuesMultiple
|
|
907
|
+
this.itemsToSelect && this.itemsToSelect.forEach((item) => {
|
|
908
|
+
this.initialItemsToSelect.push(item);
|
|
909
|
+
});
|
|
910
|
+
|
|
911
|
+
// Check Item Text
|
|
912
|
+
this.itemTextMultiple = Array.isArray(this.itemText);
|
|
913
|
+
if (this.itemTextMultiple === false) {
|
|
914
|
+
this.itemTextNested = this.checkForNestedFields(this.itemText);
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
// Check Item Value
|
|
918
|
+
this.itemValueMultiple = Array.isArray(this.itemValue);
|
|
919
|
+
if (this.itemValueMultiple === false) {
|
|
920
|
+
this.itemValueNested = this.checkForNestedFields(this.itemValue);
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
this.setInternalQueryFields();
|
|
924
|
+
this.getItems();
|
|
925
|
+
|
|
926
|
+
this.setSingleItemAutoselectEnabled();
|
|
927
|
+
|
|
928
|
+
// Subscribe events
|
|
929
|
+
this.$puiEvents.$on(`onPuiSelect_${this.puiSelectId}`, (newVal) => {
|
|
930
|
+
this.itemsToSelect[0] = newVal;
|
|
931
|
+
this.onPuiSelectItemsToSelect = [newVal];
|
|
932
|
+
this.getSelectedItemsFromPuiList();
|
|
933
|
+
});
|
|
934
|
+
},
|
|
935
|
+
mounted() {
|
|
936
|
+
if (this.detailComponentName) {
|
|
937
|
+
const self = this;
|
|
938
|
+
this.$puiEvents.$on(`pui-modalDialog-${this.detailComponentName}_${this.puiSelectId}_popup-hide`, (data) => {
|
|
939
|
+
self.showDetailComponent = false;
|
|
940
|
+
if (data) {
|
|
941
|
+
const newItem = {};
|
|
942
|
+
const itemValues = this.itemValue;
|
|
943
|
+
itemValues.forEach((pkValue) => {
|
|
944
|
+
newItem[pkValue] = data[pkValue];
|
|
945
|
+
});
|
|
946
|
+
self.itemsToSelect[0] = newItem;
|
|
947
|
+
self.onPuiSelectItemsToSelect = [newItem];
|
|
948
|
+
self.getSelectedItemsFromPuiList();
|
|
949
|
+
}
|
|
950
|
+
});
|
|
882
951
|
}
|
|
883
952
|
},
|
|
953
|
+
beforeDestroy() {
|
|
954
|
+
// Unsubscribe events
|
|
955
|
+
this.$puiEvents.$off(`onPuiSelect_${this.puiSelectId}`);
|
|
956
|
+
this.$puiEvents.$off(`pui-modalDialog-${this.detailComponentName}_${this.puiSelectId}_popup-hide`);
|
|
957
|
+
},
|
|
884
958
|
methods: {
|
|
959
|
+
validate() {
|
|
960
|
+
this.checkValue();
|
|
961
|
+
this.valid = !this.internalError;
|
|
962
|
+
return this.valid;
|
|
963
|
+
},
|
|
885
964
|
requestItems() {
|
|
886
965
|
this.getItemsFromPuiList();
|
|
887
966
|
},
|
|
967
|
+
setInternalQueryFields() {
|
|
968
|
+
this.internalQueryFields = this.queryFields;
|
|
969
|
+
|
|
970
|
+
if (this.modelName && this.hasEmptyValue(this.queryFields)) {
|
|
971
|
+
this.internalQueryFields = this.theModel.columns?.map((c) => c.name);
|
|
972
|
+
}
|
|
973
|
+
},
|
|
974
|
+
setSingleItemAutoselectEnabled() {
|
|
975
|
+
if (this.singleItemAutoselect || (this.$store.state.global.singleItemAutoselectOnRequired && this.required)) {
|
|
976
|
+
this.singleItemAutoselectEnabled = true;
|
|
977
|
+
}
|
|
978
|
+
},
|
|
979
|
+
focusValue() {
|
|
980
|
+
this.hasBeenFocused = true;
|
|
981
|
+
this.$refs.arrowUp.isMenuActive = true;
|
|
982
|
+
this.setDropDownDirection();
|
|
983
|
+
},
|
|
888
984
|
setDropDownDirection() {
|
|
889
985
|
if (this.$refs.arrowUp && this.attach) {
|
|
890
986
|
setTimeout(() => {
|
|
891
987
|
const puiSelect = this.$refs.arrowUp.$el;
|
|
892
|
-
const dropDown = puiSelect.querySelector('.v-menu__content');
|
|
893
988
|
const puiSelectPositions = puiSelect.getBoundingClientRect();
|
|
989
|
+
|
|
894
990
|
const heightBrowser = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
|
|
895
991
|
const screenAvailableForDropDown = heightBrowser - puiSelectPositions.top;
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
992
|
+
|
|
993
|
+
const dropDown = puiSelect.querySelector('.v-menu__content');
|
|
994
|
+
if (dropDown) {
|
|
995
|
+
if (screenAvailableForDropDown < parseInt(dropDown.style['max-height']?.replace('px', '')) + 10) {
|
|
996
|
+
dropDown.style.top = 'initial';
|
|
997
|
+
dropDown.style.bottom = '40px';
|
|
998
|
+
} else {
|
|
999
|
+
dropDown.style.bottom = 'initial';
|
|
1000
|
+
dropDown.style.top = '40px';
|
|
1001
|
+
}
|
|
902
1002
|
}
|
|
903
1003
|
}, 0);
|
|
904
1004
|
}
|
|
905
1005
|
},
|
|
906
|
-
focusValue() {
|
|
907
|
-
//antes estaba así pero resultaba en un bug, se cambia a como esta dos lineas abajo. Si tenia explicación que se comente ya que generaba un bug
|
|
908
|
-
//(this.theItems.length === this.initialItemsToSelect.length || !this.theItems.length) && this[`getItems${this.getItemsFrom}`]();
|
|
909
|
-
this.hasBeenFocused === false && this[`getItems${this.getItemsFrom}`]();
|
|
910
|
-
//never more to load on focus
|
|
911
|
-
this.hasBeenFocused = true;
|
|
912
|
-
this.$refs.arrowUp.isMenuActive = true;
|
|
913
|
-
this.setDropDownDirection();
|
|
914
|
-
},
|
|
915
1006
|
menuArrow() {
|
|
916
1007
|
const arrowEl = this.$refs.arrowUp;
|
|
917
1008
|
if (arrowEl.isMenuActive) {
|
|
@@ -934,7 +1025,7 @@ export default {
|
|
|
934
1025
|
//los dos estan vacios
|
|
935
1026
|
return false;
|
|
936
1027
|
}
|
|
937
|
-
if (!this.
|
|
1028
|
+
if (!this.hasEmptyValue(this.itemValue)) {
|
|
938
1029
|
if (this.initialItemsToSelect.length !== this.selectedItems.length) {
|
|
939
1030
|
return true;
|
|
940
1031
|
} else if (this.itemValueNested === true) {
|
|
@@ -968,20 +1059,20 @@ export default {
|
|
|
968
1059
|
return false;
|
|
969
1060
|
} else {
|
|
970
1061
|
//comprobamos existencias y por último contenido de los objetos
|
|
971
|
-
if (this.
|
|
1062
|
+
if (this.hasEmptyValue(this.initialItemsToSelect) || this.hasEmptyValue(this.selectedItems)) {
|
|
972
1063
|
if (this.initialItemsToSelect && this.initialItemsToSelect.length > 0) {
|
|
973
1064
|
if (this.itemValueMultiple === true) {
|
|
974
|
-
return !this.
|
|
1065
|
+
return !this.hasEmptyValue(this.initialItemsToSelect[this.itemValue[0]]);
|
|
975
1066
|
} else {
|
|
976
|
-
return !this.
|
|
1067
|
+
return !this.hasEmptyValue(this.initialItemsToSelect[this.itemValue]);
|
|
977
1068
|
}
|
|
978
|
-
} else if (!this.
|
|
1069
|
+
} else if (!this.hasEmptyValue(this.selectedItems)) {
|
|
979
1070
|
return true;
|
|
980
1071
|
}
|
|
981
1072
|
//los dos estan vacios
|
|
982
1073
|
return false;
|
|
983
1074
|
}
|
|
984
|
-
if (!this.
|
|
1075
|
+
if (!this.hasEmptyValue(this.itemValue)) {
|
|
985
1076
|
if (this.itemValueMultiple === true) {
|
|
986
1077
|
for (let i = 0, length = this.itemValue.length; i < length; i++) {
|
|
987
1078
|
if (this.selectedItems[this.itemValue[i]] !== this.initialItemsToSelect[0][this.itemValue[i]]) {
|
|
@@ -992,7 +1083,7 @@ export default {
|
|
|
992
1083
|
} else if (this.itemValueNested === true) {
|
|
993
1084
|
//TODO
|
|
994
1085
|
}
|
|
995
|
-
return this.initialItemsToSelect[0][this.itemValue] !== this.selectedItems[this.itemValue];
|
|
1086
|
+
return this.initialItemsToSelect[0] != null && this.initialItemsToSelect[0][this.itemValue] !== this.selectedItems[this.itemValue];
|
|
996
1087
|
}
|
|
997
1088
|
return this.initialItemsToSelect[0] !== this.selectedItems;
|
|
998
1089
|
}
|
|
@@ -1001,7 +1092,7 @@ export default {
|
|
|
1001
1092
|
this.search = '';
|
|
1002
1093
|
this.clearMessages();
|
|
1003
1094
|
if (this.required) {
|
|
1004
|
-
if (this.
|
|
1095
|
+
if (this.hasEmptyValue(this.selectedItems)) {
|
|
1005
1096
|
this.showErrorMessage();
|
|
1006
1097
|
}
|
|
1007
1098
|
}
|
|
@@ -1022,64 +1113,19 @@ export default {
|
|
|
1022
1113
|
}, 500);
|
|
1023
1114
|
}
|
|
1024
1115
|
},
|
|
1025
|
-
insertItem() {
|
|
1026
|
-
//alert('TODO');
|
|
1027
|
-
},
|
|
1028
1116
|
disableInput() {
|
|
1029
1117
|
this.$el.children[0].children[0].children[0].children[0].children[0].children[1].setAttribute('disabled', '');
|
|
1030
1118
|
this.disabledInput = true;
|
|
1031
1119
|
},
|
|
1032
|
-
clearItems() {
|
|
1033
|
-
this.selectedItems = [];
|
|
1034
|
-
},
|
|
1035
|
-
selectItemById(id) {
|
|
1036
|
-
var itemValueTemp = this.itemValue;
|
|
1037
|
-
var selectedItem;
|
|
1038
|
-
for (let index = 0, length = this.theItems.length; index < length; index++) {
|
|
1039
|
-
var item = this.theItems[index];
|
|
1040
|
-
if (this.itemValueMultiple === true) {
|
|
1041
|
-
let allPropsEqual = false;
|
|
1042
|
-
for (let i = 0, length = this.itemValue.length; i < length; i++) {
|
|
1043
|
-
if (item[this.itemValue[i]] !== id[this.itemValue[i]]) {
|
|
1044
|
-
allPropsEqual = true;
|
|
1045
|
-
break;
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
if (allPropsEqual === true) {
|
|
1049
|
-
continue;
|
|
1050
|
-
}
|
|
1051
|
-
selectedItem = this.return_object ? item : id;
|
|
1052
|
-
if (this.multiple === false) {
|
|
1053
|
-
this.selectedItems = selectedItem;
|
|
1054
|
-
} else {
|
|
1055
|
-
this.selectedItems.push(selectedItem);
|
|
1056
|
-
}
|
|
1057
|
-
//eslint-disable-next-line no-useless-return
|
|
1058
|
-
return;
|
|
1059
|
-
} else if (item[itemValueTemp] === id) {
|
|
1060
|
-
selectedItem = this.return_object ? item : id;
|
|
1061
|
-
if (this.multiple === false) {
|
|
1062
|
-
this.selectedItems = selectedItem;
|
|
1063
|
-
} else {
|
|
1064
|
-
this.selectedItems.push(selectedItem);
|
|
1065
|
-
}
|
|
1066
|
-
//eslint-disable-next-line no-useless-return
|
|
1067
|
-
return;
|
|
1068
|
-
} else if (item === id) {
|
|
1069
|
-
this.selectedItems = item;
|
|
1070
|
-
return;
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1073
|
-
},
|
|
1074
1120
|
goToDetail(method) {
|
|
1075
|
-
if (!this.
|
|
1121
|
+
if (!this.hasEmptyValue(this.selectedItems)) {
|
|
1076
1122
|
const detailPk = {};
|
|
1077
1123
|
let itemValues = this.itemValue;
|
|
1078
1124
|
if (this.itemValueMultiple === false) {
|
|
1079
1125
|
itemValues = [this.itemValue];
|
|
1080
1126
|
}
|
|
1081
1127
|
itemValues.forEach((pkProperty) => {
|
|
1082
|
-
if (!this.
|
|
1128
|
+
if (!this.hasEmptyValue(this.selectedItems[pkProperty])) {
|
|
1083
1129
|
detailPk[pkProperty] = this.selectedItems[pkProperty];
|
|
1084
1130
|
}
|
|
1085
1131
|
});
|
|
@@ -1095,17 +1141,6 @@ export default {
|
|
|
1095
1141
|
this.showDetailComponent = true;
|
|
1096
1142
|
}
|
|
1097
1143
|
},
|
|
1098
|
-
subscribeEvents() {
|
|
1099
|
-
this.$puiEvents.$on(`onPuiSelect_${this.puiSelectId}`, (newVal) => {
|
|
1100
|
-
this.itemsToSelect[0] = newVal;
|
|
1101
|
-
this.onPuiSelectItemsToSelect = [newVal];
|
|
1102
|
-
this.getSelectedItemsFromPuiList();
|
|
1103
|
-
});
|
|
1104
|
-
},
|
|
1105
|
-
unsubscribeEvents() {
|
|
1106
|
-
this.$puiEvents.$off(`onPuiSelect_${this.puiSelectId}`);
|
|
1107
|
-
this.$puiEvents.$off(`pui-modalDialog-${this.detailComponentName}_${this.puiSelectId}_popup-hide`);
|
|
1108
|
-
},
|
|
1109
1144
|
replaceMapping() {
|
|
1110
1145
|
let itemValues = this.itemValue;
|
|
1111
1146
|
if (this.itemValueMultiple === false) {
|
|
@@ -1113,7 +1148,7 @@ export default {
|
|
|
1113
1148
|
}
|
|
1114
1149
|
if (this.multiple !== true) {
|
|
1115
1150
|
itemValues.forEach((pkValue) => {
|
|
1116
|
-
if (this.
|
|
1151
|
+
if (this.hasEmptyValue(this.selectedItems)) {
|
|
1117
1152
|
if (this.filterId && this.filterMap) {
|
|
1118
1153
|
let isParentPkValue = false;
|
|
1119
1154
|
for (const property in this.filterMap) {
|
|
@@ -1161,35 +1196,19 @@ export default {
|
|
|
1161
1196
|
const selectedObject = {};
|
|
1162
1197
|
for (const property in this.filterMap) {
|
|
1163
1198
|
let parentProperty = property;
|
|
1164
|
-
if (this.filterParentMap && !this.
|
|
1199
|
+
if (this.filterParentMap && !this.hasEmptyValue(this.filterParentMap[property])) {
|
|
1165
1200
|
parentProperty = this.filterParentMap[property];
|
|
1166
1201
|
}
|
|
1167
1202
|
selectedObject[parentProperty] = this.selectedItems[property];
|
|
1168
1203
|
}
|
|
1169
1204
|
this.$puiEvents.$emit(`onPuiSelect_${this.filterId}`, selectedObject);
|
|
1170
1205
|
},
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
this.loading =
|
|
1176
|
-
this.
|
|
1177
|
-
const bodyRequest = this.getBodyRequest(search);
|
|
1178
|
-
const loadMoreItems = (response) => {
|
|
1179
|
-
if (response && response.data) {
|
|
1180
|
-
//this.processItems(response.data.data);
|
|
1181
|
-
this.theItems = this.theItems.concat(response.data.data);
|
|
1182
|
-
this.$refs.infiniteLoading.stateChanger.loaded();
|
|
1183
|
-
if (response.data.totalPages <= this.page) {
|
|
1184
|
-
this.$refs.infiniteLoading.stateChanger.complete();
|
|
1185
|
-
}
|
|
1186
|
-
}
|
|
1187
|
-
this.loading = false;
|
|
1188
|
-
};
|
|
1189
|
-
this.postRequest(bodyRequest, loadMoreItems);
|
|
1190
|
-
},
|
|
1191
|
-
getItemsFromService() {
|
|
1192
|
-
// de momento por implementar
|
|
1206
|
+
getItems() {
|
|
1207
|
+
if (this.items) {
|
|
1208
|
+
this.theItems = this.items;
|
|
1209
|
+
}
|
|
1210
|
+
this.loading = false;
|
|
1211
|
+
this.selectItems();
|
|
1193
1212
|
},
|
|
1194
1213
|
getItemsFromPuiList(search) {
|
|
1195
1214
|
this.page = 1;
|
|
@@ -1198,7 +1217,6 @@ export default {
|
|
|
1198
1217
|
this.$refs.infiniteLoading && this.$refs.infiniteLoading.stateChanger.reset();
|
|
1199
1218
|
if (response && response.data) {
|
|
1200
1219
|
this.theItems = response.data.data;
|
|
1201
|
-
//this.processItems(this.theItems);
|
|
1202
1220
|
if (this.selected === false) {
|
|
1203
1221
|
this.selectItems();
|
|
1204
1222
|
} else {
|
|
@@ -1214,13 +1232,24 @@ export default {
|
|
|
1214
1232
|
const bodyRequest = this.getBodyRequest(search);
|
|
1215
1233
|
this.postRequest(bodyRequest, loadItems);
|
|
1216
1234
|
},
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
this.loading =
|
|
1222
|
-
|
|
1223
|
-
this.
|
|
1235
|
+
/**
|
|
1236
|
+
* Metodo llamado por el componente infinteloading al hacer scroll, nadie más lo llama directamente
|
|
1237
|
+
*/
|
|
1238
|
+
getMoreItemsFromPuiList(search) {
|
|
1239
|
+
this.loading = true;
|
|
1240
|
+
this.page++;
|
|
1241
|
+
const bodyRequest = this.getBodyRequest(search);
|
|
1242
|
+
const loadMoreItems = (response) => {
|
|
1243
|
+
if (response && response.data) {
|
|
1244
|
+
this.theItems = this.theItems.concat(response.data.data);
|
|
1245
|
+
this.$refs.infiniteLoading.stateChanger.loaded();
|
|
1246
|
+
if (response.data.totalPages <= this.page) {
|
|
1247
|
+
this.$refs.infiniteLoading.stateChanger.complete();
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
this.loading = false;
|
|
1251
|
+
};
|
|
1252
|
+
this.postRequest(bodyRequest, loadMoreItems);
|
|
1224
1253
|
},
|
|
1225
1254
|
postRequest(body, successCallback) {
|
|
1226
1255
|
this.$puiRequests.postRequest(this.internalController, body, successCallback, (error) => {
|
|
@@ -1232,14 +1261,12 @@ export default {
|
|
|
1232
1261
|
model: this.modelName,
|
|
1233
1262
|
filter: this.createFilter()
|
|
1234
1263
|
};
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
paginateItemsParams.rows = this.rowNum;
|
|
1242
|
-
}
|
|
1264
|
+
|
|
1265
|
+
paginateItemsParams.rows = this.rows;
|
|
1266
|
+
paginateItemsParams.page = this.page;
|
|
1267
|
+
paginateItemsParams.queryText = search;
|
|
1268
|
+
paginateItemsParams.queryFields = this.internalQueryFields;
|
|
1269
|
+
|
|
1243
1270
|
const searchOrder = this.createOrder();
|
|
1244
1271
|
if (searchOrder) {
|
|
1245
1272
|
paginateItemsParams.order = searchOrder;
|
|
@@ -1280,7 +1307,7 @@ export default {
|
|
|
1280
1307
|
if (this.multiple !== true) {
|
|
1281
1308
|
for (const colmodel in this.filterMap) {
|
|
1282
1309
|
const value = this.filterMap[colmodel];
|
|
1283
|
-
if (Object.prototype.hasOwnProperty.call(this.filterMap, colmodel) && !this.
|
|
1310
|
+
if (Object.prototype.hasOwnProperty.call(this.filterMap, colmodel) && !this.hasEmptyValue(value)) {
|
|
1284
1311
|
group.rules.push({
|
|
1285
1312
|
field: colmodel,
|
|
1286
1313
|
op: 'eq',
|
|
@@ -1313,39 +1340,20 @@ export default {
|
|
|
1313
1340
|
|
|
1314
1341
|
return stringField.split('.').length > 1;
|
|
1315
1342
|
},
|
|
1316
|
-
checkItemText() {
|
|
1317
|
-
this.itemTextMultiple = Array.isArray(this.itemText);
|
|
1318
|
-
if (this.itemTextMultiple === false) {
|
|
1319
|
-
this.itemTextNested = this.checkForNestedFields(this.itemText);
|
|
1320
|
-
}
|
|
1321
|
-
},
|
|
1322
|
-
checkItemValue() {
|
|
1323
|
-
this.itemValueMultiple = Array.isArray(this.itemValue);
|
|
1324
|
-
if (this.itemValueMultiple === false) {
|
|
1325
|
-
this.itemValueNested = this.checkForNestedFields(this.itemValue);
|
|
1326
|
-
}
|
|
1327
|
-
},
|
|
1328
|
-
getSelectedItems() {
|
|
1329
|
-
for (let i = 0, length = this.itemsToSelect.length; i < length; i++) {
|
|
1330
|
-
this.selectItemById(this.itemsToSelect[i][this.itemValue] || this.itemsToSelect[i], this.itemsToSelect[i]);
|
|
1331
|
-
}
|
|
1332
|
-
this.checkSelectedItems();
|
|
1333
|
-
if (!this.isEmpty(this.modelFormMapping, this.selectedItems)) {
|
|
1334
|
-
this.replaceMapping();
|
|
1335
|
-
}
|
|
1336
|
-
},
|
|
1337
1343
|
getFilterRequest(itemsToSelect) {
|
|
1338
1344
|
const filter = {
|
|
1339
1345
|
groupOp: 'and',
|
|
1340
1346
|
rules: [],
|
|
1341
1347
|
groups: []
|
|
1342
1348
|
};
|
|
1343
|
-
|
|
1344
|
-
const
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
+
|
|
1350
|
+
const itemValuesToSearch = this.itemValueMultiple === false ? [this.itemValue] : this.itemValue;
|
|
1351
|
+
const itemsToSearch = itemsToSelect || this.itemsToSelect;
|
|
1352
|
+
|
|
1353
|
+
itemsToSearch.forEach((itemToSearch) => {
|
|
1354
|
+
itemValuesToSearch.forEach((pkProperty) => {
|
|
1355
|
+
if (itemToSearch && !this.hasEmptyValue(itemToSearch[pkProperty])) {
|
|
1356
|
+
filter.rules.push({ field: pkProperty, op: 'eq', data: itemToSearch[pkProperty] });
|
|
1349
1357
|
}
|
|
1350
1358
|
});
|
|
1351
1359
|
});
|
|
@@ -1360,11 +1368,60 @@ export default {
|
|
|
1360
1368
|
if (this.fixedFilter && !this.isDisabled) {
|
|
1361
1369
|
filter.groups.push(this.fixedFilter);
|
|
1362
1370
|
}
|
|
1371
|
+
|
|
1363
1372
|
return filter;
|
|
1364
1373
|
},
|
|
1374
|
+
getSelectedItems() {
|
|
1375
|
+
for (let i = 0, length = this.itemsToSelect.length; i < length; i++) {
|
|
1376
|
+
this.selectItemById(this.itemsToSelect[i][this.itemValue] || this.itemsToSelect[i], this.itemsToSelect[i]);
|
|
1377
|
+
}
|
|
1378
|
+
this.checkSelectedItems();
|
|
1379
|
+
if (!this.hasEmptyValue(this.modelFormMapping, this.selectedItems)) {
|
|
1380
|
+
this.replaceMapping();
|
|
1381
|
+
}
|
|
1382
|
+
},
|
|
1383
|
+
selectItemById(id) {
|
|
1384
|
+
var itemValueTemp = this.itemValue;
|
|
1385
|
+
var selectedItem;
|
|
1386
|
+
for (let index = 0, length = this.theItems.length; index < length; index++) {
|
|
1387
|
+
var item = this.theItems[index];
|
|
1388
|
+
if (this.itemValueMultiple === true) {
|
|
1389
|
+
let allPropsEqual = false;
|
|
1390
|
+
for (let i = 0, length = this.itemValue.length; i < length; i++) {
|
|
1391
|
+
if (item[this.itemValue[i]] !== id[this.itemValue[i]]) {
|
|
1392
|
+
allPropsEqual = true;
|
|
1393
|
+
break;
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
if (allPropsEqual === true) {
|
|
1397
|
+
continue;
|
|
1398
|
+
}
|
|
1399
|
+
selectedItem = this.return_object ? item : id;
|
|
1400
|
+
if (this.multiple === false) {
|
|
1401
|
+
this.selectedItems = selectedItem;
|
|
1402
|
+
} else {
|
|
1403
|
+
this.selectedItems.push(selectedItem);
|
|
1404
|
+
}
|
|
1405
|
+
//eslint-disable-next-line no-useless-return
|
|
1406
|
+
return;
|
|
1407
|
+
} else if (item[itemValueTemp] === id) {
|
|
1408
|
+
selectedItem = this.return_object ? item : id;
|
|
1409
|
+
if (this.multiple === false) {
|
|
1410
|
+
this.selectedItems = selectedItem;
|
|
1411
|
+
} else {
|
|
1412
|
+
this.selectedItems.push(selectedItem);
|
|
1413
|
+
}
|
|
1414
|
+
//eslint-disable-next-line no-useless-return
|
|
1415
|
+
return;
|
|
1416
|
+
} else if (item === id) {
|
|
1417
|
+
this.selectedItems = item;
|
|
1418
|
+
return;
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
},
|
|
1365
1422
|
getSelectedItemsFromPuiList() {
|
|
1366
1423
|
const filter = this.getFilterRequest();
|
|
1367
|
-
if (this.
|
|
1424
|
+
if (this.hasEmptyValue(filter.rules) && this.hasEmptyValue(filter.groups)) {
|
|
1368
1425
|
if (this.firstLoad) this.firstLoad = false;
|
|
1369
1426
|
return;
|
|
1370
1427
|
}
|
|
@@ -1417,7 +1474,7 @@ export default {
|
|
|
1417
1474
|
let itemsToSelectHasValue = true;
|
|
1418
1475
|
this.itemsToSelect.forEach((item) => {
|
|
1419
1476
|
itemValues.forEach((pkProperty) => {
|
|
1420
|
-
if (this.
|
|
1477
|
+
if (item && this.hasEmptyValue(item[pkProperty])) {
|
|
1421
1478
|
itemsToSelectHasValue = false;
|
|
1422
1479
|
}
|
|
1423
1480
|
});
|
|
@@ -1426,7 +1483,7 @@ export default {
|
|
|
1426
1483
|
itemsToSelectHasValue = true;
|
|
1427
1484
|
this.onPuiSelectItemsToSelect.forEach((item) => {
|
|
1428
1485
|
itemValues.forEach((pkProperty) => {
|
|
1429
|
-
if (this.
|
|
1486
|
+
if (this.hasEmptyValue(item[pkProperty])) {
|
|
1430
1487
|
itemsToSelectHasValue = false;
|
|
1431
1488
|
}
|
|
1432
1489
|
});
|
|
@@ -1437,20 +1494,22 @@ export default {
|
|
|
1437
1494
|
},
|
|
1438
1495
|
selectItems() {
|
|
1439
1496
|
this.selectedItems = this.multiple ? [] : null;
|
|
1440
|
-
if (this.multiple === true
|
|
1497
|
+
if (this.multiple === true) {
|
|
1441
1498
|
this.selectedItems = [];
|
|
1442
1499
|
}
|
|
1443
1500
|
|
|
1444
1501
|
// only for multiselect
|
|
1445
1502
|
this.setAvailableItems && this.setAvailableItems();
|
|
1446
|
-
if (this.
|
|
1503
|
+
if (this.hasEmptyValue(this.itemsToSelect)) {
|
|
1447
1504
|
return;
|
|
1448
1505
|
}
|
|
1449
|
-
|
|
1450
|
-
|
|
1506
|
+
|
|
1507
|
+
if (this.multiple === false && this.modelName) {
|
|
1508
|
+
this.getSelectedItemsFromPuiList();
|
|
1451
1509
|
} else {
|
|
1452
|
-
this
|
|
1510
|
+
this.getSelectedItems();
|
|
1453
1511
|
}
|
|
1512
|
+
|
|
1454
1513
|
this.selected = true;
|
|
1455
1514
|
},
|
|
1456
1515
|
/**
|
|
@@ -1462,7 +1521,7 @@ export default {
|
|
|
1462
1521
|
* cargará los primeros a theItems y después seleccionará
|
|
1463
1522
|
**/
|
|
1464
1523
|
checkSelectedItems() {
|
|
1465
|
-
if (this.modelName
|
|
1524
|
+
if (this.modelName) {
|
|
1466
1525
|
if (this.multiple === false) {
|
|
1467
1526
|
// si es la selección inicial y itemsToSelect no esta en theItems, por tanto no se ha seleccionado
|
|
1468
1527
|
if (this.selected === false && !this.selectedItems && this.itemsToSelect && this.itemsToSelect.length > 0) {
|
|
@@ -1490,10 +1549,10 @@ export default {
|
|
|
1490
1549
|
}
|
|
1491
1550
|
},
|
|
1492
1551
|
resetItems(newValue) {
|
|
1493
|
-
if (this.
|
|
1552
|
+
if (this.hasEmptyValue(newValue)) {
|
|
1494
1553
|
this.selectedItems = this.multiple ? [] : null;
|
|
1495
1554
|
}
|
|
1496
|
-
if (this.
|
|
1555
|
+
if (this.hasEmptyValue(this.selectedItems)) {
|
|
1497
1556
|
return;
|
|
1498
1557
|
}
|
|
1499
1558
|
let filtersValid = true;
|
|
@@ -1503,9 +1562,9 @@ export default {
|
|
|
1503
1562
|
parentPkProperty = this.filterParentMap[pkProperty];
|
|
1504
1563
|
}
|
|
1505
1564
|
if (
|
|
1506
|
-
!this.
|
|
1565
|
+
!this.hasEmptyValue(newValue[pkProperty]) &&
|
|
1507
1566
|
newValue[pkProperty] !== this.selectedItems[pkProperty] &&
|
|
1508
|
-
!this.
|
|
1567
|
+
!this.hasEmptyValue(newValue[parentPkProperty]) &&
|
|
1509
1568
|
newValue[parentPkProperty] !== this.selectedItems[pkProperty]
|
|
1510
1569
|
) {
|
|
1511
1570
|
filtersValid = false;
|
|
@@ -1555,7 +1614,7 @@ export default {
|
|
|
1555
1614
|
return true;
|
|
1556
1615
|
});
|
|
1557
1616
|
const filter = this.getFilterRequest(itemToSelect);
|
|
1558
|
-
if (this.
|
|
1617
|
+
if (this.hasEmptyValue(newSelected) && this.modelName && filter.rules.length > 0) {
|
|
1559
1618
|
const params = {
|
|
1560
1619
|
model: this.modelName,
|
|
1561
1620
|
filter: filter
|
|
@@ -1591,7 +1650,7 @@ export default {
|
|
|
1591
1650
|
}
|
|
1592
1651
|
}
|
|
1593
1652
|
},
|
|
1594
|
-
|
|
1653
|
+
hasEmptyValue(...values) {
|
|
1595
1654
|
return values.some(
|
|
1596
1655
|
(value) =>
|
|
1597
1656
|
value === undefined ||
|
|
@@ -1599,50 +1658,18 @@ export default {
|
|
|
1599
1658
|
(typeof value === 'string' && value.trim() === '') ||
|
|
1600
1659
|
(Array.isArray(value) && value.length === 0)
|
|
1601
1660
|
);
|
|
1602
|
-
}
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
this.checkItemText();
|
|
1612
|
-
this.checkItemValue();
|
|
1613
|
-
this.internalQueryFields = this.queryFields;
|
|
1614
|
-
if (this.modelName) {
|
|
1615
|
-
const theModel = this.$store.getters.getModelByName(this.modelName);
|
|
1616
|
-
this.internalController = this.controller || theModel.url.list;
|
|
1617
|
-
this.internalQueryFields = !this.isEmpty(this.queryFields) ? this.queryFields : theModel.columns?.map(c => c.name);
|
|
1618
|
-
}
|
|
1619
|
-
if (this.isMultiSelect) {
|
|
1620
|
-
this[`getItems${this.getItemsFrom}`]();
|
|
1621
|
-
} else {
|
|
1622
|
-
this.getItems();
|
|
1623
|
-
}
|
|
1624
|
-
this.subscribeEvents();
|
|
1625
|
-
},
|
|
1626
|
-
mounted() {
|
|
1627
|
-
if (this.detailComponentName) {
|
|
1628
|
-
const self = this;
|
|
1629
|
-
this.$puiEvents.$on(`pui-modalDialog-${this.detailComponentName}_${this.puiSelectId}_popup-hide`, (data) => {
|
|
1630
|
-
self.showDetailComponent = false;
|
|
1631
|
-
if (data) {
|
|
1632
|
-
const newItem = {};
|
|
1633
|
-
const itemValues = this.itemValue;
|
|
1634
|
-
itemValues.forEach((pkValue) => {
|
|
1635
|
-
newItem[pkValue] = data[pkValue];
|
|
1636
|
-
});
|
|
1637
|
-
self.itemsToSelect[0] = newItem;
|
|
1638
|
-
self.onPuiSelectItemsToSelect = [newItem];
|
|
1639
|
-
self.getSelectedItemsFromPuiList();
|
|
1661
|
+
},
|
|
1662
|
+
copySelectedItemToClipboard() {
|
|
1663
|
+
let selectedText = this.$refs.arrowUp.$el.firstChild.firstChild.firstChild.firstChild.firstChild.innerHTML;
|
|
1664
|
+
navigator.clipboard.writeText(selectedText).then(
|
|
1665
|
+
() => {
|
|
1666
|
+
// console.log('Content copied to clipboard');
|
|
1667
|
+
},
|
|
1668
|
+
() => {
|
|
1669
|
+
// console.error('Failed to copy');
|
|
1640
1670
|
}
|
|
1641
|
-
|
|
1671
|
+
);
|
|
1642
1672
|
}
|
|
1643
|
-
},
|
|
1644
|
-
beforeDestroy() {
|
|
1645
|
-
this.unsubscribeEvents();
|
|
1646
1673
|
}
|
|
1647
1674
|
};
|
|
1648
1675
|
</script>
|