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

View File

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