1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <template>
- <SmartModal
- v-if="show"
- dialog
- :title="`${$t('collection.new')}`"
- @close="hideModal"
- >
- <template #body>
- <div class="flex flex-col px-2">
- <input
- id="selectLabelGqlAdd"
- v-model="name"
- v-focus
- class="input floating-input"
- placeholder=" "
- type="text"
- autocomplete="off"
- @keyup.enter="addNewCollection"
- />
- <label for="selectLabelGqlAdd">
- {{ $t("action.label") }}
- </label>
- </div>
- </template>
- <template #footer>
- <span>
- <ButtonPrimary
- :label="`${$t('action.save')}`"
- @click.native="addNewCollection"
- />
- <ButtonSecondary
- :label="`${$t('action.cancel')}`"
- @click.native="hideModal"
- />
- </span>
- </template>
- </SmartModal>
- </template>
- <script lang="ts">
- import { defineComponent } from "@nuxtjs/composition-api"
- import { HoppGQLRequest, makeCollection } from "@hoppscotch/data"
- import { addGraphqlCollection } from "~/newstore/collections"
- export default defineComponent({
- props: {
- show: Boolean,
- },
- data() {
- return {
- name: null as string | null,
- }
- },
- methods: {
- addNewCollection() {
- if (!this.name) {
- this.$toast.error(`${this.$t("collection.invalid_name")}`)
- return
- }
- addGraphqlCollection(
- makeCollection<HoppGQLRequest>({
- name: this.name,
- folders: [],
- requests: [],
- })
- )
- this.hideModal()
- },
- hideModal() {
- this.name = null
- this.$emit("hide-modal")
- },
- },
- })
- </script>
|