mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 13:06:01 +00:00
68 lines
1.7 KiB
Svelte
68 lines
1.7 KiB
Svelte
<script>
|
|
import _ from 'lodash';
|
|
import AppObjectGroup from './AppObjectGroup.svelte';
|
|
|
|
import AppObjectListItem from './AppObjectListItem.svelte';
|
|
|
|
export let list;
|
|
export let module;
|
|
export let subItemsComponent = undefined;
|
|
export let expandOnClick = false;
|
|
export let isExpandable = undefined;
|
|
export let filter;
|
|
export let expandIconFunc = undefined;
|
|
export let checkedObjectsStore = null;
|
|
export let disableContextMenu = false;
|
|
|
|
export let groupFunc = undefined;
|
|
|
|
$: filtered = list.filter(data => {
|
|
const matcher = module.createMatcher && module.createMatcher(data);
|
|
if (matcher && !matcher(filter)) return false;
|
|
return true;
|
|
});
|
|
|
|
$: listGrouped = groupFunc
|
|
? _.compact(
|
|
(list || []).map(data => {
|
|
const matcher = module.createMatcher && module.createMatcher(data);
|
|
const isMatched = matcher && !matcher(filter) ? false : true;
|
|
const group = groupFunc(data);
|
|
return { group, data, isMatched };
|
|
})
|
|
)
|
|
: null;
|
|
|
|
$: groups = groupFunc ? _.groupBy(listGrouped, 'group') : null;
|
|
</script>
|
|
|
|
{#if groupFunc}
|
|
{#each _.keys(groups) as group (group)}
|
|
<AppObjectGroup
|
|
{group}
|
|
{module}
|
|
items={groups[group]}
|
|
{expandIconFunc}
|
|
{isExpandable}
|
|
{subItemsComponent}
|
|
{checkedObjectsStore}
|
|
{groupFunc}
|
|
{disableContextMenu}
|
|
/>
|
|
{/each}
|
|
{:else}
|
|
{#each filtered as data (module.extractKey(data))}
|
|
<AppObjectListItem
|
|
{module}
|
|
{subItemsComponent}
|
|
{expandOnClick}
|
|
{data}
|
|
{isExpandable}
|
|
on:objectClick
|
|
{expandIconFunc}
|
|
{checkedObjectsStore}
|
|
{disableContextMenu}
|
|
/>
|
|
{/each}
|
|
{/if}
|