77 isTitle
88 :rules =" rules.title"
99 @save =" updatePlan"
10+ class =" mt-2"
1011 ></EditableTextBlock >
1112 <v-spacer class =" my-4" />
1213 <v-card class =" py-10" >
1617 </v-row >
1718 </v-card >
1819 <v-spacer class =" my-4" />
19- <AddressView @save =" updatePlan" v-model =" plan.address" title =" Home Address" ></AddressView >
20+ <AddressView
21+ @save =" updatePlan"
22+ v-model =" plan.address"
23+ title =" Home Address"
24+ ></AddressView >
2025 <v-spacer class =" my-4" />
2126 <EditableTextBlock
2227 icon =" mdi-phone"
3136 class =" mx-2 my-2"
3237 color =" #eee"
3338 ripple
34- :to = " `/prepare/familyplan/${plan.id}/ emergencycontacts` "
39+ @click = " ensureNamed('Emergency Contacts', ' emergencycontacts') "
3540 >
3641 <v-flex class =" d-flex justify-space-between px-2 py-2" >
3742 <div >Emergency Contacts</div >
4449 class =" mx-2 my-2"
4550 color =" #eee"
4651 ripple
47- :to = " `/prepare/familyplan/${plan.id}/ routes/` "
52+ @click = " ensureNamed('Routes and Locations', ' routes') "
4853 >
4954 <v-flex class =" d-flex justify-space-between px-2 py-2" >
5055 <div >Routes and Locations</div >
5358 </div >
5459 </v-flex >
5560 </v-card >
56- <v-card class =" mx-2 my-2" color =" #eee" ripple :to =" `/prepare/familyplan/${plan.id}/children/`" >
61+ <v-card
62+ class =" mx-2 my-2"
63+ color =" #eee"
64+ ripple
65+ @click =" ensureNamed('Children', 'children')"
66+ >
5767 <v-flex class =" d-flex justify-space-between px-2 py-2" >
5868 <div >Children</div >
5969 <div >
6070 <v-icon class =" mr-2" >mdi-chevron-right</v-icon >
6171 </div >
6272 </v-flex >
6373 </v-card >
64- <v-card class =" mx-2 my-2" color =" #eee" ripple :to =" `/prepare/familyplan/${plan.id}/pets/`" >
74+ <v-card
75+ class =" mx-2 my-2"
76+ color =" #eee"
77+ ripple
78+ @click =" ensureNamed('Pets', 'pets')"
79+ >
6580 <v-flex class =" d-flex justify-space-between px-2 py-2" >
6681 <div >Pets</div >
6782 <div >
@@ -79,7 +94,7 @@ import {
7994 defineComponent ,
8095 onMounted ,
8196 reactive ,
82- ref ,
97+ ref
8398} from " @vue/composition-api" ;
8499import store from " @/store" ;
85100import FamilyPlan from " @/models/family-plans/FamilyPlan" ;
@@ -88,6 +103,7 @@ import goBack from "@/functions/goBack";
88103import { phoneNumber , required , minLength } from " @/rules" ;
89104
90105import AddressView from " ./address-view.vue" ;
106+ import router from " @/router" ;
91107
92108export default defineComponent ({
93109 name: " family-plan-view" ,
@@ -127,18 +143,27 @@ export default defineComponent({
127143 const rules = {
128144 title: [
129145 required (" Title is required." ),
130- minLength (3 , " Title must be more than three characters." ),
146+ minLength (3 , " Title must be more than three characters." )
131147 ],
132- phone: [required (" Phone is required." ), phoneNumber ()],
148+ phone: [required (" Phone is required." ), phoneNumber ()]
133149 };
134150
151+ function ensureNamed (intent , subcomponent ) {
152+ if (store .state .error ) store .commit (" clearError" );
153+ if (! plan .value || ! plan .value .id || ! plan .value .title ) {
154+ store .commit (" setError" , ` Must name a plan before setting ${ intent} ` );
155+ } else {
156+ router .push (` /prepare/familyplan/${ plan .value .id } /${ subcomponent} /` );
157+ }
158+ }
159+
135160 return {
161+ ensureNamed,
136162 plan,
137163 updatePlan,
138164 goBack,
139- rules,
165+ rules
140166 };
141- },
167+ }
142168});
143169 </script >
144-
0 commit comments