diff --git a/src/components/Cards/CreateWiki.vue b/src/components/Cards/CreateWiki.vue index 59b4090f..4bbe47fc 100644 --- a/src/components/Cards/CreateWiki.vue +++ b/src/components/Cards/CreateWiki.vue @@ -29,6 +29,17 @@ :error="error" v-model="stepThree" @previous-step="goToStep(2)" + @next-step="goToStep(4)" + @submit="createWiki" + /> + + @@ -39,13 +50,15 @@ import config from '~/config' import SiteDetailsCreateWikiWizardStep from './SiteDetailsCreateWikiWizardStep.vue' import AudienceAndPurposeWizardStep from './AudienceAndPurposeWizardStep.vue' import TemporalityCreateWikiWizardStep from './TemporalityCreateWikiWizardStep.vue' +import KnowledgeEquityCreateWikiWizardStep from './KnowledgeEquityCreateWikiWizardStep.vue' export default { name: 'CreateWiki', components: { SiteDetailsCreateWikiWizardStep, AudienceAndPurposeWizardStep, - TemporalityCreateWikiWizardStep + TemporalityCreateWikiWizardStep, + KnowledgeEquityCreateWikiWizardStep }, props: [ 'title' @@ -74,6 +87,10 @@ export default { temporality: '', otherTemporality: '' }, + stepFour: { + selectedOption: '', + freeTextResponse: '' + }, hasError: false, error: [], inFlight: false, @@ -119,7 +136,7 @@ export default { domainToSubmit = this.stepOne.domain } - const profileJSObject = { + const profileObject = { purpose: this.stepTwo.purpose, ...(this.stepTwo.otherPurpose && { purpose_other: this.stepTwo.otherPurpose }), ...(this.stepTwo.audience && { audience: this.stepTwo.audience }), @@ -127,16 +144,22 @@ export default { temporality: this.stepThree.temporality, ...(this.stepThree.otherTemporality && { temporality_other: this.stepThree.otherTemporality }) } - const profileJsonString = JSON.stringify(profileJSObject) - this.$api.createWiki( - { - domain: domainToSubmit, - sitename: this.stepOne.sitename, - username: this.stepOne.username, - profile: profileJsonString + const requestBody = { + domain: domainToSubmit, + sitename: this.stepOne.sitename, + username: this.stepOne.username, + profile: JSON.stringify(profileObject) + } + + if (this.stepThree.temporality === 'permanent' && this.stepFour.selectedOption) { + requestBody.knowledgeEquityResponse = { + selectedOption: this.stepFour.selectedOption, + freeTextResponse: this.stepFour.freeTextResponse } - ) + } + + this.$api.createWiki(requestBody) .then(wikiDetails => this.createSuccess(wikiDetails)) .catch(errors => this.createFail(errors)) }, diff --git a/src/components/Cards/KnowledgeEquityCreateWikiWizardStep.vue b/src/components/Cards/KnowledgeEquityCreateWikiWizardStep.vue new file mode 100644 index 00000000..41dfe4bb --- /dev/null +++ b/src/components/Cards/KnowledgeEquityCreateWikiWizardStep.vue @@ -0,0 +1,102 @@ + + + + + diff --git a/src/components/Cards/TemporalityCreateWikiWizardStep.vue b/src/components/Cards/TemporalityCreateWikiWizardStep.vue index 98bffe82..8b75b3ce 100644 --- a/src/components/Cards/TemporalityCreateWikiWizardStep.vue +++ b/src/components/Cards/TemporalityCreateWikiWizardStep.vue @@ -81,9 +81,9 @@ type="button" color="primary" :disabled="inFlight" - @click="submitWholeForm" + @click="primaryBtnAction" > - Create Wiki + {{primaryBtnLabel}} @@ -98,26 +98,39 @@ export default { value: Object, error: Array }, + computed: { + primaryBtnLabel () { + if (this.value.temporality === 'permanent') { + return 'Next >' + } else { + return 'Create Wiki' + } + } + }, methods: { - previousStep () { + primaryBtnAction () { if (this.value.temporality !== 'other') { this.value.otherTemporality = undefined } - this.$emit('previous-step') + if (this.$refs.inputForm.validate() === false) { + return + } + + if (this.value.temporality === 'permanent') { + this.$emit('next-step') + } else { + this.$emit('submit') + } }, - submitWholeForm () { + previousStep () { if (this.value.temporality !== 'other') { this.value.otherTemporality = undefined } - this.$refs.inputForm.validate() - if (this.$refs.inputForm.validate() === true) { - this.$emit('submit') - } + this.$emit('previous-step') } } - }