11<template >
22 <v-form ref =" form" >
3+ <v-overlay :value =" dialog.show" >
4+ <v-dialog
5+ content-class =" update-wiki-profile-dialog"
6+ v-model =" dialog.show"
7+ >
8+ <step-two-card
9+ v-show =" dialog.step === 1"
10+ :title =" dialog.title"
11+ :inFlight =" inFlight"
12+ :dismissable =" true"
13+ v-model =" dialog.data.stepOne"
14+ @close-dialog =" dialog.show = false"
15+ @next-step =" goToStep(2)"
16+ />
17+ <step-three-card
18+ v-show =" dialog.step === 2"
19+ :title =" dialog.title"
20+ :inFlight =" inFlight"
21+ :error =" dialog.error"
22+ :dismissable =" true"
23+ :showTerms =" false"
24+ submitButtonText =" Set intended use"
25+ v-model =" dialog.data.stepTwo"
26+ @close-dialog =" dialog.show = false"
27+ @previous-step =" goToStep(1)"
28+ @submit =" updateProfile"
29+ />
30+ </v-dialog >
31+ </v-overlay >
332 <v-card >
433 <v-card-title class =" card-title" >
534 <span >Intended use</span >
4069 <span v-if =" updatedAt" class =" updated-at" >{{ updatedAt }}</span >
4170 </v-card-text >
4271 <Message ref =" message" />
72+ <v-card-actions >
73+ <v-btn :disabled =" inFlight" @click =" showDialog()" >Set intended use</v-btn >
74+ </v-card-actions >
4375 </v-card >
4476 </v-form >
4577</template >
4678
4779<script >
4880import Message from ' ../Features/Message.vue'
81+ import StepTwoCard from ' ~/components/Cards/CreateWikiWizardStepTwo'
82+ import StepThreeCard from ' ~/components/Cards/CreateWikiWizardStepThree'
4983
5084const providedResponses = {
5185 purpose: {
@@ -69,14 +103,36 @@ const providedResponses = {
69103export default {
70104 name: ' Profile' ,
71105 components: {
72- Message
106+ Message,
107+ StepTwoCard,
108+ StepThreeCard
73109 },
74110 props: [
75111 ' wikiId'
76112 ],
77113 data () {
78114 return {
79- profile: {}
115+ inFlight: false ,
116+ profile: {},
117+ dialog: {
118+ show: false ,
119+ title: ' Set intended use' ,
120+ error: [],
121+ step: 1 ,
122+ data: {},
123+ dataTemplate: {
124+ stepOne: {
125+ purpose: ' ' ,
126+ otherPurpose: ' ' ,
127+ audience: ' ' ,
128+ otherAudience: ' '
129+ },
130+ stepTwo: {
131+ temporality: ' ' ,
132+ otherTemporality: ' '
133+ }
134+ }
135+ }
80136 }
81137 },
82138 computed: {
@@ -107,6 +163,40 @@ export default {
107163 return providedResponses[question][providedResponse]
108164 }
109165 return ' No answer selected.'
166+ },
167+ showDialog () {
168+ this .dialog .step = 1
169+ this .dialog .data = JSON .parse (JSON .stringify (this .dialog .dataTemplate ))
170+ this .dialog .show = true
171+ },
172+ goToStep (stepNumber ) {
173+ this .dialog .step = stepNumber
174+ },
175+ async updateProfile () {
176+ this .inFlight = true
177+
178+ try {
179+ const profile = {
180+ purpose: this .dialog .data .stepOne .purpose ,
181+ ... (this .dialog .data .stepOne .otherPurpose && { purpose_other: this .dialog .data .stepOne .otherPurpose }),
182+ ... (this .dialog .data .stepOne .audience && { audience: this .dialog .data .stepOne .audience }),
183+ ... (this .dialog .data .stepOne .otherAudience && { audience_other: this .dialog .data .stepOne .otherAudience }),
184+ temporality: this .dialog .data .stepTwo .temporality ,
185+ ... (this .dialog .data .stepTwo .otherTemporality && { temporality_other: this .dialog .data .stepTwo .otherTemporality })
186+ }
187+
188+ this .profile = (await this .$store .dispatch (' updateProfile' , {
189+ wiki: this .wikiId , profile: JSON .stringify (profile)
190+ })).data .data ?? {}
191+
192+ this .$refs .message .show (' success' , ' Intended use has been updated.' )
193+ this .dialog .show = false
194+ } catch (error) {
195+ console .log (error)
196+ this .$refs .message .show (' error' , ' Something went wrong with updating your intended use. Please try again.' )
197+ } finally {
198+ this .inFlight = false
199+ }
110200 }
111201 },
112202 async created () {
@@ -121,6 +211,15 @@ export default {
121211}
122212< / script>
123213
214+ < style lang= " css" >
215+ .update - wiki- profile- dialog {
216+ max- width: 356px ;
217+ }
218+ .update - wiki- profile- dialog .v - dialog > .v - card > .v - card__text {
219+ padding: 16px ;
220+ }
221+ < / style>
222+
124223< style lang= " css" scoped>
125224.card - title {
126225 display: flex;
0 commit comments