intelica-library-ui 0.1.209 → 0.1.210
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.
|
@@ -1552,6 +1552,66 @@ class SharedService {
|
|
|
1552
1552
|
};
|
|
1553
1553
|
return filterRecursive(listTempAll, true, false);
|
|
1554
1554
|
}
|
|
1555
|
+
GetFilteredSearchMultipleKeysRecursive(listTempAll, keys, value, operatorId, searchOnlyParent = true) {
|
|
1556
|
+
if (!value || value.length === 0)
|
|
1557
|
+
return listTempAll;
|
|
1558
|
+
if (!listTempAll || !keys || keys.length === 0)
|
|
1559
|
+
return [];
|
|
1560
|
+
value = value.toString().toLowerCase();
|
|
1561
|
+
const words = value.includes("&") ? value.split("&").filter(Boolean) : [value];
|
|
1562
|
+
const matchesFilter = (item) => {
|
|
1563
|
+
// Verificar si coincide en CUALQUIERA de los campos
|
|
1564
|
+
return keys.some(key => {
|
|
1565
|
+
const itemValue = item[key]?.toString()?.toLowerCase();
|
|
1566
|
+
switch (operatorId) {
|
|
1567
|
+
case 0: // 'Contains'
|
|
1568
|
+
return words.every((word) => itemValue?.includes(word));
|
|
1569
|
+
case 1: // 'Exact'
|
|
1570
|
+
return itemValue === value;
|
|
1571
|
+
case 2: // 'Begin'
|
|
1572
|
+
return itemValue?.startsWith(value);
|
|
1573
|
+
case 3: // 'Ends'
|
|
1574
|
+
return itemValue?.endsWith(value);
|
|
1575
|
+
default:
|
|
1576
|
+
return itemValue?.includes(value);
|
|
1577
|
+
}
|
|
1578
|
+
});
|
|
1579
|
+
};
|
|
1580
|
+
const filterRecursive = (items, isTopLevel = true, parentMatched = false) => {
|
|
1581
|
+
const result = [];
|
|
1582
|
+
for (const item of items) {
|
|
1583
|
+
const currentMatches = matchesFilter(item);
|
|
1584
|
+
if (parentMatched) {
|
|
1585
|
+
result.push({ ...item });
|
|
1586
|
+
continue;
|
|
1587
|
+
}
|
|
1588
|
+
if (currentMatches) {
|
|
1589
|
+
if (searchOnlyParent) {
|
|
1590
|
+
result.push({ ...item });
|
|
1591
|
+
}
|
|
1592
|
+
else {
|
|
1593
|
+
const itemCopy = { ...item };
|
|
1594
|
+
if (itemCopy.children && Array.isArray(itemCopy.children) && itemCopy.children.length > 0) {
|
|
1595
|
+
itemCopy.children = filterRecursive(itemCopy.children, false, true);
|
|
1596
|
+
}
|
|
1597
|
+
result.push(itemCopy);
|
|
1598
|
+
}
|
|
1599
|
+
continue;
|
|
1600
|
+
}
|
|
1601
|
+
if (!searchOnlyParent && item.children && Array.isArray(item.children) && item.children.length > 0) {
|
|
1602
|
+
const filteredChildren = filterRecursive(item.children, false, false);
|
|
1603
|
+
if (filteredChildren.length > 0) {
|
|
1604
|
+
result.push({
|
|
1605
|
+
...item,
|
|
1606
|
+
children: filteredChildren
|
|
1607
|
+
});
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
return result;
|
|
1612
|
+
};
|
|
1613
|
+
return filterRecursive(listTempAll, true, false);
|
|
1614
|
+
}
|
|
1555
1615
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: SharedService, deps: [{ token: i1.Location }, { token: TermPipe }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1556
1616
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: SharedService, providedIn: "root" });
|
|
1557
1617
|
}
|
|
@@ -2755,7 +2815,13 @@ class TreeTableComponent {
|
|
|
2755
2815
|
let searchOption = this.ListSearchOptions.find((item) => item.id === this.SearchInput.fieldId);
|
|
2756
2816
|
let searchValue = searchOption?.field || "code";
|
|
2757
2817
|
let searchOnlyParent = searchOption?.searchOnlyParent ?? true;
|
|
2758
|
-
|
|
2818
|
+
if (searchValue.includes(',')) {
|
|
2819
|
+
const fields = searchValue.split(',').map((f) => f.trim());
|
|
2820
|
+
this.ListDataFilter = this.SharedService.GetFilteredSearchMultipleKeysRecursive([...this.ListData], fields, Search, this.SearchInput.operatorId, searchOnlyParent);
|
|
2821
|
+
}
|
|
2822
|
+
else {
|
|
2823
|
+
this.ListDataFilter = this.SharedService.GetFilteredSearchKeyRecursive([...this.ListData], searchValue, Search, this.SearchInput.operatorId, searchOnlyParent);
|
|
2824
|
+
}
|
|
2759
2825
|
if (this.PaginatorTable) {
|
|
2760
2826
|
this.PaginatorTable.CurrentPage = 1;
|
|
2761
2827
|
this.CurrentPage = 1;
|