1
1
mirror of https://github.com/Fabio286/antares.git synced 2025-06-05 21:59:22 +02:00

feat: close modals pressing ESC

This commit is contained in:
Fabio 2020-10-04 17:21:21 +02:00
parent 6ee4ef4b8b
commit d563cec70d
8 changed files with 76 additions and 5 deletions

View File

@ -30,7 +30,6 @@ An application created with minimalism and semplicity in mind, with features in
This is a roadmap with major features will come in near future. This is a roadmap with major features will come in near future.
- Improvements of query editor area. - Improvements of query editor area.
- Database management (add/edit/delete).
- Tables management (add/edit/delete). - Tables management (add/edit/delete).
- Users management (add/edit/delete). - Users management (add/edit/delete).
- Stored procedures, views, schedulers and trigger support. - Stored procedures, views, schedulers and trigger support.
@ -57,7 +56,7 @@ This is a roadmap with major features will come in near future.
### Operating Systems ### Operating Systems
#### • x86 #### • x64
- [x] Windows - [x] Windows
- [x] Linux - [x] Linux

View File

@ -1,7 +1,11 @@
<template> <template>
<div class="context"> <div class="context">
<a
class="context-overlay"
@click="close"
@contextmenu="close"
/>
<div <div
v-click-outside="close"
class="context-container" class="context-container"
:style="position" :style="position"
> >
@ -29,9 +33,20 @@ export default {
}; };
} }
}, },
created () {
window.addEventListener('keydown', this.onKey);
},
beforeDestroy () {
window.removeEventListener('keydown', this.onKey);
},
methods: { methods: {
close () { close () {
this.$emit('close-context'); this.$emit('close-context');
},
onKey (e) {
e.stopPropagation();
if (e.key === 'Escape')
this.close();
} }
} }
}; };
@ -52,7 +67,6 @@ export default {
top: 0; top: 0;
left: 0; left: 0;
bottom: 0; bottom: 0;
pointer-events: none;
.context-container { .context-container {
min-width: 100px; min-width: 100px;

View File

@ -173,6 +173,10 @@ export default {
}, },
created () { created () {
this.localConnection = Object.assign({}, this.connection); this.localConnection = Object.assign({}, this.connection);
window.addEventListener('keydown', this.onKey);
},
beforeDestroy () {
window.removeEventListener('keydown', this.onKey);
}, },
methods: { methods: {
...mapActions({ ...mapActions({
@ -226,6 +230,11 @@ export default {
closeAsking () { closeAsking () {
this.isTesting = false; this.isTesting = false;
this.isAsking = false; this.isAsking = false;
},
onKey (e) {
e.stopPropagation();
if (e.key === 'Escape')
this.closeModal();
} }
} }
}; };

View File

@ -112,6 +112,11 @@ export default {
collation: actualCollation || this.defaultCollation, collation: actualCollation || this.defaultCollation,
prevCollation: actualCollation || this.defaultCollation prevCollation: actualCollation || this.defaultCollation
}; };
window.addEventListener('keydown', this.onKey);
},
beforeDestroy () {
window.removeEventListener('keydown', this.onKey);
}, },
methods: { methods: {
...mapActions({ ...mapActions({
@ -139,6 +144,11 @@ export default {
}, },
closeModal () { closeModal () {
this.$emit('close'); this.$emit('close');
},
onKey (e) {
e.stopPropagation();
if (e.key === 'Escape')
this.closeModal();
} }
} }
}; };

View File

@ -180,6 +180,12 @@ export default {
isAsking: false isAsking: false
}; };
}, },
created () {
window.addEventListener('keydown', this.onKey);
},
beforeDestroy () {
window.removeEventListener('keydown', this.onKey);
},
methods: { methods: {
...mapActions({ ...mapActions({
closeModal: 'application/hideNewConnModal', closeModal: 'application/hideNewConnModal',
@ -249,6 +255,11 @@ export default {
closeAsking () { closeAsking () {
this.isAsking = false; this.isAsking = false;
this.isTesting = false; this.isTesting = false;
},
onKey (e) {
e.stopPropagation();
if (e.key === 'Escape')
this.closeModal();
} }
} }
}; };

View File

@ -88,6 +88,10 @@ export default {
}, },
created () { created () {
this.database = { ...this.database, collation: this.defaultCollation }; this.database = { ...this.database, collation: this.defaultCollation };
window.addEventListener('keydown', this.onKey);
},
beforeDestroy () {
window.removeEventListener('keydown', this.onKey);
}, },
methods: { methods: {
...mapActions({ ...mapActions({
@ -113,6 +117,11 @@ export default {
}, },
closeModal () { closeModal () {
this.$emit('close'); this.$emit('close');
},
onKey (e) {
e.stopPropagation();
if (e.key === 'Escape')
this.closeModal();
} }
} }
}; };

View File

@ -160,6 +160,9 @@ export default {
this.nInserts = 1; this.nInserts = 1;
} }
}, },
created () {
window.addEventListener('keydown', this.onKey);
},
mounted () { mounted () {
const rowObj = {}; const rowObj = {};
@ -195,6 +198,9 @@ export default {
this.localRow = { ...rowObj }; this.localRow = { ...rowObj };
}, },
beforeDestroy () {
window.removeEventListener('keydown', this.onKey);
},
methods: { methods: {
...mapActions({ ...mapActions({
addNotification: 'notifications/addNotification' addNotification: 'notifications/addNotification'
@ -294,9 +300,13 @@ export default {
this.localRow[field] = files[0].path; this.localRow[field] = files[0].path;
}, },
getKeyUsage (keyName) { getKeyUsage (keyName) {
return this.keyUsage.find(key => key.column === keyName); return this.keyUsage.find(key => key.column === keyName);
},
onKey (e) {
e.stopPropagation();
if (e.key === 'Escape')
this.closeModal();
} }
} }
}; };

View File

@ -164,6 +164,10 @@ export default {
this.localLocale = this.selectedLocale; this.localLocale = this.selectedLocale;
this.localTimeout = this.notificationsTimeout; this.localTimeout = this.notificationsTimeout;
this.selectedTab = this.selectedSettingTab; this.selectedTab = this.selectedSettingTab;
window.addEventListener('keydown', this.onKey);
},
beforeDestroy () {
window.removeEventListener('keydown', this.onKey);
}, },
methods: { methods: {
...mapActions({ ...mapActions({
@ -182,6 +186,11 @@ export default {
this.localTimeout = 10; this.localTimeout = 10;
this.updateNotificationsTimeout(+this.localTimeout); this.updateNotificationsTimeout(+this.localTimeout);
},
onKey (e) {
e.stopPropagation();
if (e.key === 'Escape')
this.closeModal();
} }
} }
}; };