const OrganizationRelationCreate = { template: `

{{ $t("comp.title") }}

{{ $t("shared.cancel") }} {{ $t("shared.submit") }}
`, i18n: { messages: { en: { comp: { title: "Add relation", successMessage: "Relation successfully created", }, }, de: { comp: { title: "Beziehung hinzufügen", successMessage: "Beziehung erfolgreich erstellt", }, }, }, }, data: () => ({ isLoadingAdminUnit: false, isSubmitting: false, adminUnit: null, form: { targetOrganization: null, auto_verify_event_reference_requests: false, verify: false, }, }), computed: { adminUnitId() { return this.$route.params.admin_unit_id }, }, mounted() { this.isLoadingAdminUnit = false; this.adminUnit = null; this.form = { targetOrganization: null, auto_verify_event_reference_requests: false, verify: this.$route.query.verify == "1", } this.loadAdminUnit(); }, methods: { loadAdminUnit() { axios .get(`/api/v1/organizations/${this.adminUnitId}`, { withCredentials: true, handleLoading: this.handleLoadingAdminUnit, }) .then((response) => { this.adminUnit = response.data; this.loadTarget(); }); }, loadTarget() { if (this.$route.query.target == undefined) { return; } axios .get(`/api/v1/organizations/${this.$route.query.target}`, { withCredentials: true, }) .then((response) => { this.form.targetOrganization = { id: response.data.id, name: response.data.name }; }); }, handleLoadingAdminUnit(isLoading) { this.isLoadingAdminUnit = isLoading; }, submitForm() { let data = { 'auto_verify_event_reference_requests': this.form.auto_verify_event_reference_requests, 'verify': this.form.verify, 'target_organization': { 'id': this.form.targetOrganization.id } } axios .post(`/api/v1/organizations/${this.adminUnitId}/relations/outgoing`, data, { withCredentials: true, handleLoading: this.handleSubmitting, }) .then(() => { this.$root.makeSuccessToast(this.$t("comp.successMessage")) this.goBack() }) }, handleSubmitting(isLoading) { this.isSubmitting = isLoading; }, goBack() { this.$root.goBack(`/manage/admin_unit/${this.adminUnitId}/relations`) }, } };