datagrid menu refactor

This commit is contained in:
Jan Prochazka
2021-04-07 21:41:10 +02:00
parent 1c0c2bbc71
commit bcc1f91352
3 changed files with 23 additions and 24 deletions

View File

@@ -34,6 +34,7 @@
keyText: command.keyText || command.keyTextFromGroup,
onClick: command.onClick,
disabled: !command.enabled,
hideDisabled: item.hideDisabled,
};
}
return null;
@@ -69,6 +70,8 @@
});
$: extracted = extractMenuItems(items);
$: compacted = _.compact(extracted.map(x => mapItem(x, $commands)));
$: filtered = compacted.filter(x => !x.disabled || !x.hideDisabled);
</script>
<ul
@@ -77,7 +80,7 @@
on:clickOutside={() => dispatch('close')}
bind:this={element}
>
{#each _.compact(extracted.map(x => mapItem(x, $commands))) as item}
{#each filtered as item}
{#if item.divider}
<li class="divider" />
{:else}