intelica-library-ui 0.1.141 → 0.1.142
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.
|
@@ -2829,6 +2829,12 @@ class MultiSelectComponent {
|
|
|
2829
2829
|
selectedOptions = [];
|
|
2830
2830
|
onChangeFn = () => { };
|
|
2831
2831
|
onTouchedFn = () => { };
|
|
2832
|
+
ngAfterViewInit() {
|
|
2833
|
+
if (this.options.some(option => typeof option !== "object")) {
|
|
2834
|
+
this.optionValue = undefined;
|
|
2835
|
+
this.optionLabel = undefined;
|
|
2836
|
+
}
|
|
2837
|
+
}
|
|
2832
2838
|
writeValue(value) {
|
|
2833
2839
|
this.selectedOptions = value || [];
|
|
2834
2840
|
this.checked = this.selectedOptions.length === this.options.length;
|
|
@@ -2843,13 +2849,20 @@ class MultiSelectComponent {
|
|
|
2843
2849
|
/* opcional: implementar si necesitas deshabilitar el componente desde ngModel */
|
|
2844
2850
|
}
|
|
2845
2851
|
toggleAllSelection(event) {
|
|
2846
|
-
|
|
2852
|
+
if (!event.checked) {
|
|
2853
|
+
this.selectedOptions = [];
|
|
2854
|
+
}
|
|
2855
|
+
else {
|
|
2856
|
+
this.options.map(option => option[this.optionValue]);
|
|
2857
|
+
if (this.options.some(option => typeof option !== "object")) {
|
|
2858
|
+
this.selectedOptions = this.options;
|
|
2859
|
+
}
|
|
2860
|
+
}
|
|
2847
2861
|
this.emitChangeEvent();
|
|
2848
2862
|
this.onChangeFn(this.selectedOptions);
|
|
2849
2863
|
this.onTouchedFn();
|
|
2850
2864
|
}
|
|
2851
2865
|
onChangeSelect(event) {
|
|
2852
|
-
console.log("onChange -> ", event);
|
|
2853
2866
|
this.checked = this.selectedOptions.length === this.options.length;
|
|
2854
2867
|
this.emitChangeEvent();
|
|
2855
2868
|
this.onChangeFn(this.selectedOptions);
|