File tree Expand file tree Collapse file tree 5 files changed +24
-6
lines changed
Expand file tree Collapse file tree 5 files changed +24
-6
lines changed Original file line number Diff line number Diff line change 282282 this .questions .forEach (question => {
283283 if (question .title ) {
284284 let answer = question .answer
285- if (typeof answer === ' object ' ) {
285+ if (Array . isArray ( answer) ) {
286286 answer = answer .join (' , ' )
287287 }
288288
Original file line number Diff line number Diff line change 228228 return false
229229 }
230230
231- if (! q || ! this .dataValue ) {
231+ // If there is no question referenced, or dataValue is still set to its default (null).
232+ // This allows a ChoiceOption value of false, but will not allow you to use null as a value.
233+ if (! q || this .dataValue === null ) {
232234 return false
233235 }
234236
241243 showInvalid () {
242244 const q = this .$refs .questionComponent
243245
244- if (! q || ! this .dataValue ) {
246+ if (! q || this .dataValue === null ) {
245247 return false
246248 }
247249
Original file line number Diff line number Diff line change 2525 data () {
2626 return {
2727 dirty: false ,
28- dataValue: ' ' ,
28+ dataValue: null ,
2929 answer: null ,
3030 enterPressed: false ,
3131 allowedChars: null ,
Original file line number Diff line number Diff line change 222222 stopEditOther () {
223223 this .editingOther = false
224224 }
225+ },
226+
227+ computed: {
228+ hasValue () {
229+ if (this .question .options .filter (o => o .selected ).length ) {
230+ return true
231+ }
232+
233+ if (this .question .allowOther ) {
234+ return this .question .other && this .question .other .trim ().length > 0
235+ }
236+
237+ return false
238+ }
225239 }
226240 }
227241 </script >
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ export const MaskPresets = Object.freeze({
3535export class ChoiceOption {
3636 constructor ( options ) {
3737 this . label = ''
38- this . value = ''
38+ this . value = null
3939 this . selected = false
4040
4141 Object . assign ( this , options )
@@ -46,7 +46,9 @@ export class ChoiceOption {
4646 }
4747
4848 choiceValue ( ) {
49- return this . value || this . label
49+ // Returns the value if it's anything other than the default (null).
50+ // Returns label if the value has not been set.
51+ return this . value !== null ? this . value : this . label
5052 }
5153
5254 toggle ( ) {
You can’t perform that action at this time.
0 commit comments