Merge pull request #520 from dyaskur/master

add copy shortcut and default copy type setting
This commit is contained in:
Fabio Di Stasio 2023-01-16 18:16:13 +01:00 committed by GitHub
commit 5624b3b2d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 61 additions and 7 deletions

View File

@ -210,6 +210,28 @@
</div>
</div>
</div>
<div class="column col-12 h6 mt-4 text-uppercase mb-1">
{{ t('word.resultsTable') }}
</div>
<div class="column col-12 col-sm-12 columns">
<div class="form-group column col-12">
<div class="col-5 col-sm-12">
<label class="form-label">
{{ t('message.defaultCopyType') }}
</label>
</div>
<div class="col-3 col-sm-12">
<BaseSelect
v-model="defaultCopyType"
class="form-select"
:options="copyTypes"
option-track-by="code"
option-label="name"
@change="changeDefaultCopyType(defaultCopyType)"
/>
</div>
</div>
</div>
</form>
</div>
</div>
@ -393,6 +415,7 @@ const {
autoComplete: selectedAutoComplete,
lineWrap: selectedLineWrap,
executeSelected: selectedExecuteSelected,
defaultCopyType: selectedCopyType,
notificationsTimeout,
restoreTabs,
disableBlur,
@ -416,7 +439,8 @@ const {
changeApplicationTheme,
changeEditorTheme,
changeEditorFontSize,
updateNotificationsTimeout
updateNotificationsTimeout,
changeDefaultCopyType
} = settingsStore;
const {
hideSettingModal: closeModal,
@ -448,6 +472,7 @@ ORDER BY
`;
const localLocale: Ref<AvailableLocale> = ref(null);
const defaultCopyType: Ref<string> = ref(null);
const localPageSize: Ref<number> = ref(null);
const localTimeout: Ref<number> = ref(null);
const localEditorTheme: Ref<string> = ref(null);
@ -511,6 +536,14 @@ const locales = computed(() => {
return locales;
});
const copyTypes = computed(() => [
{ code: 'cell', name: t('word.cell') },
{ code: 'html', name: t('word.table') },
{ code: 'json', name: 'JSON' },
{ code: 'csv', name: 'CSV' },
{ code: 'sql', name: 'SQL insert' }
]);
const hasUpdates = computed(() => ['available', 'downloading', 'downloaded', 'link'].includes(updateStatus.value));
const workspace = computed(() => {
@ -570,6 +603,7 @@ const toggleExecuteSelected = () => {
};
localLocale.value = selectedLocale.value;
defaultCopyType.value = selectedCopyType.value;
localPageSize.value = pageSize.value as number;
localTimeout.value = notificationsTimeout.value as number;
localEditorTheme.value = editorTheme.value as string;

View File

@ -142,7 +142,7 @@ const settingsStore = useSettingsStore();
const consoleStore = useConsoleStore();
const { getWorkspace } = useWorkspacesStore();
const { dataTabLimit: pageSize } = storeToRefs(settingsStore);
const { dataTabLimit: pageSize, defaultCopyType } = storeToRefs(settingsStore);
const { consoleHeight } = storeToRefs(consoleStore);
@ -697,6 +697,18 @@ const onKey = async (e: KeyboardEvent) => {
if ((e.ctrlKey || e.metaKey) && e.code === 'KeyA' && !e.altKey)
selectAllRows(e);
if ((e.ctrlKey || e.metaKey) && e.code === 'KeyC' && !e.altKey) {
const copyType = defaultCopyType.value;
if (selectedRows.value.length >= 1) {
if (selectedRows.value.length === 1 && copyType === 'cell')
await navigator.clipboard.writeText(scrollElement.value.querySelector('.td.selected').innerText);
else if (selectedRows.value.length > 1 && copyType === 'cell')
copyRow('html');
else
copyRow(copyType);
}
}
// row navigation stuff
if (!(e.ctrlKey || e.metaKey) && (e.code.includes('Arrow') || e.code === 'Tab') && sortedResults.value.length > 0 && !e.altKey) {
e.preventDefault();

View File

@ -148,7 +148,8 @@ export const enUS = {
appearence: 'Appearence',
color: 'Color',
label: 'Label',
icon: 'Icon'
icon: 'Icon',
resultsTable: 'Results table'
},
message: {
appWelcome: 'Welcome to Antares SQL Client!',
@ -333,7 +334,8 @@ export const enUS = {
folderName: 'Folder name',
deleteFolder: 'Delete folder',
editConnectionAppearence: 'Edit connection appearence',
executeSelectedQuery: 'Execute selected query'
executeSelectedQuery: 'Execute selected query',
defaultCopyType: 'Default copy type'
},
faker: {
address: 'Address',

View File

@ -333,7 +333,8 @@ export const idID = {
folderName: 'Nama folder',
deleteFolder: 'Hapus folder',
editConnectionAppearence: 'Ubah connection appearence',
executeSelectedQuery: 'Eksekusi query yang dipilih'
executeSelectedQuery: 'Eksekusi query yang dipilih',
defaultCopyType: 'Jenis salin default'
},
faker: {
address: 'Alamat',

View File

@ -29,7 +29,8 @@ export const useSettingsStore = defineStore('settings', {
restoreTabs: settingsStore.get('restore_tabs', true) as boolean,
disableBlur: settingsStore.get('disable_blur', false) as boolean,
disableScratchpad: settingsStore.get('disable_scratchpad', false) as boolean,
shortcuts: shortcutsStore.get('shortcuts', []) as ShortcutRecord[]
shortcuts: shortcutsStore.get('shortcuts', []) as ShortcutRecord[],
defaultCopyType: settingsStore.get('default_copy_type', 'cell') as string
}),
actions: {
changeLocale (locale: AvailableLocale) {
@ -92,6 +93,10 @@ export const useSettingsStore = defineStore('settings', {
},
updateShortcuts (shortcuts: ShortcutRecord[]) {
this.shortcuts = shortcuts;
},
changeDefaultCopyType (type: string) {
this.defaultCopyType = type;
settingsStore.set('default_copy_type', this.defaultCopyType);
}
}
});