api-client/components/environments/Add.vue

68 lines
1.5 KiB
Vue
Raw Normal View History

2020-02-23 16:38:15 +00:00
<template>
<SmartModal v-if="show" @close="hideModal">
2020-02-23 16:38:15 +00:00
<div slot="header">
2020-12-11 10:29:03 +00:00
<div class="row-wrapper">
<h3 class="title">{{ $t("new_environment") }}</h3>
<div>
<button class="icon" @click="hideModal">
<i class="material-icons">close</i>
</button>
</div>
</div>
2020-02-23 16:38:15 +00:00
</div>
2020-12-11 16:54:34 +00:00
<div slot="body" class="flex flex-col">
2020-12-11 10:29:03 +00:00
<label for="selectLabel">{{ $t("label") }}</label>
<input
id="selectLabel"
v-model="name"
2021-05-18 06:26:59 +00:00
type="text"
2020-12-11 10:29:03 +00:00
:placeholder="$t('my_new_environment')"
@keyup.enter="addNewEnvironment"
/>
2020-02-23 16:38:15 +00:00
</div>
<div slot="footer">
2020-09-22 17:06:37 +00:00
<div class="row-wrapper">
2020-02-23 16:38:15 +00:00
<span></span>
<span>
<button class="icon" @click="hideModal">
{{ $t("cancel") }}
2020-02-23 16:38:15 +00:00
</button>
<button class="icon primary" @click="addNewEnvironment">
{{ $t("save") }}
2020-02-23 16:38:15 +00:00
</button>
</span>
</div>
</div>
</SmartModal>
2020-02-23 16:38:15 +00:00
</template>
<script lang="ts">
import Vue from "vue"
import { createEnvironment } from "~/newstore/environments"
2020-02-23 19:00:22 +00:00
export default Vue.extend({
2020-02-23 16:38:15 +00:00
props: {
2020-02-24 18:44:50 +00:00
show: Boolean,
2020-02-23 16:38:15 +00:00
},
data() {
return {
name: null as string | null,
}
},
2020-02-23 16:38:15 +00:00
methods: {
addNewEnvironment() {
if (!this.name) {
this.$toast.info(this.$t("invalid_environment_name").toString())
2020-02-24 18:44:50 +00:00
return
2020-02-23 16:38:15 +00:00
}
createEnvironment(this.name)
this.hideModal()
2020-02-23 16:38:15 +00:00
},
hideModal() {
this.name = null
this.$emit("hide-modal")
2020-02-24 18:44:50 +00:00
},
},
})
2020-02-23 16:38:15 +00:00
</script>