2FAuth/public/build/assets/CreateUpdate-Bshdf4W1.js.map

1 line
3.6 KiB
Plaintext
Raw Normal View History

2024-11-27 12:03:02 +01:00
{"version":3,"file":"CreateUpdate-Bshdf4W1.js","sources":["../../../resources/js/views/groups/CreateUpdate.vue"],"sourcesContent":["<script setup>\n import Form from '@/components/formElements/Form'\n import groupService from '@/services/groupService'\n import { useGroups } from '@/stores/groups'\n import { useBusStore } from '@/stores/bus'\n\n const groups = useGroups()\n const router = useRouter()\n const route = useRoute()\n const bus = useBusStore()\n\n const props = defineProps({\n groupId: [Number, String]\n })\n\n const isEditMode = computed(() => {\n return props.groupId != undefined\n })\n \n const form = reactive(new Form({\n name: '',\n }))\n\n onBeforeMount(() => {\n // We get the name to edit from the bus store to prevent request latency\n if (route.name == 'editGroup') {\n if (bus.editedGroupName) {\n form.name = bus.editedGroupName\n bus.editedGroupName = undefined\n }\n else {\n groupService.get(props.groupId).then(response => {\n form.name = response.data.name\n })\n }\n }\n })\n\n /**\n * Wrapper to call the appropriate function at form submit\n */\n function handleSubmit() {\n isEditMode.value ? updateGroup() : createGroup()\n }\n\n /**\n * Submits the form to the backend to store the new group\n */\n async function createGroup() {\n form.post('/api/v1/groups').then(response => {\n groups.addOrEdit(response.data)\n router.push({ name: 'groups' })\n })\n }\n\n /**\n * Submits the form to the backend to update the group\n */\n async function updateGroup() {\n form.put('/api/v1/groups/' + props.groupId).then(response => {\n groups.addOrEdit(response.data)\n router.push({ name: 'groups' })\n })\n }\n\n</script>\n\n<template>\n <FormWrapper :title=\"isEditMode ? $t('groups.forms.rename_group') : $t('groups.forms.new_group')\">\n <form @submit.prevent=\"handleSubmit\" @keydown=\"form.onKeydown($event)\">\n <FormField v-model=\"form.name\" fieldName=\"name\" :fieldError=\"form.errors.get('name')\" label=\"commons.name\" autofocus />\n <FormButtons\n :submitId=\"isEditMode ? 'btnEditGroup' : 'btnCreateGroup'\"\n :isBusy=\"form.isBusy\"\n :caption=\"isEditMode ? $t('commons.save') : $t('commons.create')\"\n :showCancelButton=\"true\"\n cancelLandingView=\"groups\" />\n </form>\n </FormWrapper>\n</template>"],"names":["groups","useGroups","router","useRouter","route","useRoute","bus","useBusStore","props","__props","isEditMode","computed","form","reactive","Form","onBeforeMount","groupService","response","handleSubmit","updateGroup","createGroup"],"mappings":"sXAMI,MAAMA,EAASC,EAAS,EAClBC,EAASC,EAAS,EAClBC,EAAQC,EAAQ,EAChBC,EAAMC,EAAW,EAEjBC,EAAQC,EAIRC,EAAaC,EAAS,IACjBH,EAAM,SAAW,IAC3B,EAEKI,EAAOC,EAAS,IAAIC,EAAK,CAC3B,KAAM,EACd,CAAK,CAAC,EAEFC,EAAc,IAAM,CAEZX,EAAM,MAAQ,cACVE,EAAI,iBACJM,EAAK,KAAON,EAAI,gBAChBA,EAAI,gBAAkB,QAGtBU,EAAa,IAAIR,EAAM,OAAO,EAAE,KAAKS,GAAY,CAC7CL,EAAK,KAAOK,EAAS,KAAK,IAC7B,CAAA,EAGZ,CAAA,EAKD,SAASC,GAAe,CACpBR,EAAW,MAAQS,EAAW,EAAKC,EAAW,CACtD,CAKI,eAAeA,GAAc,CACzBR,EAAK,KAAK,gBAAgB,EAAE,KAAKK,GAAY,CACzCjB,EAAO,UAAUiB,EAAS,IAAI,EAC9Bf,EAAO,KAAK,CAAE,KAAM,QAAU,CAAA,CACjC,CAAA,CACT,CAKI,eAAeiB,GAAc,CACzBP,EAAK,IAAI,kBAAoBJ,EAAM,OAAO,EAAE,KAAKS,GAAY,CACzDjB,EAAO,UAAUiB,EAAS,IAAI,EAC9Bf,EAAO,KAAK,CAAE,KAAM,QAAU,CAAA,CACjC,CAAA,CACT"}