refactor - not working

This commit is contained in:
SPRINX0\prochazka
2024-12-16 15:53:52 +01:00
parent 7e1ceb69ae
commit 358a641449
2 changed files with 16 additions and 16 deletions

View File

@@ -36,9 +36,19 @@
$: matcher = module.createMatcher && module.createMatcher(filter, passProps?.searchSettings); $: matcher = module.createMatcher && module.createMatcher(filter, passProps?.searchSettings);
$: childMatcher = module.createChildMatcher && module.createChildMatcher(filter, passProps?.searchSettings); $: childMatcher = module.createChildMatcher && module.createChildMatcher(filter, passProps?.searchSettings);
$: filtered = !groupFunc ? list.filter(data => !matcher || matcher(data)) : null; $: dataLabeled = _.compact(
(list || []).map(data => {
const isMatched = !matcher || matcher(data);
const isChildMatched =
module.disableShowChildrenWithParentMatch && isMatched ? false : !childMatcher || childMatcher(data);
const group = groupFunc ? groupFunc(data) : undefined;
return { group, data, isMatched, isChildMatched };
})
);
$: childrenMatched = !groupFunc ? list.filter(data => !childMatcher || childMatcher(data)) : null; $: filtered = dataLabeled.filter(x => x.isMatched).map(x => x.data);
$: childrenMatched = dataLabeled.filter(x => x.isChildMatched).map(x => x.data);
// let filtered = []; // let filtered = [];
@@ -54,17 +64,6 @@
// } // }
// } // }
$: listGrouped = groupFunc
? _.compact(
(list || []).map(data => {
const isMatched = !matcher || matcher(data);
const isChildMatched = !childMatcher || childMatcher(data);
const group = groupFunc(data);
return { group, data, isMatched, isChildMatched };
})
)
: null;
function extendGroups(base, emptyList) { function extendGroups(base, emptyList) {
const res = { const res = {
...base, ...base,
@@ -76,10 +75,9 @@
return res; return res;
} }
$: groups = groupFunc ? extendGroups(_.groupBy(listGrouped, 'group'), emptyGroupNames) : null; $: groups = groupFunc ? extendGroups(_.groupBy(dataLabeled, 'group'), emptyGroupNames) : null;
$: listLimited = $: listLimited = isExpandedBySearch && !expandLimited ? filtered.slice(0, Math.min(filter.trim().length, 3)) : list;
isExpandedBySearch && !expandLimited ? filtered.slice(0, Math.min(filter.trim().length, 3)) : list;
$: isListLimited = isExpandedBySearch && listLimited.length < filtered.length; $: isListLimited = isExpandedBySearch && listLimited.length < filtered.length;
</script> </script>

View File

@@ -44,6 +44,8 @@
return res; return res;
}; };
export const disableShowChildrenWithParentMatch = true;
export const createTitle = ({ schemaName, pureName }) => (schemaName ? `${schemaName}.${pureName}` : pureName); export const createTitle = ({ schemaName, pureName }) => (schemaName ? `${schemaName}.${pureName}` : pureName);
export const databaseObjectIcons = { export const databaseObjectIcons = {