45 lines
1.5 KiB
Vue
45 lines
1.5 KiB
Vue
<script setup>
|
|
import {onMounted} from "vue";
|
|
import {loading, organization, fetchOrganization, isRequestPending} from "src/composables/objects/organization";
|
|
import {useAppStore} from "stores/App";
|
|
import {useRoute, useRouter} from "vue-router";
|
|
import {useOrganizationsStore} from "stores/Organizations";
|
|
import {successObject} from "src/composables/dialog";
|
|
import {useQuasar} from "quasar";
|
|
import OrganizationEditSkeleton from "components/organizations/OrganizationEditSkeleton.vue";
|
|
import OrganizationForm from "components/organizations/OrganizationForm.vue";
|
|
|
|
const organizationId = parseInt(useRoute().params.id);
|
|
|
|
onMounted(() => {
|
|
fetchOrganization(organizationId).then(() => {
|
|
useAppStore().setPageTitle(`${organization.value.name} - editace`);
|
|
useAppStore().setBreadcrumbs([
|
|
{to: {name: "organizations"}, label: "Organizace"},
|
|
{to: {name: "organizationDetail", params: {id: organizationId}}, label: organization.value.name},
|
|
{label: "Editace"}
|
|
])
|
|
})
|
|
});
|
|
|
|
const $q = useQuasar();
|
|
const $router = useRouter();
|
|
const handleSave = (formData) => {
|
|
useOrganizationsStore().update(organizationId, formData).then(() => {
|
|
$q.notify(successObject("Organizace úspěšně upravena"));
|
|
$router.push({name: "organizationDetail", params: {id: organizationId}});
|
|
});
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<OrganizationEditSkeleton v-if="loading"/>
|
|
|
|
<OrganizationForm
|
|
v-else
|
|
:organization="organization"
|
|
:is-request-pending="isRequestPending"
|
|
@save="handleSave"
|
|
/>
|
|
</template>
|