chore: update graphql with ts and setup

This commit is contained in:
nivedin
2023-12-04 14:15:46 +05:30
committed by Andrew Bastin
parent ea8de655d7
commit ad7b3f05b1
10 changed files with 468 additions and 442 deletions

View File

@@ -32,52 +32,47 @@
</HoppSmartModal>
</template>
<script lang="ts">
import { defineComponent } from "vue"
<script setup lang="ts">
import { ref, watch } from "vue"
import { useI18n } from "@composables/i18n"
import { useToast } from "@composables/toast"
import { editGraphqlFolder } from "~/newstore/collections"
export default defineComponent({
props: {
show: Boolean,
folder: { type: Object, default: () => ({}) },
folderPath: { type: String, default: null },
editingFolderName: { type: String, default: null },
},
emits: ["hide-modal"],
setup() {
return {
toast: useToast(),
t: useI18n(),
}
},
data() {
return {
name: "",
}
},
watch: {
editingFolderName(val) {
this.name = val
},
},
methods: {
editFolder() {
if (!this.name) {
this.toast.error(`${this.t("collection.invalid_name")}`)
return
}
editGraphqlFolder(this.folderPath, {
...(this.folder as any),
name: this.name,
})
this.hideModal()
},
hideModal() {
this.name = ""
this.$emit("hide-modal")
},
},
})
const t = useI18n()
const toast = useToast()
const props = defineProps<{
show: boolean
folderPath?: string
folder: any
editingFolderName: string
}>()
const emit = defineEmits(["hide-modal"])
const name = ref("")
watch(
() => props.editingFolderName,
(val) => {
name.value = val
}
)
const editFolder = () => {
if (!name.value) {
toast.error(`${t("collection.invalid_name")}`)
return
}
editGraphqlFolder(props.folderPath, {
...(props.folder as any),
name: name.value,
})
hideModal()
}
const hideModal = () => {
name.value = ""
emit("hide-modal")
}
</script>