traxxx/assets/components/stashes/add.vue

72 lines
983 B
Vue
Raw Permalink Normal View History

2021-03-20 02:22:08 +00:00
<template>
<Dialog
title="Add stash"
@close="$emit('close', false)"
2021-03-20 02:22:08 +00:00
>
2021-04-04 22:48:03 +00:00
<form
class="dialog-body"
@submit.prevent="addStash"
>
2023-06-08 02:19:37 +00:00
<div
v-if="errorMsg"
class="form-error"
>{{ errorMsg }}</div>
2021-03-20 02:22:08 +00:00
<input
ref="name"
v-model="name"
type="input"
placeholder="Name"
class="input"
>
<div class="dialog-actions right">
<button
type="submit"
class="button button-primary"
>Add</button>
</div>
</form>
</Dialog>
</template>
<script>
async function addStash() {
2023-06-08 02:19:37 +00:00
this.errorMsg = null;
try {
await this.$store.dispatch('createStash', {
name: this.name,
});
2021-03-20 02:22:08 +00:00
2023-06-08 02:19:37 +00:00
this.$emit('close', true);
} catch (error) {
this.errorMsg = error.message;
}
2021-03-20 02:22:08 +00:00
}
function mounted() {
this.$refs.name.focus();
}
export default {
2023-06-08 02:19:37 +00:00
emits: ['close'],
2021-03-20 02:22:08 +00:00
data() {
return {
2023-06-08 02:19:37 +00:00
errorMsg: null,
2021-03-20 02:22:08 +00:00
name: null,
};
},
mounted,
methods: {
addStash,
},
};
</script>
2023-06-08 02:19:37 +00:00
<style lang="scss" scoped>
.input {
width: 100%;
}
</style>