Skip to content

Add MultiplePictureChoice question type #159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 87 additions & 14 deletions src/assets/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ header.vff-header svg.f-logo {
margin-top: 22px;
}

.vff div.field-sectionbreaktype .f-answer {
.vff div.field-sectionbreak .f-answer {
margin-top: 18px;
}

Expand Down Expand Up @@ -444,13 +444,13 @@ header.vff-header svg.f-logo {
}

/* ios datepicker */
.vff.vff-is-ios .field-datetype:not(.f-has-value) .f-answer > span {
.vff.vff-is-ios .field-date:not(.f-has-value) .f-answer > span {
position: relative;
top: 0;
left: 0;
}

.vff.vff-is-ios .field-datetype:not(.f-has-value) .f-answer > span::before {
.vff.vff-is-ios .field-date:not(.f-has-value) .f-answer > span::before {
position: absolute;
content: attr(data-placeholder);
display: block;
Expand All @@ -468,16 +468,16 @@ header.vff-header svg.f-logo {
*/

.vff a.f-link,
.vff .field-submittype .f-section-wrap a {
.vff .field-submit .f-section-wrap a {
color: inherit;
border-bottom: 1px dotted;
word-break: break-word;
}

.vff a.f-link:hover,
.vff a.f-link:active,
.vff .field-submittype .f-section-wrap a:hover,
.vff .field-submittype .f-section-wrap a:active {
.vff .field-submit .f-section-wrap a:hover,
.vff .field-submit .f-section-wrap a:active {
color: inherit;
border-bottom: none;
}
Expand Down Expand Up @@ -575,7 +575,7 @@ header.vff-header svg.f-logo {
}

/*
f-radios (multiple-choice)
f-radios (multiple choice)
*/

.vff ul.f-radios {
Expand Down Expand Up @@ -629,6 +629,64 @@ header.vff-header svg.f-logo {
position: absolute;
}

/*
f-radios (multiple picture choice)
*/

.vff .field-multiplepicturechoice ul.f-radios{
max-width: 800px;
min-width: auto;
display: -ms-flexbox;
display: flex;
margin: 0 -8px 0 0;
flex-flow: 0 1;
-moz-box-align: stretch;
align-items: stretch;
flex-wrap: wrap;
}

.vff .field-multiplepicturechoice ul.f-radios li{
position: relative;
display: -ms-flexbox;
display: flex;
-moz-box-align: center;
align-items: center;
flex-direction: column;
padding: 8px 8px 10px;
cursor: pointer;
margin-bottom: 8px;
margin-right: 8px;
-ms-flex: 0 0 calc(25% - 8px);
flex: 0 0 calc(25% - 8px);
font-size: 15px;
line-height: 1.38;
}

.vff .field-multiplepicturechoice ul.f-radios li span.f-image{
display: flex;
display: -ms-flexbox;
-moz-box-align: center;
align-items: center;
-moz-box-pack: center;
justify-content: center;
overflow: hidden;
width: 100%;
height: 164px;
margin-bottom: 8px;
}

.vff .field-multiplepicturechoice ul.f-radios li span.f-image img{
margin-bottom: .8px;
max-height: 100%;
max-width: 100%;
}

.vff .field-multiplepicturechoice ul.f-radios li div.f-label-wrap{
width: 100%;
position: relative;
min-height: 20px;
}

/*
footer
*/
Expand Down Expand Up @@ -714,8 +772,8 @@ header.vff-header svg.f-logo {
margin-bottom: 20px;
}

.vff .field-sectionbreaktype,
.vff .field-submittype {
.vff .field-sectionbreak,
.vff .field-submit {
max-width: 920px;
}

Expand Down Expand Up @@ -805,8 +863,8 @@ header.vff-header svg.f-logo {
*/

@media only screen and (min-width: 1440px) {
.vff .field-sectionbreaktype,
.vff .field-submittype {
.vff .field-sectionbreak,
.vff .field-submit {
max-width: 960px;
}

Expand All @@ -818,8 +876,8 @@ header.vff-header svg.f-logo {
}

@media only screen and (min-width: 1920px) {
.vff .field-sectionbreaktype,
.vff .field-submittype {
.vff .field-sectionbreak,
.vff .field-submit {
max-width: 1160px;
}

Expand Down Expand Up @@ -884,6 +942,12 @@ header.vff-header svg.f-logo {
padding-right: 0;
}

.vff .field-multiplepicturechoice ul.f-radios li{
font-size: 14px;
-ms-flex: 0 0 calc(33.3333% - 8px);
flex: 0 0 calc(33.3333% - 8px);
}

}

@media screen and (max-width:479px) {
Expand Down Expand Up @@ -949,14 +1013,23 @@ header.vff-header svg.f-logo {
font-size: .62em;
}

.vff .field-sectionbreaktype p {
.vff .field-sectionbreak p {
font-size: 1em;
}

.vff-footer .f-timer {
font-size: 16px;
}

.vff .field-multiplepicturechoice ul.f-radios li span.f-image{
height: 130px;
}

.vff .field-multiplepicturechoice ul.f-radios li{
-ms-flex: 0 0 calc(50% - 8px);
flex: 0 0 calc(50% - 8px);
}

}

@media screen and (max-height:400px) {
Expand Down
8 changes: 4 additions & 4 deletions src/assets/css/themes/theme-green.css
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ header.vff-header svg.f-logo {
}

/*faux input type date placeholder for iOS*/
.vff.vff-is-ios .field-datetype:not(.f-has-value) .f-answer > span::before{
.vff.vff-is-ios .field-date:not(.f-has-value) .f-answer > span::before{
color: var(--vff-secondary-text-color);
font-weight: 300;
font-size: .72em;
}

/*field-multiplechoicetype*/
/*field-multiplechoice*/
.vff ul.f-radios li {
border: 1px solid var(--vff-secondary-text-color);
font-weight: 900;
Expand All @@ -135,7 +135,7 @@ header.vff-header svg.f-logo {
font-weight: 300;
}

/*field-dropdowntype*/
/*field-dropdown*/
.vff span.f-empty {
color: var(--vff-secondary-text-color);
}
Expand Down Expand Up @@ -275,7 +275,7 @@ header.vff-header svg.f-logo {
background-color: var(--vff-main-accent-color);
}

/*field-multiplechoicetype*/
/*field-multiplechoice*/
.vff ul.f-radios li {
color: var(--vff-secondary-text-color);
}
Expand Down
8 changes: 4 additions & 4 deletions src/assets/css/themes/theme-minimal.css
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ header.vff-header svg.f-logo{
}

/*faux input type date placeholder for iOS*/
.vff.vff-is-ios .field-datetype:not(.f-has-value) .f-answer > span::before{
.vff.vff-is-ios .field-date:not(.f-has-value) .f-answer > span::before{
color: var(--vff-secondary-text-color);
font-weight: 300;
font-size: .72em;
}

/*field-multiplechoicetype*/
/*field-multiplechoice*/
.vff ul.f-radios li {
border: 1px solid var(--vff-secondary-text-color);
}
Expand All @@ -125,7 +125,7 @@ header.vff-header svg.f-logo{
color: var(--vff-secondary-text-color);
}

/*field-dropdowntype*/
/*field-dropdown*/
.vff span.f-empty {
color: var(--vff-secondary-text-color);
}
Expand Down Expand Up @@ -278,7 +278,7 @@ header.vff-header svg.f-logo{
background-color: var(--vff-main-accent-color);
}

/*field-multiplechoicetype*/
/*field-multiplechoice*/
.vff ul.f-radios li.f-selected{
color: var(--vff-main-accent-color);
}
Expand Down
8 changes: 4 additions & 4 deletions src/assets/css/themes/theme-purple.css
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ header.vff-header svg.f-logo{
}

/*faux input type date placeholder for iOS*/
.vff.vff-is-ios .field-datetype:not(.f-has-value) .f-answer > span::before{
.vff.vff-is-ios .field-date:not(.f-has-value) .f-answer > span::before{
color: var(--vff-secondary-text-color);
font-weight: 300;
font-size: .72em;
}

/*field-multiplechoicetype*/
/*field-multiplechoice*/
.vff ul.f-radios li {
border: 1px solid var(--vff-secondary-form-bg-color);
background-color: var(--vff-main-form-bg-color);
Expand All @@ -143,7 +143,7 @@ header.vff-header svg.f-logo{
color: var(--vff-field-key-color);
}

/*field-dropdowntype*/
/*field-dropdown*/
.vff span.f-empty {
color: var(--vff-secondary-text-color);
}
Expand Down Expand Up @@ -265,7 +265,7 @@ header.vff-header svg.f-logo{
background-color: rgba(44,62,80,0.8);
}

/*field-multiplechoicetype*/
/*field-multiplechoice*/
.vff .f-key {
font-weight: 400;
}
Expand Down
11 changes: 10 additions & 1 deletion src/components/Question.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
import FlowFormEmailType from './QuestionTypes/EmailType.vue'
import FlowFormLongTextType from './QuestionTypes/LongTextType.vue'
import FlowFormMultipleChoiceType from './QuestionTypes/MultipleChoiceType.vue'
import FlowFormMultiplePictureChoiceType from './QuestionTypes/MultiplePictureChoiceType.vue'
import FlowFormNumberType from './QuestionTypes/NumberType.vue'
import FlowFormPasswordType from './QuestionTypes/PasswordType.vue'
import FlowFormPhoneType from './QuestionTypes/PhoneType.vue'
Expand All @@ -119,13 +120,15 @@
FlowFormEmailType,
FlowFormLongTextType,
FlowFormMultipleChoiceType,
FlowFormMultiplePictureChoiceType,
FlowFormNumberType,
FlowFormPasswordType,
FlowFormPhoneType,
FlowFormSectionBreakType,
FlowFormTextType,
FlowFormUrlType
},

props: {
question: QuestionModel,
language: LanguageModel,
Expand All @@ -139,25 +142,30 @@
default: false
}
},

mixins: [
IsMobile
],

data() {
return {
QuestionType: QuestionType,
dataValue: null,
debounced: false
}
},

mounted() {
this.focusField()
this.dataValue = this.question.answer

this.$refs.qanimate.addEventListener('animationend', this.onAnimationEnd)
},

beforeDestroy() {
this.$refs.qanimate.removeEventListener('animationend', this.onAnimationEnd)
},

methods: {
/**
* Autofocus the input box of the current question
Expand Down Expand Up @@ -288,6 +296,7 @@
return q.showInvalid()
}
},

computed: {
mainClasses: {
cache: false,
Expand All @@ -301,7 +310,7 @@
'f-has-value': this.$refs.questionComponent && this.$refs.questionComponent.hasValue
}

classes['field-' + this.question.type.toLowerCase().substring(8)] = true
classes['field-' + this.question.type.toLowerCase().substring(8, this.question.type.length - 4)] = true

return classes
}
Expand Down
1 change: 1 addition & 0 deletions src/components/QuestionTypes/BaseType.vue
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
return !this.question.required || this.hasValue
}
},

computed: {
placeholder() {
return this.question.placeholder || this.language.placeholder
Expand Down
Loading