Skip to content

Commit 1ae276f

Browse files
committed
add cancel field to all types of setting
1 parent 2760aca commit 1ae276f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

frontend/src/components/app/settings/AccountInput.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<div class="flex justify-between items-center w-full">
77
<h1 class="text-md font-bold capitalize text-gray-matcha">{{ name }}</h1>
88
<div class="flex">
9-
<h1 v-if="type === 'password' && edit" v-on:click="cancelEditing()" class="mr-4 text-sm text-purple-matcha cursor-pointer">Cancel</h1>
9+
<h1 v-if="edit" v-on:click="cancelEditing()" class="mr-4 text-sm text-purple-matcha cursor-pointer">Cancel</h1>
1010
<input v-if="edit" type="submit" :disabled="invalid" value="Save"
1111
v-bind:class="{'text-sm': true,'text-purple-matcha': true, 'bg-transparent': true, 'focus:outline-none': true, 'active:outline-none': true, 'opacity-50': invalid, 'cursor-pointer': !invalid}">
1212
<h1 v-if="!edit" v-on:click="startEditing()" class="cursor-pointer text-sm text-purple-matcha">{{ buttonText }}</h1>
@@ -53,18 +53,21 @@ export default {
5353
props: ['name', 'type', 'currentValuePassed'],
5454
data: () => ({
5555
edit: false,
56+
currentValueBackup: '',
5657
currentValue: '',
5758
passwordRepeat: '',
5859
}),
5960
methods: {
6061
startEditing() {
62+
this.currentValueBackup = this.currentValue;
6163
this.edit = true;
6264
},
6365
cancelEditing() {
6466
if (this.type === 'password') {
6567
this.currentValue = '';
6668
this.passwordRepeat = '';
6769
}
70+
this.currentValue = this.currentValueBackup;
6871
this.edit = false;
6972
},
7073
onSubmit() {
@@ -73,6 +76,7 @@ export default {
7376
this.passwordRepeat = '';
7477
}
7578
this.edit = false;
79+
this.currentValueBackup = this.currentValue;
7680
},
7781
passwordErrorHandler(error) {
7882
if (!error || error === 'The Password field is required' || error === 'The Repeat Password field is required') {

0 commit comments

Comments
 (0)