11<template >
2- <v-form @submit =" createwiki" >
3- <v-card class =" elevation-12" >
4- <v-toolbar dark color =" primary" >
5- <v-toolbar-title >{{title}}</v-toolbar-title >
6- </v-toolbar >
7- <v-card-text >
8-
9- <h3 >Site name
10- <v-tooltip right >
11- <template v-slot :activator =" { on } " >
12- <v-icon v-on =" on" >mdi-information-outline</v-icon >
13- </template >
14- <span >The main name of your site</span ><br />
15- <span >Will appear in your page titles and can be changed at any time</span ><br />
16- <span >In MediaWiki terms this is $wgSitename</span ><br />
17- </v-tooltip >
18- </h3 >
19-
20- <v-text-field
21- id =" inputSiteName"
22- prepend-icon =" mdi-format-title"
23- name =" sitename"
24- label =" e.g., Goat Collective"
25- v-model =" sitename"
26- :disabled =" inFlight"
27- :error-messages =" error['sitename']"
28- />
29-
30- <h3 >Site domain
31- <v-tooltip right >
32- <template v-slot :activator =" { on } " >
33- <v-icon v-on =" on" >mdi-information-outline</v-icon >
34- </template >
35- <span >A domain name is what people type into their browser to visit your site.</span ><br />
36- <span >If you own your own domain, you can use it for Wikibase Cloud by selecting "Custom Domain".</span ><br />
37- <span >Otherwise, choose your own name to be a subdomain of wikibase.cloud (five characters minimum, only a-z, 0-9 and "-") by selecting "Free Subdomain". Example: your-name-here1.wikibase.cloud</span ><br />
38- </v-tooltip >
39- </h3 >
40-
41- <v-radio-group row v-model =" domainRadioChoice" :mandatory =" true" >
42- <v-radio label =" Free Subdomain" value =" sub" ></v-radio >
43- <v-radio label =" Custom Domain" value =" own" ></v-radio >
44- </v-radio-group >
45-
46- <v-text-field v-if =" domainRadioChoice === 'sub'"
47- id =" inputSubdomain"
48- prepend-icon =" mdi-web"
49- name =" subdomain"
50- label =" e.g., goat-collective"
51- v-model =" subdomain"
52- :suffix =" SUBDOMAIN_SUFFIX"
53- :disabled =" inFlight"
54- :error-messages =" error['siteaddress']"
55- :hint =" errorMessages.domainFormat"
56- />
57-
58- <v-text-field v-if =" domainRadioChoice === 'own'"
59- id =" inputDomain"
60- prepend-icon =" mdi-web"
61- name =" domain"
62- label =" e.g., goat-collective.com"
63- v-model =" domain"
64- :disabled =" inFlight"
65- :error-messages =" error['siteaddress']"
66- />
67-
68- <p v-if =" domainRadioChoice === 'own'" >This domain should have a CNAME record pointing to:</p >
69- <p v-if =" domainRadioChoice === 'own'" >"{{ CNAME_RECORD }}"</p >
70-
71- <h3 >Your user
72- <v-tooltip right >
73- <template v-slot :activator =" { on } " >
74- <v-icon v-on =" on" >mdi-information-outline</v-icon >
75- </template >
76- <span >Choose the username of your user and the first admin user on the site</span ><br />
77- <span >You will receive an email with log in details for this account</span ><br />
78- </v-tooltip >
79- </h3 >
80-
81- <v-text-field
82- id =" inputUsername"
83- prepend-icon =" mdi-account"
84- name =" username"
85- label =" e.g., Addshore"
86- v-model =" username"
87- :disabled =" inFlight"
88- :error-messages =" error['username']"
89- />
90-
91- <h3 >Terms of use</h3 >
92- <v-checkbox
93- v-model =" terms"
94- :disabled =" inFlight"
95- :error-messages =" error['terms']"
96- >
97- <template v-slot :label >
98- <div >
99- I agree to the
100- <v-tooltip bottom >
101- <template v-slot :activator =" { on } " >
102- <a
103- target =" _blank"
104- href =" /terms-of-use"
105- @click.stop
106- v-on =" on"
107- >
108- Terms of Use</a >
109- </template >
110- Opens in new window
111- </v-tooltip >.
112- </div >
113- </template >
114- </v-checkbox >
115-
116- </v-card-text >
117- <v-card-actions >
118- <v-spacer ></v-spacer >
119- <v-btn
120- type =" submit"
121- color =" primary"
122- :disabled =" inFlight"
123- >
124- {{buttonText}}
125- </v-btn >
126- </v-card-actions >
127- </v-card >
2+ <v-form @submit =" createWiki" >
3+ <step-one-card
4+ v-show =" step === 1"
5+ :title =" title"
6+ :inFlight =" inFlight"
7+ v-model =" stepOne"
8+ :error =" error"
9+ :SUBDOMAIN_SUFFIX =" SUBDOMAIN_SUFFIX"
10+ :CNAME_RECORD =" CNAME_RECORD"
11+ :errorMessages =" errorMessages"
12+ @next-step =" goToStep(2)"
13+ />
14+
15+ <step-two-card
16+ v-show =" step === 2"
17+ :title =" title"
18+ :inFlight =" inFlight"
19+ v-model =" stepTwo"
20+ @previous-step =" goToStep(1)"
21+ @next-step =" goToStep(3)"
22+ />
23+
24+ <step-three-card
25+ v-show =" step === 3"
26+ :title =" title"
27+ :inFlight =" inFlight"
28+ :error =" error"
29+ v-model =" stepThree"
30+ @previous-step =" goToStep(2)"
31+ @submit =" createWiki"
32+ />
12833 </v-form >
12934</template >
13035
13136<script >
13237import config from ' ~/config'
38+ import StepOneCard from ' ./CreateWikiWizardStepOne.vue'
39+ import StepTwoCard from ' ./CreateWikiWizardStepTwo.vue'
40+ import StepThreeCard from ' ./CreateWikiWizardStepThree.vue'
13341
13442export default {
13543 name: ' CreateWiki' ,
44+ components: {
45+ StepOneCard,
46+ StepTwoCard,
47+ StepThreeCard
48+ },
13649 props: [
13750 ' title' ,
13851 ' buttonText'
@@ -144,12 +57,24 @@ export default {
14457 },
14558 data () {
14659 return {
147- sitename: ' ' ,
148- domainRadioChoice: ' sub' ,
149- subdomain: ' ' ,
150- domain: ' ' ,
151- username: ' ' ,
152- terms: false ,
60+ stepOne: {
61+ sitename: ' ' ,
62+ domainRadioChoice: ' sub' ,
63+ subdomain: ' ' ,
64+ domain: ' ' ,
65+ username: ' '
66+ },
67+ stepTwo: {
68+ purpose: ' ' ,
69+ otherPurpose: ' ' ,
70+ audience: ' ' ,
71+ otherAudience: ' '
72+ },
73+ stepThree: {
74+ temporality: ' ' ,
75+ otherTemporality: ' ' ,
76+ terms: false
77+ },
15378 hasError: false ,
15479 error: [],
15580 inFlight: false ,
@@ -158,50 +83,61 @@ export default {
15883 errorMessages: {
15984 domainTaken: ' The domain has already been taken.' ,
16085 domainFormat: ' The subdomain must be at least five characters long and may contain only lowercase Latin letters (a-z), digits (0-9) and hyphens (-).'
161- }
86+ },
87+ step: 1
16288 }
16389 },
16490 created () {
91+ // what's this for?
92+ // this.buttonText = this.buttonTexts.next;
16593 this .checkCurrentLogin ()
16694 },
16795 updated () {
16896 this .checkCurrentLogin ()
16997 },
17098 methods: {
171- createwiki (evt ) {
172- evt .preventDefault ()
99+ goToStep (stepNumber ) {
100+ this .step = stepNumber
101+ },
102+ createWiki (evt ) {
103+ if (evt) {
104+ evt .preventDefault ()
105+ }
173106
174107 this .inFlight = true
175108 this .hasError = false
176109 this .error = []
177110
178- // Terms are not checked by the API? so check this here...?
179- // TODO do an initial round of validation here too!
180- // https://vuejs.org/v2/cookbook/form-validation.html
181- if (! this .terms ) {
182- this .hasError = true
183- this .error .terms = ' You must accept the Terms of Service.'
184- }
185-
186111 if (this .hasError ) {
187112 this .inFlight = false
188113 return
189114 }
190115
191116 // Figure out the actual domain to submit to the api!
192117 let domainToSubmit = ' '
193- if (this .domainRadioChoice === ' sub' ) {
194- domainToSubmit = this .subdomain + this .SUBDOMAIN_SUFFIX
118+ if (this .stepOne . domainRadioChoice === ' sub' ) {
119+ domainToSubmit = this .stepOne . subdomain + this .SUBDOMAIN_SUFFIX
195120 }
196- if (this .domainRadioChoice === ' own' ) {
197- domainToSubmit = this .domain
121+ if (this .stepOne . domainRadioChoice === ' own' ) {
122+ domainToSubmit = this .stepOne . domain
198123 }
199124
125+ const profileJSObject = {
126+ purpose: this .stepTwo .purpose ,
127+ ... (this .stepTwo .otherPurpose && { purpose_other: this .stepTwo .otherPurpose }),
128+ ... (this .stepTwo .audience && { audience: this .stepTwo .audience }),
129+ ... (this .stepTwo .otherAudience && { audience_other: this .stepTwo .otherAudience }),
130+ temporality: this .stepThree .temporality ,
131+ ... (this .stepThree .otherTemporality && { temporality_other: this .stepThree .otherTemporality })
132+ }
133+ const profileJsonString = JSON .stringify (profileJSObject)
134+
200135 this .$api .createWiki (
201136 {
202137 domain: domainToSubmit,
203- sitename: this .sitename ,
204- username: this .username
138+ sitename: this .stepOne .sitename ,
139+ username: this .stepOne .username ,
140+ profile: profileJsonString
205141 }
206142 )
207143 .then (wikiDetails => this .createSuccess (wikiDetails))
@@ -214,8 +150,10 @@ export default {
214150 this .$router .replace (' /wikis/manage/' + wikiDetails .id )
215151 },
216152 createFail (errors ) {
153+ // Probably we want to go back to the first step that has an error in this case.
217154 this .error = []
218-
155+ // all these errors are shown on the first step.
156+ this .goToStep (1 )
219157 if (errors .sitename ) {
220158 this .hasError = true
221159 this .error .sitename = errors .sitename [0 ]
0 commit comments