Skip to content

Commit 1eba7d8

Browse files
committed
Remove default options from Stepper
Signed-off-by: Olga Bulat <obulat@gmail.com>
1 parent 9634a24 commit 1eba7d8

File tree

5 files changed

+38
-12
lines changed

5 files changed

+38
-12
lines changed

src/components/FirstStep.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ export default {
3333
},
3434
radio: {
3535
get() {
36-
return this.$props.selected ? 'yes' : 'no'
36+
if (this.$props.selected === undefined) {
37+
return undefined
38+
} else {
39+
return this.$props.selected ? 'yes' : 'no'
40+
}
3741
},
3842
set(newVal) {
3943
this.$emit('change', newVal === 'yes')

src/components/Step.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ export default {
4949
},
5050
radio: {
5151
get() {
52-
return this.attributes[this.$props.stepName] ? 'yes' : 'no'
52+
const selected = this.attributes[this.$props.stepName]
53+
if (selected === undefined) {
54+
return undefined
55+
} else {
56+
return selected ? 'yes' : 'no'
57+
}
5358
},
5459
set(newVal) {
5560
this.$store.commit('toggleSelected', this.$props.stepName)

src/components/Stepper.vue

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<a
5050
v-if="step.name!=='AD'"
5151
role="button"
52-
class="pagination-next"
52+
:class="['pagination-next', nextButtonDisabled(idx)]"
5353
@click="handleNext(step.name)">
5454
{{$t('step.next-label')}}
5555
</a>
@@ -96,12 +96,12 @@ export default {
9696
// eg. When we choose BY, Copyright Waiver is not shown
9797
// ENABLED: Steps are shown but disabled when they cannot be chosen
9898
// eg. When we choose ND, SA is disabled
99-
{ id: 0, name: 'FS', visible: true, enabled: true, status: 'current', selected: false },
100-
{ id: 1, name: 'BY', visible: true, enabled: true, status: 'inactive', selected: true },
101-
{ id: 2, name: 'NC', visible: true, enabled: true, status: 'inactive', selected: false },
102-
{ id: 3, name: 'ND', visible: true, enabled: true, status: 'inactive', selected: false },
103-
{ id: 4, name: 'SA', visible: true, enabled: true, status: 'inactive', selected: false },
104-
{ id: 5, name: 'CW', visible: false, enabled: true, status: 'inactive', selected: false },
99+
{ id: 0, name: 'FS', visible: true, enabled: true, status: 'current', selected: undefined },
100+
{ id: 1, name: 'BY', visible: true, enabled: true, status: 'inactive', selected: undefined },
101+
{ id: 2, name: 'NC', visible: true, enabled: true, status: 'inactive', selected: undefined },
102+
{ id: 3, name: 'ND', visible: true, enabled: true, status: 'inactive', selected: undefined },
103+
{ id: 4, name: 'SA', visible: true, enabled: true, status: 'inactive', selected: undefined },
104+
{ id: 5, name: 'CW', visible: false, enabled: true, status: 'inactive', selected: undefined },
105105
{ id: 6, name: 'DD', visible: false, enabled: true, status: 'inactive', selected: undefined },
106106
{ id: 7, name: 'AD', visible: true, enabled: true, status: 'inactive', selected: undefined }
107107
]
@@ -112,13 +112,21 @@ export default {
112112
const prefix = `stepper.${stepId}`
113113
return this.status === 'current' ? `${prefix}.question` : `${prefix}.heading`
114114
},
115+
nextButtonDisabled(stepId) {
116+
if (this.steps[stepId].selected === undefined) {
117+
return 'disabled'
118+
} else {
119+
return ''
120+
}
121+
},
115122
changeFirstStep() {
116123
this.$set(this.steps, 0, { ...this.steps[0], selected: !this.steps[0].selected })
117124
},
118125
isLicenseAttribute(stepId) {
119126
return ['BY', 'NC', 'ND', 'SA'].indexOf(stepId) > -1
120127
},
121128
handleNext() {
129+
if (this.steps[this.currentStepId].selected === undefined) return
122130
const currentStepName = this.steps[this.currentStepId].name
123131
const stepSelected = this.currentStepId === 0
124132
? this.steps[0].selected
@@ -268,6 +276,14 @@ export default {
268276
font-size: 18px;
269277
line-height: 24px;
270278
}
279+
.pagination-next.disabled {
280+
background-color: #D8D8D8;
281+
}
282+
.pagination-next.disabled:hover,
283+
.pagination-next.disabled:active {
284+
box-shadow: none;
285+
border: 1px solid transparent;
286+
}
271287
/* Tooltip container */
272288
.tooltip {
273289
position: relative;

src/store/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import Vue from 'vue'
22
import Vuex from 'vuex'
3-
import { CCBYAttributes, CC0Attributes, attrToShort, attrToFull, licenseUrl, licenseIconsArr } from '../utils/license-utilities.js'
3+
import { defaultAttributes, CC0Attributes, attrToShort, attrToFull, licenseUrl, licenseIconsArr } from '../utils/license-utilities.js'
44

55
Vue.use(Vuex)
66

77
export default new Vuex.Store({
88
state: {
9-
currentLicenseAttributes: { ...CCBYAttributes },
9+
currentLicenseAttributes: { ...defaultAttributes },
1010
attributionDetails: {
1111
creatorName: '',
1212
creatorProfileUrl: '',

src/utils/license-utilities.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const CC0Attributes = { BY: false, NC: false, ND: false, SA: false }
22
const CCBYAttributes = { BY: true, NC: false, ND: false, SA: false }
3+
const defaultAttributes = { BY: undefined, NC: undefined, ND: undefined, SA: undefined }
34
const visibleSetters = {
45
FS: {
56
true: ['FS', 'DD', 'AD'],
@@ -101,4 +102,4 @@ function licenseIconsArr(licenseAttributes) {
101102
return iconsArray
102103
}
103104

104-
export { CC0Attributes, CCBYAttributes, visibleSetters, disabledSetters, shortToAttr, attrToShort, attrToFull, licenseUrl, licenseSlug, licenseIconsArr }
105+
export { defaultAttributes, CC0Attributes, CCBYAttributes, visibleSetters, disabledSetters, shortToAttr, attrToShort, attrToFull, licenseUrl, licenseSlug, licenseIconsArr }

0 commit comments

Comments
 (0)