@fuentis/phoenix-ui 0.0.9-alpha.584 → 0.0.9-alpha.585
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.
|
@@ -2042,9 +2042,13 @@ class TableCaptionComponent {
|
|
|
2042
2042
|
const t = f.type ?? 'text';
|
|
2043
2043
|
// We DO NOT store null for multiselect (we store []),
|
|
2044
2044
|
// because null is the common cause of "everything selected" / broken filtering.
|
|
2045
|
-
const initialValue = t === 'multiselect'
|
|
2046
|
-
|
|
2047
|
-
|
|
2045
|
+
const initialValue = t === 'boolean-multiselect'
|
|
2046
|
+
? this.normalizeBooleanMultiInitial(f.selected)
|
|
2047
|
+
: t === 'multiselect'
|
|
2048
|
+
? this.normalizeMultiInitial(f.selected)
|
|
2049
|
+
: t === 'checkbox'
|
|
2050
|
+
? !!f.selected
|
|
2051
|
+
: f.selected ?? '';
|
|
2048
2052
|
fg.addControl(f.key, this.fb.control(initialValue));
|
|
2049
2053
|
}
|
|
2050
2054
|
this.filtersForm = fg;
|
|
@@ -2096,6 +2100,22 @@ class TableCaptionComponent {
|
|
|
2096
2100
|
return [];
|
|
2097
2101
|
return Array.isArray(selected) ? selected : [selected];
|
|
2098
2102
|
}
|
|
2103
|
+
normalizeBooleanMultiInitial(selected) {
|
|
2104
|
+
if (selected == null)
|
|
2105
|
+
return [];
|
|
2106
|
+
const arr = Array.isArray(selected) ? selected : [selected];
|
|
2107
|
+
return arr
|
|
2108
|
+
.map((x) => {
|
|
2109
|
+
if (typeof x === 'boolean')
|
|
2110
|
+
return x;
|
|
2111
|
+
if (typeof x === 'string')
|
|
2112
|
+
return x === 'true';
|
|
2113
|
+
if (x && typeof x === 'object')
|
|
2114
|
+
return x.key === true || x.key === 'true';
|
|
2115
|
+
return null;
|
|
2116
|
+
})
|
|
2117
|
+
.filter((x) => typeof x === 'boolean');
|
|
2118
|
+
}
|
|
2099
2119
|
/**
|
|
2100
2120
|
* Emit only meaningful values:
|
|
2101
2121
|
* - text: '' removed
|
|
@@ -2112,6 +2132,12 @@ class TableCaptionComponent {
|
|
|
2112
2132
|
continue;
|
|
2113
2133
|
const t = f.type ?? 'text';
|
|
2114
2134
|
const v = raw[key];
|
|
2135
|
+
if (t === 'boolean-multiselect') {
|
|
2136
|
+
const arr = this.normalizeBooleanMultiInitial(v);
|
|
2137
|
+
if (arr.length)
|
|
2138
|
+
out[key] = arr; // boolean[]
|
|
2139
|
+
continue;
|
|
2140
|
+
}
|
|
2115
2141
|
if (t === 'multiselect') {
|
|
2116
2142
|
const arr = Array.isArray(v) ? v.filter((x) => x != null && x !== '') : [];
|
|
2117
2143
|
if (arr.length)
|
|
@@ -2150,15 +2176,23 @@ class TableCaptionComponent {
|
|
|
2150
2176
|
}
|
|
2151
2177
|
// ensure multiselect never becomes null
|
|
2152
2178
|
for (const f of cfg) {
|
|
2153
|
-
|
|
2179
|
+
const t = f.type ?? 'text';
|
|
2180
|
+
if (t === 'boolean-multiselect') {
|
|
2181
|
+
patch[f.key] = this.normalizeBooleanMultiInitial(patch[f.key]);
|
|
2182
|
+
continue;
|
|
2183
|
+
}
|
|
2184
|
+
if (t === 'multiselect') {
|
|
2154
2185
|
const val = patch[f.key];
|
|
2155
2186
|
if (val == null)
|
|
2156
2187
|
patch[f.key] = [];
|
|
2157
2188
|
else if (!Array.isArray(val))
|
|
2158
2189
|
patch[f.key] = [val];
|
|
2190
|
+
continue;
|
|
2159
2191
|
}
|
|
2160
|
-
if (
|
|
2192
|
+
if (t === 'checkbox') {
|
|
2161
2193
|
patch[f.key] = !!patch[f.key];
|
|
2194
|
+
continue;
|
|
2195
|
+
}
|
|
2162
2196
|
}
|
|
2163
2197
|
this.filtersForm.patchValue(patch, { emitEvent: false });
|
|
2164
2198
|
}
|