Add escape button handler for form (reset)

This commit is contained in:
Annika Backstrom 2019-12-17 22:30:24 -05:00
parent 1f9a0ea586
commit ee5dd22f5f
1 changed files with 10 additions and 1 deletions

View File

@ -11,6 +11,7 @@
return {
editing: false,
saving: false,
trackForReset: {},
}
},
computed: {
@ -20,9 +21,17 @@
},
methods: {
edit: function() {
if (this.editing) {
return;
}
this.trackForReset = Object.assign({}, this.track);
this.saving = false;
this.editing = true;
},
cancel: function() {
this.track = Object.assign({}, this.trackForReset);
this.editing = false;
},
save: function() {
this.saving = true;
@ -55,7 +64,7 @@
template: `
<div class="media-track" @click="edit()">
<template v-if="editing">
<form method="patch" :action="patch_url">
<form method="patch" :action="patch_url" @keyup.27="cancel">
<select v-model="track.tag" :disabled="saving">
<option value=""></option>
<option :class="{unused: tag.tag_count == 0}" v-for="tag in tags">