1<template>
2 <Dialog
3 v-model:open="show"
4 :title="__('New team')"
5 :actions="[
6 {
7 label: __('Create'),
8 variant: 'solid',
9 onClick: () => {
10 newTeam.submit();
11 },
12 },
13 ]"
14 >
15 <template #default>
16 <form class="space-y-2" @submit.prevent="newTeam.submit">
17 <FormControl
18 v-model="newTeamTitle"
19 :label="__('Title')"
20 :placeholder="__('Product experts')"
21 type="text"
22 />
23 </form>
24 </template>
25 </Dialog>
26</template>
27
28<script setup lang="ts">
29import { createResource, toast } from "frappe-ui";
30import { ref } from "vue";
31import { __ } from "@/translation";
32
33const emit = defineEmits(["create"]);
34const show = defineModel();
35
36const newTeamTitle = ref(null);
37const newTeam = createResource({
38 url: "frappe.client.insert",
39 makeParams() {
40 return {
41 doc: {
42 doctype: "OD Team",
43 team_name: newTeamTitle.value,
44 },
45 };
46 },
47 validate(params) {
48 if (!params.doc.team_name) return __("Title is required");
49 },
50 auto: false,
51 onSuccess() {
52 toast.success(__("Team created"));
53 newTeamTitle.value = null;
54 show.value = false;
55 emit("create");
56 },
57});
58</script>
59
60<style scoped></style>
61