From 49630dc784b36190cc9f246dc06a282f49b21356 Mon Sep 17 00:00:00 2001 From: hujtomi Date: Wed, 15 Mar 2023 00:10:52 +0100 Subject: [PATCH] Move Family Members to top section of family plan #112 --- .../family-plans/family-plans-view.vue | 253 +++++++++++------- 2wr-app/src/router/familyPlanRoutes.js | 10 + .../family-plans/add-family-member.vue | 145 ++++++++++ 3 files changed, 317 insertions(+), 91 deletions(-) create mode 100644 2wr-app/src/views/prepare/family-plans/add-family-member.vue diff --git a/2wr-app/src/components/prepare/family-plans/family-plans-view.vue b/2wr-app/src/components/prepare/family-plans/family-plans-view.vue index a460d0d..9487668 100644 --- a/2wr-app/src/components/prepare/family-plans/family-plans-view.vue +++ b/2wr-app/src/components/prepare/family-plans/family-plans-view.vue @@ -1,70 +1,117 @@ @@ -142,16 +173,23 @@ import FamilyPlan from "@/models/family-plans/FamilyPlan"; import _ from "lodash"; import goBack from "@/functions/goBack"; import { phoneNumber, required, minLength } from "@/rules"; +import PetEditor from "./editors/pet-editor.vue"; +import ChildEditor from "./editors/child-editor.vue"; import AddressView from "./address-view.vue"; import router from "@/router"; export default defineComponent({ name: "family-plan-view", - components: { AddressView }, + components: { AddressView, PetEditor, ChildEditor }, props: { planId: { required: true } }, setup(props, { refs }) { + const plan = ref(null); + const showPetEditor = ref(false); + const editorPet = ref(null); + const showChildEditor = ref(false); + const editorChild = ref(null); onMounted(() => { // Determine which plan to use @@ -162,7 +200,7 @@ export default defineComponent({ props.planId ); if (found) { - plan.value = reactive(_.cloneDeep(found)); + plan.value = found; } else { goBack(); } @@ -221,7 +259,40 @@ export default defineComponent({ } } + function launchPetEditor(pet) { + editorPet.value = pet; + showPetEditor.value = true; + } + + async function savePet(pet) { + await store.dispatch("familyPlansStore/updatePetAsync", { pet, planId: props.planId }); + showPetEditor.value = false; + } + + function launchChildEditor(child) { + editorChild.value = child; + showChildEditor.value = true; + } + + async function saveChild(child) { + await store.dispatch("familyPlansStore/updateChildAsync", { + child, + planId: props.planId, + }); + showChildEditor.value = false; + } + return { + launchPetEditor, + showPetEditor, + editorPet, + savePet, + + launchChildEditor, + showChildEditor, + editorChild, + saveChild, + deletePlan, toggleAlerts, ensureNamed, diff --git a/2wr-app/src/router/familyPlanRoutes.js b/2wr-app/src/router/familyPlanRoutes.js index 52cfc3d..16e41c6 100644 --- a/2wr-app/src/router/familyPlanRoutes.js +++ b/2wr-app/src/router/familyPlanRoutes.js @@ -5,6 +5,7 @@ import FamilyPlanDistantContacts from "../views/prepare/family-plans/distant-con import FamilyPlanRoutes from "../views/prepare/family-plans/routes.vue"; import FamilyPlanChildren from '@/views/prepare/family-plans/children.vue'; import FamilyPlanPets from '@/views/prepare/family-plans/pets.vue'; +import AddFamilyMember from '@/views/prepare/family-plans/add-family-member.vue' export default [ { @@ -68,5 +69,14 @@ export default [ meta: { requiresAuth: true } + }, + { + path: '/prepare/familyplan/:planId/addfamilymember', + name: "familyplan-addfamilymember", + component: AddFamilyMember, + props: true, + meta: { + requiresAuth: true + } } ]; diff --git a/2wr-app/src/views/prepare/family-plans/add-family-member.vue b/2wr-app/src/views/prepare/family-plans/add-family-member.vue new file mode 100644 index 0000000..31d1f77 --- /dev/null +++ b/2wr-app/src/views/prepare/family-plans/add-family-member.vue @@ -0,0 +1,145 @@ + + + + + \ No newline at end of file