mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-27 04:25:59 +00:00
perspective context menu
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let width;
|
export let width;
|
||||||
|
export let isFlex;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div style={`max-width: ${width}px`}>
|
<div style={`max-width: ${width}px`} class:isFlex>
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -12,4 +13,8 @@
|
|||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.isFlex {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
import ManagerInnerContainer from '../elements/ManagerInnerContainer.svelte';
|
import ManagerInnerContainer from '../elements/ManagerInnerContainer.svelte';
|
||||||
|
import FontIcon from '../icons/FontIcon.svelte';
|
||||||
import PerspectiveFiltersColumn from './PerspectiveFiltersColumn.svelte';
|
import PerspectiveFiltersColumn from './PerspectiveFiltersColumn.svelte';
|
||||||
|
|
||||||
export let managerSize;
|
export let managerSize;
|
||||||
@@ -13,26 +14,41 @@
|
|||||||
$: allFilterNames = _.keys(config.filterInfos || {});
|
$: allFilterNames = _.keys(config.filterInfos || {});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ManagerInnerContainer width={managerSize}>
|
<ManagerInnerContainer width={managerSize} isFlex={allFilterNames.length == 0}>
|
||||||
{#each allFilterNames as uniqueName}
|
{#if allFilterNames.length == 0}
|
||||||
<PerspectiveFiltersColumn
|
<div class="msg">
|
||||||
filterInfo={config.filterInfos[uniqueName]}
|
<div class="mb-3 bold">No Filters defined</div>
|
||||||
{uniqueName}
|
<div><FontIcon icon="img info" /> Use context menu, command "Add to filter" in table or in tree</div>
|
||||||
filter={config.filters[uniqueName]}
|
</div>
|
||||||
onSetFilter={value =>
|
{:else}
|
||||||
setConfig(cfg => ({
|
{#each allFilterNames as uniqueName}
|
||||||
...cfg,
|
<PerspectiveFiltersColumn
|
||||||
filters: {
|
filterInfo={config.filterInfos[uniqueName]}
|
||||||
...cfg.filters,
|
{uniqueName}
|
||||||
[uniqueName]: value,
|
filter={config.filters[uniqueName]}
|
||||||
},
|
onSetFilter={value =>
|
||||||
}))}
|
setConfig(cfg => ({
|
||||||
onRemoveFilter={value =>
|
...cfg,
|
||||||
setConfig(cfg => ({
|
filters: {
|
||||||
...cfg,
|
...cfg.filters,
|
||||||
filters: _.omit(cfg.filters, [uniqueName]),
|
[uniqueName]: value,
|
||||||
filterInfos: _.omit(cfg.filterInfos, [uniqueName]),
|
},
|
||||||
}))}
|
}))}
|
||||||
/>
|
onRemoveFilter={value =>
|
||||||
{/each}
|
setConfig(cfg => ({
|
||||||
|
...cfg,
|
||||||
|
filters: _.omit(cfg.filters, [uniqueName]),
|
||||||
|
filterInfos: _.omit(cfg.filterInfos, [uniqueName]),
|
||||||
|
}))}
|
||||||
|
/>
|
||||||
|
{/each}
|
||||||
|
{/if}
|
||||||
</ManagerInnerContainer>
|
</ManagerInnerContainer>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.msg {
|
||||||
|
background: var(--theme-bg-1);
|
||||||
|
flex: 1;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -9,8 +9,6 @@
|
|||||||
export let config: PerspectiveConfig;
|
export let config: PerspectiveConfig;
|
||||||
export let setConfig: ChangePerspectiveConfigFunc;
|
export let setConfig: ChangePerspectiveConfigFunc;
|
||||||
|
|
||||||
let mouseIn;
|
|
||||||
|
|
||||||
$: parentUniqueName = column.dataNode?.parentNode?.uniqueName || '';
|
$: parentUniqueName = column.dataNode?.parentNode?.uniqueName || '';
|
||||||
$: uniqueName = column.dataNode.uniqueName;
|
$: uniqueName = column.dataNode.uniqueName;
|
||||||
$: order = config.sort?.[parentUniqueName]?.find(x => x.uniqueName == uniqueName)?.order;
|
$: order = config.sort?.[parentUniqueName]?.find(x => x.uniqueName == uniqueName)?.order;
|
||||||
@@ -20,54 +18,6 @@
|
|||||||
: -1;
|
: -1;
|
||||||
$: isSortDefined = config.sort?.[parentUniqueName]?.length > 0;
|
$: isSortDefined = config.sort?.[parentUniqueName]?.length > 0;
|
||||||
|
|
||||||
const setSort = order => {
|
|
||||||
setConfig(
|
|
||||||
cfg => ({
|
|
||||||
...cfg,
|
|
||||||
sort: {
|
|
||||||
...cfg.sort,
|
|
||||||
[parentUniqueName]: [{ uniqueName, order }],
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
true
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const addToSort = order => {
|
|
||||||
setConfig(
|
|
||||||
cfg => ({
|
|
||||||
...cfg,
|
|
||||||
sort: {
|
|
||||||
...cfg.sort,
|
|
||||||
[parentUniqueName]: [...(cfg.sort?.[parentUniqueName] || []), { uniqueName, order }],
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
true
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const clearSort = () => {
|
|
||||||
setConfig(
|
|
||||||
cfg => ({
|
|
||||||
...cfg,
|
|
||||||
sort: {
|
|
||||||
...cfg.sort,
|
|
||||||
[parentUniqueName]: [],
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
true
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
function getMenu() {
|
|
||||||
return [
|
|
||||||
{ onClick: () => setSort('ASC'), text: 'Sort ascending' },
|
|
||||||
{ onClick: () => setSort('DESC'), text: 'Sort descending' },
|
|
||||||
isSortDefined && !order && { onClick: () => addToSort('ASC'), text: 'Add to sort - ascending' },
|
|
||||||
isSortDefined && !order && { onClick: () => addToSort('DESC'), text: 'Add to sort - descending' },
|
|
||||||
order && { onClick: () => clearSort(), text: 'Clear sort criteria' },
|
|
||||||
];
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if column.isVisible(columnLevel)}
|
{#if column.isVisible(columnLevel)}
|
||||||
@@ -75,8 +25,6 @@
|
|||||||
rowspan={column.rowSpan}
|
rowspan={column.rowSpan}
|
||||||
class="columnHeader"
|
class="columnHeader"
|
||||||
data-column={column.columnIndex}
|
data-column={column.columnIndex}
|
||||||
on:mouseenter={() => (mouseIn = true)}
|
|
||||||
on:mouseleave={() => (mouseIn = false)}
|
|
||||||
>
|
>
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<div class="label">
|
<div class="label">
|
||||||
@@ -100,12 +48,6 @@
|
|||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if mouseIn}
|
|
||||||
<div class="menuButton">
|
|
||||||
<DropDownButton menu={getMenu} narrow />
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
</th>
|
</th>
|
||||||
{/if}
|
{/if}
|
||||||
{#if column.showParent(columnLevel)}
|
{#if column.showParent(columnLevel)}
|
||||||
@@ -116,11 +58,6 @@
|
|||||||
.wrap {
|
.wrap {
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
.menuButton {
|
|
||||||
position: absolute;
|
|
||||||
right: 0;
|
|
||||||
bottom: 0;
|
|
||||||
}
|
|
||||||
.label {
|
.label {
|
||||||
flex-wrap: nowrap;
|
flex-wrap: nowrap;
|
||||||
}
|
}
|
||||||
@@ -143,12 +80,6 @@
|
|||||||
align-self: center;
|
align-self: center;
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
}
|
}
|
||||||
/* .resizer {
|
|
||||||
background-color: var(--theme-border);
|
|
||||||
width: 2px;
|
|
||||||
cursor: col-resize;
|
|
||||||
z-index: 1;
|
|
||||||
} */
|
|
||||||
.grouping {
|
.grouping {
|
||||||
color: var(--theme-font-alt);
|
color: var(--theme-font-alt);
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { ChangePerspectiveConfigFunc, PerspectiveConfig, PerspectiveTreeNode } from 'dbgate-datalib';
|
import { ChangePerspectiveConfigFunc, PerspectiveConfig, PerspectiveTreeNode } from 'dbgate-datalib';
|
||||||
|
import _ from 'lodash';
|
||||||
import { showModal } from '../modals/modalTools';
|
import { showModal } from '../modals/modalTools';
|
||||||
import CustomJoinModal from './CustomJoinModal.svelte';
|
import CustomJoinModal from './CustomJoinModal.svelte';
|
||||||
|
|
||||||
@@ -15,7 +16,63 @@ export function getPerspectiveNodeMenu(props: PerspectiveNodeMenuProps) {
|
|||||||
const { node, conid, database, root, config, setConfig } = props;
|
const { node, conid, database, root, config, setConfig } = props;
|
||||||
const customJoin = node.customJoinConfig;
|
const customJoin = node.customJoinConfig;
|
||||||
const filterInfo = node.filterInfo;
|
const filterInfo = node.filterInfo;
|
||||||
|
|
||||||
|
const parentUniqueName = node?.parentNode?.uniqueName || '';
|
||||||
|
const uniqueName = node.uniqueName;
|
||||||
|
const order = config.sort?.[parentUniqueName]?.find(x => x.uniqueName == uniqueName)?.order;
|
||||||
|
const orderIndex =
|
||||||
|
config.sort?.[parentUniqueName]?.length > 1
|
||||||
|
? _.findIndex(config.sort?.[parentUniqueName], x => x.uniqueName == uniqueName)
|
||||||
|
: -1;
|
||||||
|
const isSortDefined = config.sort?.[parentUniqueName]?.length > 0;
|
||||||
|
|
||||||
|
const setSort = order => {
|
||||||
|
setConfig(
|
||||||
|
cfg => ({
|
||||||
|
...cfg,
|
||||||
|
sort: {
|
||||||
|
...cfg.sort,
|
||||||
|
[parentUniqueName]: [{ uniqueName, order }],
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const addToSort = order => {
|
||||||
|
setConfig(
|
||||||
|
cfg => ({
|
||||||
|
...cfg,
|
||||||
|
sort: {
|
||||||
|
...cfg.sort,
|
||||||
|
[parentUniqueName]: [...(cfg.sort?.[parentUniqueName] || []), { uniqueName, order }],
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const clearSort = () => {
|
||||||
|
setConfig(
|
||||||
|
cfg => ({
|
||||||
|
...cfg,
|
||||||
|
sort: {
|
||||||
|
...cfg.sort,
|
||||||
|
[parentUniqueName]: [],
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
{ onClick: () => setSort('ASC'), text: 'Sort ascending' },
|
||||||
|
{ onClick: () => setSort('DESC'), text: 'Sort descending' },
|
||||||
|
isSortDefined && !order && { onClick: () => addToSort('ASC'), text: 'Add to sort - ascending' },
|
||||||
|
isSortDefined && !order && { onClick: () => addToSort('DESC'), text: 'Add to sort - descending' },
|
||||||
|
order && { onClick: () => clearSort(), text: 'Clear sort criteria' },
|
||||||
|
{ divider: true },
|
||||||
|
|
||||||
filterInfo && {
|
filterInfo && {
|
||||||
text: 'Add to filter',
|
text: 'Add to filter',
|
||||||
onClick: () =>
|
onClick: () =>
|
||||||
|
|||||||
Reference in New Issue
Block a user