|
70 | 70 | import Step from './Step' |
71 | 71 | import FirstStep from './FirstStep' |
72 | 72 | import AttributionDetails from './AttributionDetails' |
| 73 | +import CopyrightWaiverStep from './CopyrightWaiverStep' |
73 | 74 | import DropdownStep from './DropdownStep' |
74 | 75 | import { disabledSetters, visibleSetters } from '../utils/license-utilities' |
75 | 76 | import { mapGetters } from 'vuex' |
76 | | -import CopyrightWaiverStep from './CopyrightWaiverStep' |
77 | 77 |
|
78 | 78 | export default { |
79 | 79 | name: 'Stepper', |
@@ -108,45 +108,53 @@ export default { |
108 | 108 | } |
109 | 109 | }, |
110 | 110 | methods: { |
111 | | - headerText(stepId) { |
| 111 | + headerText(stepId, stepStatus) { |
112 | 112 | const prefix = `stepper.${stepId}` |
113 | | - return this.status === 'current' ? `${prefix}.question` : `${prefix}.heading` |
| 113 | + if (stepId === 'AD' || stepId === 'CW') { |
| 114 | + return prefix + '.heading' |
| 115 | + } |
| 116 | + return stepStatus === 'current' ? `${prefix}.question` : `${prefix}.heading` |
114 | 117 | }, |
115 | | - nextButtonDisabled(stepId) { |
116 | | - if (this.steps[stepId].selected === undefined) { |
117 | | - return 'disabled' |
| 118 | + nextButtonDisabled: function(stepId) { |
| 119 | + // Disable 'Next' button if on one of the first 4 steps |
| 120 | + if (stepId <= 4) { |
| 121 | + return this.steps[stepId].selected === undefined |
| 122 | + ? 'disabled' |
| 123 | + : '' |
118 | 124 | } else { |
| 125 | + if (stepId === 6 && this.$store.state.currentLicenseAttributes.BY === undefined) { |
| 126 | + return 'disabled' |
| 127 | + } |
119 | 128 | return '' |
120 | 129 | } |
121 | 130 | }, |
122 | | - changeFirstStep() { |
123 | | - this.$set(this.steps, 0, { ...this.steps[0], selected: !this.steps[0].selected }) |
| 131 | + changeFirstStep(isSelected) { |
| 132 | + this.$set(this.steps, 0, { ...this.steps[0], selected: isSelected }) |
| 133 | + }, |
| 134 | + changeStepSelected(stepName, stepId, isSelected) { |
| 135 | + this.$set(this.steps, stepId, { ...this.steps[stepId], selected: isSelected }) |
| 136 | + this.$store.commit('setSelected', { stepName, isSelected }) |
| 137 | + console.log('Step selected changed, ', this.steps) |
124 | 138 | }, |
125 | 139 | isLicenseAttribute(stepId) { |
126 | 140 | return ['BY', 'NC', 'ND', 'SA'].indexOf(stepId) > -1 |
127 | 141 | }, |
128 | | - handleNext() { |
129 | | - if (this.steps[this.currentStepId].selected === undefined) return |
130 | | - const currentStepName = this.steps[this.currentStepId].name |
131 | | - const stepSelected = this.currentStepId === 0 |
132 | | - ? this.steps[0].selected |
133 | | - : this.isAttrSelected(currentStepName) |
| 142 | + handleNext(stepName) { |
| 143 | + const stepSelected = this.steps[this.currentStepId].selected |
| 144 | + if (stepSelected === undefined && this.currentStepId <= 4) return |
134 | 145 | // update steps enabled and visible properties |
135 | 146 | // set the next enabled and visible step as current, and stepName as previous |
136 | | - this.updateDisabledAndVisibleSteps(currentStepName, |
137 | | - stepSelected) |
| 147 | + this.updateDisabledAndVisibleSteps(stepName, stepSelected) |
138 | 148 | const nextStep = this.steps.slice(this.currentStepId + 1).find(step => step.visible && step.enabled).id |
139 | 149 | this.$set(this.steps, nextStep, { ...this.steps[nextStep], status: 'current' }) |
140 | 150 | this.$set(this.steps, this.currentStepId, { ...this.steps[this.currentStepId], status: 'previous' }) |
141 | 151 | this.currentStepId = nextStep |
142 | 152 | }, |
143 | | - handlePrevious() { |
144 | | - const currentStepName = this.steps[this.currentStepId].name |
145 | | - const stepSelected = this.currentStepId === 0 |
146 | | - ? this.steps[0].selected |
147 | | - : this.isAttrSelected(currentStepName) |
148 | | - this.updateDisabledAndVisibleSteps(currentStepName, |
149 | | - stepSelected) |
| 153 | + handlePrevious(stepName) { |
| 154 | + const stepSelected = this.steps[this.currentStepId].selected |
| 155 | + console.log('Handling previous: ', this.steps[this.currentStepId], stepSelected) |
| 156 | + if (stepSelected === undefined && this.currentStepId <= 4) return |
| 157 | + this.updateDisabledAndVisibleSteps(stepName, stepSelected) |
150 | 158 | let previousStep = this.currentStepId |
151 | 159 | for (let i = this.currentStepId - 1; i >= 0; i--) { |
152 | 160 | const thisStep = this.steps[i] |
|
0 commit comments