Skip to content

Commit

Permalink
Adding Control-S save feature to item edit (openhab#842)
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Homeyer <[email protected]>
  • Loading branch information
bigbasec committed Jan 28, 2021
1 parent 731f009 commit 1b71f2c
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<f7-navbar :title="createMode ? 'Create New Item': 'Edit Item'" back-link="Cancel">
<f7-nav-right v-if="!$theme.aurora || !createMode">
<f7-link @click="save()" v-if="$theme.md" icon-md="material:save" icon-only></f7-link>
<f7-link @click="save()" v-if="!$theme.md">Save</f7-link>
<f7-link @click="save()" v-if="!$theme.md">Save<span v-if="$device.desktop">&nbsp;(Ctrl-S)</span></f7-link>
</f7-nav-right>
</f7-navbar>
<f7-block class="block-narrow" v-if="item.name || item.created === false">
Expand Down Expand Up @@ -97,6 +97,21 @@ export default {
this.ready = true
})
}
if (window) {
window.addEventListener('keydown', this.keyDown)
}
},
onPageBeforeOut () {
if (window) {
window.removeEventListener('keydown', this.keyDown)
}
},
keyDown (ev) {
if (ev.keyCode === 83 && (ev.ctrlKey || ev.metaKey)) {
this.save()
ev.stopPropagation()
ev.preventDefault()
}
},
save () {
// TODO properly validate item
Expand Down

0 comments on commit 1b71f2c

Please sign in to comment.