dbgate/packages/web/src/designer/QueryDesigner.svelte

53 lines
1.8 KiB
Svelte
Raw Normal View History

2021-03-18 12:57:50 +00:00
<script lang="ts">
2022-08-27 08:42:58 +00:00
import _ from 'lodash';
2021-03-18 12:57:50 +00:00
import Designer from './Designer.svelte';
2022-08-27 08:42:58 +00:00
import { isConnectedByReference, referenceIsConnecting } from './designerTools';
2022-01-06 08:24:32 +00:00
import QueryDesignerReference from './QueryDesignerReference.svelte';
2021-03-18 12:57:50 +00:00
</script>
2022-01-05 13:58:27 +00:00
<Designer
{...$$props}
settings={{
showTableCloseButton: true,
allowColumnOperations: true,
allowCreateRefByDrag: true,
allowTableAlias: true,
2022-01-06 07:58:26 +00:00
allowScrollColumns: true,
canSelectColumns: true,
2022-08-27 08:42:58 +00:00
referenceMenu: ({ designer, reference, onChangeReference, onRemoveReference }) => {
const isConnected = isConnectedByReference(
designer,
{ designerId: reference?.sourceId },
{ designerId: reference?.targetId },
reference
);
const setJoinType = joinType => {
onChangeReference({
...reference,
joinType,
});
};
return [
{ text: 'Remove', onClick: () => onRemoveReference(reference) },
!isConnected && [
{ divider: true },
{ onClick: () => setJoinType('INNER JOIN'), text: 'Set INNER JOIN' },
{ onClick: () => setJoinType('LEFT JOIN'), text: 'Set LEFT JOIN' },
{ onClick: () => setJoinType('RIGHT JOIN'), text: 'Set RIGHT JOIN' },
{ onClick: () => setJoinType('FULL OUTER JOIN'), text: 'Set FULL OUTER JOIN' },
{ onClick: () => setJoinType('CROSS JOIN'), text: 'Set CROSS JOIN' },
{ onClick: () => setJoinType('WHERE EXISTS'), text: 'Set WHERE EXISTS' },
{ onClick: () => setJoinType('WHERE NOT EXISTS'), text: 'Set WHERE NOT EXISTS' },
],
];
},
createReferenceText: reference =>
_.snakeCase(reference?.joinType || 'CROSS JOIN')
.replace('_', '\xa0')
.replace('_', '\xa0'),
2022-01-05 13:58:27 +00:00
}}
2022-01-06 08:24:32 +00:00
referenceComponent={QueryDesignerReference}
2022-01-05 13:58:27 +00:00
/>