sql generator

This commit is contained in:
Jan Prochazka 2021-04-01 10:48:20 +02:00
parent d6ba822338
commit a3762c6caa
6 changed files with 30 additions and 5 deletions

View File

@ -19,6 +19,7 @@
export let menu = undefined;
export let expandIcon = undefined;
export let checkedObjectsStore = null;
export let disableContextMenu = false;
$: isChecked = checkedObjectsStore && $checkedObjectsStore.find(x => module.extractKey(data) == module.extractKey(x));
@ -52,7 +53,7 @@
class:isBold
draggable={true}
on:click={handleClick}
use:contextMenu={menu}
use:contextMenu={disableContextMenu ? null : menu}
on:dragstart={e => {
e.dataTransfer.setData('app_object_drag_data', JSON.stringify(data));
}}

View File

@ -12,6 +12,7 @@
export let items;
export let module;
export let checkedObjectsStore = null;
export let disableContextMenu = false;
let isExpanded = true;
@ -52,7 +53,14 @@
{/if}
{#each filtered as item (module.extractKey(item.data))}
<AppObjectListItem {...$$restProps} {module} data={item.data} {checkedObjectsStore} on:objectClick />
<AppObjectListItem
{...$$restProps}
{module}
data={item.data}
{checkedObjectsStore}
on:objectClick
{disableContextMenu}
/>
{/each}
{/if}

View File

@ -12,6 +12,7 @@
export let filter;
export let expandIconFunc = undefined;
export let checkedObjectsStore = null;
export let disableContextMenu = false;
export let groupFunc = undefined;
@ -46,6 +47,7 @@
{subItemsComponent}
{checkedObjectsStore}
{groupFunc}
{disableContextMenu}
/>
{/each}
{:else}
@ -59,6 +61,7 @@
on:objectClick
{expandIconFunc}
{checkedObjectsStore}
{disableContextMenu}
/>
{/each}
{/if}

View File

@ -17,6 +17,7 @@
export let isExpandable = undefined;
export let expandIconFunc = plusExpandIcon;
export let checkedObjectsStore = null;
export let disableContextMenu = false;
let isExpanded = false;
@ -44,6 +45,7 @@
expandIcon={getExpandIcon(expandable, subItemsComponent, isExpanded, expandIconFunc)}
{checkedObjectsStore}
{module}
{disableContextMenu}
/>
{#if isExpanded && subItemsComponent}

View File

@ -131,6 +131,10 @@
<ModalBase {...$$restProps} fullScreen>
<svelte:fragment slot="header">
SQL Generator
<span class="dbname">
<FontIcon icon="icon database" />
{database}
</span>
{#if busy}
<FontIcon icon="icon loading" />
{/if}
@ -151,6 +155,7 @@
groupFunc={data => _.startCase(data.objectTypeField)}
isExpandable={data => data.objectTypeField == 'tables' || data.objectTypeField == 'views'}
filter={objectsFilter}
disableContextMenu
{checkedObjectsStore}
/>
</WidgetsInnerContainer>
@ -245,4 +250,8 @@
margin: 5px;
margin-top: 20px;
}
.dbname {
color: var(--theme-font-3);
}
</style>

View File

@ -5,9 +5,11 @@ export default function contextMenu(node, items) {
const handleContextMenu = e => {
e.preventDefault();
e.stopPropagation();
const left = e.pageX;
const top = e.pageY;
currentDropDownMenu.set({ left, top, items: _.isFunction(items) ? items() : items });
if (items) {
const left = e.pageX;
const top = e.pageY;
currentDropDownMenu.set({ left, top, items: _.isFunction(items) ? items() : items });
}
};
node.addEventListener('contextmenu', handleContextMenu);