1
1
mirror of https://github.com/Fabio286/antares.git synced 2025-03-09 16:00:17 +01:00

feat: context menu option to duplicate connections

This commit is contained in:
Fabio Di Stasio 2021-07-09 11:18:40 +02:00
parent c6897af22d
commit 439356a019
4 changed files with 24 additions and 10 deletions

View File

@ -3,6 +3,9 @@
:context-event="contextEvent" :context-event="contextEvent"
@close-context="$emit('close-context')" @close-context="$emit('close-context')"
> >
<div class="context-element" @click="duplicateConnection">
<span class="d-flex"><i class="mdi mdi-18px mdi-content-duplicate text-light pr-1" /> {{ $t('word.duplicate') }}</span>
</div>
<div class="context-element" @click="showConfirmModal"> <div class="context-element" @click="showConfirmModal">
<span class="d-flex"><i class="mdi mdi-18px mdi-delete text-light pr-1" /> {{ $t('word.delete') }}</span> <span class="d-flex"><i class="mdi mdi-18px mdi-delete text-light pr-1" /> {{ $t('word.delete') }}</span>
</div> </div>
@ -28,6 +31,7 @@
<script> <script>
import { mapActions, mapGetters } from 'vuex'; import { mapActions, mapGetters } from 'vuex';
import { uidGen } from 'common/libs/uidGen';
import BaseContextMenu from '@/components/BaseContextMenu'; import BaseContextMenu from '@/components/BaseContextMenu';
import ConfirmModal from '@/components/BaseConfirmModal'; import ConfirmModal from '@/components/BaseConfirmModal';
@ -58,6 +62,7 @@ export default {
}, },
methods: { methods: {
...mapActions({ ...mapActions({
addConnection: 'connections/addConnection',
deleteConnection: 'connections/deleteConnection', deleteConnection: 'connections/deleteConnection',
selectWorkspace: 'workspaces/selectWorkspace' selectWorkspace: 'workspaces/selectWorkspace'
}), }),
@ -67,6 +72,17 @@ export default {
this.deleteConnection(this.contextConnection); this.deleteConnection(this.contextConnection);
this.closeContext(); this.closeContext();
}, },
duplicateConnection () {
let connectionCopy = Object.assign({}, this.contextConnection);
connectionCopy = {
...connectionCopy,
uid: uidGen('C'),
name: connectionCopy.name ? `${connectionCopy.name}_copy` : ''
};
this.addConnection(connectionCopy);
this.closeContext();
},
showConfirmModal () { showConfirmModal () {
this.isConfirmModal = true; this.isConfirmModal = true;
}, },

View File

@ -401,15 +401,11 @@ export default {
}, },
created () { created () {
this.setDefaults(); this.setDefaults();
window.addEventListener('keydown', this.onKey);
setTimeout(() => { setTimeout(() => {
this.$refs.firstInput.focus(); if (this.$refs.firstInput) this.$refs.firstInput.focus();
}, 20); }, 20);
}, },
beforeDestroy () {
window.removeEventListener('keydown', this.onKey);
},
methods: { methods: {
...mapActions({ ...mapActions({
addConnection: 'connections/addConnection', addConnection: 'connections/addConnection',

View File

@ -377,12 +377,13 @@ export default {
return JSON.stringify(this.connection) !== JSON.stringify(this.localConnection); return JSON.stringify(this.connection) !== JSON.stringify(this.localConnection);
} }
}, },
watch: {
connection () {
this.localConnection = JSON.parse(JSON.stringify(this.connection));
}
},
created () { created () {
this.localConnection = JSON.parse(JSON.stringify(this.connection)); this.localConnection = JSON.parse(JSON.stringify(this.connection));
window.addEventListener('keydown', this.onKey);
},
beforeDestroy () {
window.removeEventListener('keydown', this.onKey);
}, },
methods: { methods: {
...mapActions({ ...mapActions({

View File

@ -114,7 +114,8 @@ module.exports = {
row: 'Row | Rows', row: 'Row | Rows',
cell: 'Cell | Cells', cell: 'Cell | Cells',
triggerFunction: 'Trigger function | Trigger functions', triggerFunction: 'Trigger function | Trigger functions',
all: 'All' all: 'All',
duplicate: 'Duplicate'
}, },
message: { message: {
appWelcome: 'Welcome to Antares SQL Client!', appWelcome: 'Welcome to Antares SQL Client!',