|
295 | 295 |
|
296 | 296 | if (!this.questions) { |
297 | 297 | const classMap = { |
298 | | - 'options': ChoiceOption, |
299 | | - 'descriptionLink': LinkOption |
| 298 | + options: ChoiceOption, |
| 299 | + descriptionLink: LinkOption |
300 | 300 | } |
301 | 301 |
|
| 302 | + window.a = this |
| 303 | +
|
302 | 304 | this |
303 | 305 | .$slots |
304 | | - .default |
305 | | - .filter(q => q.tag && q.tag.indexOf('Question') !== -1) |
| 306 | + .default()[0] |
| 307 | + .children |
| 308 | + .filter(q => q.type && q.type.name.indexOf('Question') !== -1) |
306 | 309 | .forEach(q => { |
307 | | - const attrs = q.data.attrs |
| 310 | + const props = q.props |
308 | 311 | let model = new QuestionModel() |
309 | 312 |
|
310 | | - if (q.componentInstance.question !== null) { |
311 | | - model = q.componentInstance.question |
| 313 | + if (q.question !== undefined) { |
| 314 | + model = q.question |
312 | 315 | } |
313 | 316 |
|
314 | | - if (q.data.model) { |
315 | | - model.answer = q.data.model.value |
| 317 | + if (props.modelValue) { |
| 318 | + model.answer = props.modelValue |
316 | 319 | } |
317 | 320 |
|
318 | 321 | Object.keys(model).forEach(key => { |
319 | | - if (attrs[key] !== undefined) { |
| 322 | + if (props[key] !== undefined) { |
320 | 323 | if (typeof model[key] === 'boolean') { |
321 | | - model[key] = attrs[key] !== false |
| 324 | + model[key] = props[key] !== false |
322 | 325 | } else if (key in classMap) { |
323 | 326 | const |
324 | 327 | classReference = classMap[key], |
325 | 328 | options = [] |
326 | 329 |
|
327 | | - attrs[key].forEach(option => { |
| 330 | + props[key].forEach(option => { |
328 | 331 | const instance = new classReference() |
329 | 332 |
|
330 | 333 | Object.keys(instance).forEach(instanceKey => { |
|
340 | 343 | } else { |
341 | 344 | switch(key) { |
342 | 345 | case 'type': |
343 | | - if (Object.values(QuestionType).indexOf(attrs[key]) !== -1) { |
344 | | - model[key] = attrs[key] |
| 346 | + if (Object.values(QuestionType).indexOf(props[key]) !== -1) { |
| 347 | + model[key] = props[key] |
345 | 348 | } else { |
346 | 349 | for (const questionTypeKey in QuestionType) { |
347 | | - if (questionTypeKey.toLowerCase() === attrs[key].toLowerCase()) { |
| 350 | + if (questionTypeKey.toLowerCase() === props[key].toLowerCase()) { |
348 | 351 | model[key] = QuestionType[questionTypeKey] |
349 | 352 | break |
350 | 353 | } |
|
353 | 356 | break |
354 | 357 |
|
355 | 358 | default: |
356 | | - model[key] = attrs[key] |
| 359 | + model[key] = props[key] |
357 | 360 | break |
358 | 361 | } |
359 | 362 | } |
360 | 363 | } |
361 | 364 | }) |
362 | 365 |
|
363 | | - q.componentInstance.question = model |
| 366 | + q.question = model |
364 | 367 |
|
365 | 368 | model.resetOptions() |
366 | 369 |
|
|
0 commit comments