@wg-npm/survey-response 0.5.157 → 0.5.159

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -179,26 +179,67 @@ var __vue_staticRenderFns__$h = [];
179
179
 
180
180
  var EmptyQuestion = __vue_component__$h;
181
181
 
182
+ var OptionLayoutMixin = Vue.extend({
183
+ props: {
184
+ options: {
185
+ type: Object,
186
+ }
187
+ },
188
+ methods: {
189
+ isMobile() {
190
+ const val = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i);
191
+ return !_.isEmpty(val);
192
+ },
193
+ },
194
+ computed: {
195
+ optionLayout() {
196
+ const globalLayout = _.lowerCase(_.get(this.options, "layout", "horizontal"));
197
+ return `question-choice-${globalLayout}`;
198
+ },
199
+ },
200
+ });
201
+
202
+ var QuestionMixin = Vue.extend({
203
+ props: {
204
+ index: Number,
205
+ surveyIndex: Number,
206
+ isMoreSurvey: {
207
+ type: Boolean,
208
+ required: false,
209
+ default: false,
210
+ },
211
+ },
212
+ computed: {
213
+ answerProp() {
214
+ return this.isMoreSurvey
215
+ ? `moreSurveyAnswers[${this.surveyIndex}].answers[${this.index}].answer`
216
+ : `answers[${this.index}].answer`;
217
+ },
218
+ },
219
+ methods: {},
220
+ });
221
+
182
222
  var script$g = Vue.extend({
183
223
  name: "question-title",
224
+ mixins: [OptionLayoutMixin, QuestionMixin],
184
225
  components: { Icon },
185
226
  inject: ["$rootComponent"],
186
227
  props: {
187
228
  index: {
188
229
  type: Number,
189
- default: 0,
230
+ default: 0
190
231
  },
191
232
  question: {
192
233
  type: Object,
193
- required: true,
234
+ required: true
194
235
  },
195
236
  language: {
196
- type: String,
237
+ type: String
197
238
  },
198
239
  customQuestion: {
199
240
  type: Object,
200
- required: false,
201
- },
241
+ required: false
242
+ }
202
243
  },
203
244
  computed: {
204
245
  customFilledTitle() {
@@ -209,7 +250,7 @@ var script$g = Vue.extend({
209
250
  },
210
251
  isSingleSelection() {
211
252
  return this.question.type == "SINGLE_SELECTION";
212
- },
253
+ }
213
254
  },
214
255
  methods: {
215
256
  getShowInput(index, formatTitle) {
@@ -217,18 +258,18 @@ var script$g = Vue.extend({
217
258
  },
218
259
  getTitle(question) {
219
260
  return formatTitle(question, this.$rootComponent.currentLanguage);
220
- },
221
- },
261
+ }
262
+ }
222
263
  });
223
264
 
224
265
  /* script */
225
266
  const __vue_script__$g = script$g;
226
267
 
227
268
  /* template */
228
- var __vue_render__$g = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"question-title"},[(_vm.question.type !== 'text_title')?_c('span',{staticClass:"pr-sm"},[(_vm.question.options.required)?_c('label',{staticClass:"require-label"},[_vm._v("*")]):_vm._e(),_vm._v(" "),(_vm.question.header.number)?_c('label',{staticClass:"number"},[_vm._v(_vm._s(_vm.question.header.number)+".")]):_vm._e()]):_vm._e(),_vm._v(" "),_vm._l((_vm.getTitle(_vm.question)),function(title,index){return _c('div',{key:index,staticClass:"flex"},[(title !== '')?_c('span',{staticClass:"content"},[_vm._v(_vm._s(title))]):_vm._e(),_vm._v(" "),_vm._l((_vm.customFilledTitle),function(customTitle){return _c('div',{key:index + customTitle.index},[(title === '' && index === customTitle.index)?_c('span',{staticClass:"content"},[_vm._v(_vm._s(customTitle.title))]):_c('div',[(
269
+ var __vue_render__$g = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"question-title",style:({'display':(_vm.isMobile()?'inline-block':'')})},[(_vm.question.type !== 'text_title')?_c('span',{staticClass:"pr-sm",style:({'display':(_vm.isMobile()?'inline-block':'')})},[(_vm.question.options.required)?_c('label',{staticClass:"require-label"},[_vm._v("*")]):_vm._e(),_vm._v(" "),(_vm.question.header.number)?_c('label',{staticClass:"number"},[_vm._v(_vm._s(_vm.question.header.number)+".")]):_vm._e()]):_vm._e(),_vm._v(" "),_vm._l((_vm.getTitle(_vm.question)),function(title,index){return _c('div',{key:index,staticClass:"flex",style:({'display':(_vm.isMobile()?'inline-block':'')})},[(title !== '')?_c('span',{staticClass:"content"},[_vm._v(_vm._s(title))]):_vm._e(),_vm._v(" "),_vm._l((_vm.customFilledTitle),function(customTitle){return _c('div',{key:index + customTitle.index},[(title === '' && index === customTitle.index)?_c('span',{staticClass:"content"},[_vm._v(_vm._s(customTitle.title))]):_c('div',[(
229
270
  _vm.getShowInput(index, _vm.getTitle(_vm.question)) &&
230
271
  index === customTitle.index
231
- )?_c('span',{staticClass:"content"},[_vm._v(_vm._s(customTitle.title))]):_vm._e()])])})],2)}),_vm._v(" "),(_vm.haveStar)?_c('span',{staticClass:"options-explain"},[(_vm.isSingleSelection)?_c('span',[_vm._v("\n ("+_vm._s(_vm.t(
272
+ )?_c('span',{staticClass:"content"},[_vm._v(_vm._s(customTitle.title))]):_vm._e()])])})],2)}),_vm._v(" "),(_vm.haveStar)?_c('span',{staticClass:"options-explain",style:({'display':(_vm.isMobile()?'block':'')})},[(_vm.isSingleSelection)?_c('span',[_vm._v("\n ("+_vm._s(_vm.t(
232
273
  "survey_creator.question.star_single",
233
274
  _vm.$rootComponent.currentLanguage
234
275
  ))+"\n "),_c('span',[_c('Icon',{attrs:{"type":"md-star","color":"orange","size":16}})],1),_vm._v(")\n ")]):_c('span',[_vm._v("\n (\n "+_vm._s(_vm.t(
@@ -246,11 +287,11 @@ var __vue_staticRenderFns__$g = [];
246
287
  /* style */
247
288
  const __vue_inject_styles__$g = function (inject) {
248
289
  if (!inject) return
249
- inject("data-v-32eb22f3_0", { source: ".flex[data-v-32eb22f3]{display:flex;align-items:center;white-space:nowrap}.pr-sm[data-v-32eb22f3]{padding-right:4px}", map: undefined, media: undefined });
290
+ inject("data-v-67dae2e1_0", { source: ".flex[data-v-67dae2e1]{display:flex;align-items:center;white-space:nowrap}.pr-sm[data-v-67dae2e1]{padding-right:4px}", map: undefined, media: undefined });
250
291
 
251
292
  };
252
293
  /* scoped */
253
- const __vue_scope_id__$g = "data-v-32eb22f3";
294
+ const __vue_scope_id__$g = "data-v-67dae2e1";
254
295
  /* module identifier */
255
296
  const __vue_module_identifier__$g = undefined;
256
297
  /* functional template */
@@ -276,45 +317,6 @@ var __vue_staticRenderFns__$g = [];
276
317
 
277
318
  var QuestionTitle = __vue_component__$g;
278
319
 
279
- var OptionLayoutMixin = Vue.extend({
280
- methods: {
281
- isMobile() {
282
- const flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i);
283
- return flag;
284
- },
285
- },
286
- computed: {
287
- optionLayout() {
288
- const globalLayout = _.lowerCase(_.get(this.options, "layout", undefined));
289
- if (this.isMobile() || "vertical" == globalLayout) {
290
- return "";
291
- }
292
- const questionLayout = _.lowerCase(_.get(this.question.options, "layout", "horizontal"));
293
- return `question-choice-${questionLayout}`;
294
- },
295
- },
296
- });
297
-
298
- var QuestionMixin = Vue.extend({
299
- props: {
300
- index: Number,
301
- surveyIndex: Number,
302
- isMoreSurvey: {
303
- type: Boolean,
304
- required: false,
305
- default: false,
306
- },
307
- },
308
- computed: {
309
- answerProp() {
310
- return this.isMoreSurvey
311
- ? `moreSurveyAnswers[${this.surveyIndex}].answers[${this.index}].answer`
312
- : `answers[${this.index}].answer`;
313
- },
314
- },
315
- methods: {},
316
- });
317
-
318
320
  var script$f = Vue.extend({
319
321
  name: "multi-selection",
320
322
  inject: ["responseStatus", "$rootComponent"],
@@ -325,27 +327,37 @@ var script$f = Vue.extend({
325
327
  Checkbox,
326
328
  Row,
327
329
  Col,
328
- Input,
330
+ Input
329
331
  },
330
332
  props: {
331
333
  question: {
332
334
  type: Object,
333
- required: true,
335
+ required: true
334
336
  },
335
337
  answer: {
336
338
  type: Object,
337
- required: true,
338
- },
339
+ required: true
340
+ }
339
341
  },
340
342
  data() {
341
343
  return {
342
- value: this.answer,
344
+ value: this.answer
343
345
  };
344
346
  },
345
347
  watch: {
346
348
  answer(n) {
347
349
  this.value = n;
348
- },
350
+ }
351
+ },
352
+ computed: {
353
+ flexOrBlock() {
354
+ if (this.isMobile()) {
355
+ return "inline-block";
356
+ }
357
+ else {
358
+ return "flex";
359
+ }
360
+ }
349
361
  },
350
362
  methods: {
351
363
  inputAnswerProp(inputIndex) {
@@ -397,8 +409,8 @@ var script$f = Vue.extend({
397
409
  this.answer.star =
398
410
  minStarCount >= this.question.options.starMinCount ? 1 : 0;
399
411
  }
400
- },
401
- },
412
+ }
413
+ }
402
414
  });
403
415
 
404
416
  /* script */
@@ -410,7 +422,7 @@ var __vue_render__$f = function () {var _vm=this;var _h=_vm.$createElement;var _
410
422
  type: 'array',
411
423
  min: 1,
412
424
  message: _vm.t('survey_response.question.question_required'),
413
- }}},[_c('CheckboxGroup',{on:{"on-change":_vm.selChange},model:{value:(_vm.value.answer),callback:function ($$v) {_vm.$set(_vm.value, "answer", $$v);},expression:"value.answer"}},[_c('Row',{attrs:{"type":"flex","justify":"start","gutter":60}},_vm._l((_vm.question.choices),function(choice){return _c('Col',{key:choice.id,class:_vm.optionLayout,staticStyle:{"display":"flex"}},[_c('Checkbox',{key:choice.id,attrs:{"label":choice.id,"disabled":_vm.question.options.readonly ||
425
+ }}},[_c('CheckboxGroup',{on:{"on-change":_vm.selChange},model:{value:(_vm.value.answer),callback:function ($$v) {_vm.$set(_vm.value, "answer", $$v);},expression:"value.answer"}},[_c('Row',{style:({'display':(_vm.isMobile()?'inline-block':'flex')}),attrs:{"type":_vm.flexOrBlock,"justify":"start","gutter":60}},_vm._l((_vm.question.choices),function(choice){return _c('Col',{key:choice.id,class:_vm.optionLayout,style:({'display':(_vm.isMobile()?'inline-block':'flex')})},[_c('Checkbox',{key:choice.id,style:({'display':(_vm.isMobile()?'inline-block':'flex'),'align-items':(_vm.isMobile()?'':'center')}),attrs:{"label":choice.id,"disabled":_vm.question.options.readonly ||
414
426
  choice.readonly ||
415
427
  _vm.question.options.disabled}},[_c('span',[_vm._v(_vm._s(_vm.i18nText(choice.text)))])]),_vm._v(" "),_vm._l((_vm.value.inputAnswers),function(inputAnswer,inputIndex){return _c('div',{key:inputIndex},[(
416
428
  choice.id === inputAnswer.choiceId &&
@@ -433,11 +445,11 @@ var __vue_staticRenderFns__$f = [];
433
445
  /* style */
434
446
  const __vue_inject_styles__$f = function (inject) {
435
447
  if (!inject) return
436
- inject("data-v-3976b9fb_0", { source: ".ivu-row-flex-start[data-v-3976b9fb]{align-items:center}.ivu-checkbox-group-item[data-v-3976b9fb]{display:flex;flex-direction:row}.choice-title[data-v-3976b9fb]{margin-left:8px;margin-right:8px}.choice-score[data-v-3976b9fb]{margin-right:8px}[data-v-3976b9fb] .ivu-checkbox-inner{margin-top:8px}.ivu-checkbox-wrapper[data-v-3976b9fb]{white-space:nowrap}", map: undefined, media: undefined });
448
+ inject("data-v-7b3b232e_0", { source: ".choice-title[data-v-7b3b232e]{margin-left:8px;margin-right:8px}.choice-score[data-v-7b3b232e]{margin-right:8px}.ivu-checkbox-wrapper[data-v-7b3b232e]{white-space:nowrap}", map: undefined, media: undefined });
437
449
 
438
450
  };
439
451
  /* scoped */
440
- const __vue_scope_id__$f = "data-v-3976b9fb";
452
+ const __vue_scope_id__$f = "data-v-7b3b232e";
441
453
  /* module identifier */
442
454
  const __vue_module_identifier__$f = undefined;
443
455
  /* functional template */
@@ -568,24 +580,24 @@ var script$d = Vue.extend({
568
580
  Row,
569
581
  Col,
570
582
  Icon,
571
- Input,
583
+ Input
572
584
  },
573
585
  mixins: [OptionLayoutMixin, QuestionMixin],
574
586
  inject: ["responseStatus", "$rootComponent"],
575
587
  props: {
576
588
  question: {
577
589
  type: Object,
578
- required: true,
590
+ required: true
579
591
  },
580
592
  answer: {
581
593
  type: Object,
582
- required: true,
583
- },
594
+ required: true
595
+ }
584
596
  },
585
597
  data() {
586
598
  return {
587
599
  value: this.answer,
588
- choiceClasses: this.buildChoiceClasses(),
600
+ choiceClasses: this.buildChoiceClasses()
589
601
  };
590
602
  },
591
603
  watch: {
@@ -594,7 +606,17 @@ var script$d = Vue.extend({
594
606
  },
595
607
  answer(n) {
596
608
  this.value = n;
597
- },
609
+ }
610
+ },
611
+ computed: {
612
+ flexOrBlock() {
613
+ if (this.isMobile()) {
614
+ return "inline-block";
615
+ }
616
+ else {
617
+ return "flex";
618
+ }
619
+ }
598
620
  },
599
621
  methods: {
600
622
  inputAnswerProp(inputIndex) {
@@ -613,7 +635,7 @@ var script$d = Vue.extend({
613
635
  buildChoiceClasses() {
614
636
  return [
615
637
  `question-choice`,
616
- `question-choice-${_.lowerCase(this.question.options.layout || "HORIZONTAL")}`,
638
+ `question-choice-${_.lowerCase(this.question.options.layout || "HORIZONTAL")}`
617
639
  ];
618
640
  },
619
641
  haveStar(choice) {
@@ -638,10 +660,10 @@ var script$d = Vue.extend({
638
660
  }
639
661
  this.$emit("singleQuestion", {
640
662
  questionId: this.question.id,
641
- choiceId: this.value.answer,
663
+ choiceId: this.value.answer
642
664
  });
643
- },
644
- },
665
+ }
666
+ }
645
667
  });
646
668
 
647
669
  /* script */
@@ -651,7 +673,7 @@ const __vue_script__$d = script$d;
651
673
  var __vue_render__$d = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('FormItem',{attrs:{"prop":_vm.answerProp,"rules":{
652
674
  required: _vm.question.options.required && !_vm.question.options.disabled,
653
675
  message: _vm.t('survey_response.question.question_required'),
654
- }}},[_c('RadioGroup',{staticClass:"question-choice",on:{"on-change":_vm.selChange},model:{value:(_vm.value.answer),callback:function ($$v) {_vm.$set(_vm.value, "answer", $$v);},expression:"value.answer"}},[_c('Row',{attrs:{"type":"flex","justify":"start","gutter":60}},_vm._l((_vm.question.choices),function(choice){return _c('Col',{key:choice.id,class:_vm.optionLayout,staticStyle:{"display":"flex"}},[_c('Radio',{key:choice.id,attrs:{"disabled":_vm.question.options.readonly || _vm.question.options.disabled,"label":choice.id},nativeOn:{"click":function($event){return _vm.toggleAnswer($event, choice.id, _vm.question.options.disabled)}}},[(_vm.haveStar(choice))?_c('span',[_c('Icon',{attrs:{"type":"md-star","color":"orange","size":16}})],1):_vm._e(),_vm._v(" "),_c('span',[_vm._v(_vm._s(_vm.i18nText(choice.text)))])]),_vm._v(" "),_vm._l((_vm.value.inputAnswers),function(inputAnswer,inputIndex){return _c('div',{key:inputIndex},[(
676
+ }}},[_c('RadioGroup',{staticClass:"question-choice",on:{"on-change":_vm.selChange},model:{value:(_vm.value.answer),callback:function ($$v) {_vm.$set(_vm.value, "answer", $$v);},expression:"value.answer"}},[_c('Row',{style:({'display':(_vm.isMobile()?'inline-block':'flex')}),attrs:{"type":_vm.flexOrBlock,"justify":"start","gutter":60}},_vm._l((_vm.question.choices),function(choice){return _c('Col',{key:choice.id,class:_vm.optionLayout,style:({'display':(_vm.isMobile()?'inline-block':'flex')})},[_c('Radio',{key:choice.id,style:({'display':(_vm.isMobile()?'inline-block':'flex'),'align-items':(_vm.isMobile()?'':'center')}),attrs:{"disabled":_vm.question.options.readonly || _vm.question.options.disabled,"label":choice.id},nativeOn:{"click":function($event){return _vm.toggleAnswer($event, choice.id, _vm.question.options.disabled)}}},[(_vm.haveStar(choice))?_c('span',[_c('Icon',{attrs:{"type":"md-star","color":"orange","size":16}})],1):_vm._e(),_vm._v(" "),_c('span',[_vm._v(_vm._s(_vm.i18nText(choice.text)))])]),_vm._v(" "),_vm._l((_vm.value.inputAnswers),function(inputAnswer,inputIndex){return _c('div',{key:inputIndex},[(
655
677
  choice.id === inputAnswer.choiceId && choice.id === _vm.value.answer
656
678
  )?_c('FormItem',{attrs:{"prop":_vm.inputAnswerProp(inputIndex),"rules":[
657
679
  {
@@ -671,11 +693,11 @@ var __vue_staticRenderFns__$d = [];
671
693
  /* style */
672
694
  const __vue_inject_styles__$d = function (inject) {
673
695
  if (!inject) return
674
- inject("data-v-eb1364b8_0", { source: ".ivu-row-flex-start[data-v-eb1364b8]{align-items:center}.ivu-radio-group-item[data-v-eb1364b8]{display:flex;flex-direction:row}.choice-title[data-v-eb1364b8]{margin-left:8px;margin-right:8px}[data-v-eb1364b8] .ivu-radio-inner{margin-top:8px}", map: undefined, media: undefined });
696
+ inject("data-v-02ccf75f_0", { source: ".choice-title[data-v-02ccf75f]{margin-left:8px;margin-right:8px}", map: undefined, media: undefined });
675
697
 
676
698
  };
677
699
  /* scoped */
678
- const __vue_scope_id__$d = "data-v-eb1364b8";
700
+ const __vue_scope_id__$d = "data-v-02ccf75f";
679
701
  /* module identifier */
680
702
  const __vue_module_identifier__$d = undefined;
681
703
  /* functional template */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wg-npm/survey-response",
3
- "version": "0.5.157",
3
+ "version": "0.5.159",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -12,8 +12,8 @@
12
12
  "lint-fix": "eslint \"**/*.ts\" \"**/*.vue\" --fix --no-error-on-unmatched-pattern"
13
13
  },
14
14
  "peerDependencies": {
15
- "@wg-npm/survey-core": "0.5.157",
16
- "@wg-npm/survey-service-api": "0.5.157",
15
+ "@wg-npm/survey-core": "0.5.159",
16
+ "@wg-npm/survey-service-api": "0.5.159",
17
17
  "axios": "^0.19.2",
18
18
  "deepmerge": "^4.2.2",
19
19
  "lodash": "^4.17.15",
@@ -34,8 +34,8 @@
34
34
  "@typescript-eslint/parser": "^3.6.0",
35
35
  "@vue/eslint-config-prettier": "^6.0.0",
36
36
  "@vue/eslint-config-typescript": "^5.0.2",
37
- "@wg-npm/survey-core": "0.5.157",
38
- "@wg-npm/survey-service-api": "0.5.157",
37
+ "@wg-npm/survey-core": "0.5.159",
38
+ "@wg-npm/survey-service-api": "0.5.159",
39
39
  "acorn": "^7.3.1",
40
40
  "axios": "^0.19.2",
41
41
  "babelrc-rollup": "^3.0.0",
@@ -1,13 +1,13 @@
1
1
  <template>
2
- <div class="question-title">
3
- <span v-if="question.type !== 'text_title'" class="pr-sm">
2
+ <div class="question-title" :style="{'display':(isMobile()?'inline-block':'')}">
3
+ <span v-if="question.type !== 'text_title'" class="pr-sm" :style="{'display':(isMobile()?'inline-block':'')}">
4
4
  <label v-if="question.options.required" class="require-label">*</label>
5
5
  <label v-if="question.header.number" class="number"
6
- >{{ question.header.number }}.</label
6
+ >{{ question.header.number }}.</label
7
7
  >
8
8
  </span>
9
9
 
10
- <div class="flex" v-for="(title, index) in getTitle(question)" :key="index">
10
+ <div class="flex" v-for="(title, index) in getTitle(question)" :key="index" :style="{'display':(isMobile()?'inline-block':'')}">
11
11
  <span v-if="title !== ''" class="content">{{ title }}</span>
12
12
  <div
13
13
  v-for="customTitle in customFilledTitle"
@@ -16,7 +16,7 @@
16
16
  <span
17
17
  class="content"
18
18
  v-if="title === '' && index === customTitle.index"
19
- >{{ customTitle.title }}</span
19
+ >{{ customTitle.title }}</span
20
20
  >
21
21
 
22
22
  <div v-else>
@@ -26,13 +26,13 @@
26
26
  getShowInput(index, getTitle(question)) &&
27
27
  index === customTitle.index
28
28
  "
29
- >{{ customTitle.title }}</span
29
+ >{{ customTitle.title }}</span
30
30
  >
31
31
  </div>
32
32
  </div>
33
33
  </div>
34
34
 
35
- <span class="options-explain" v-if="haveStar">
35
+ <span class="options-explain" v-if="haveStar" :style="{'display':(isMobile()?'block':'')}">
36
36
  <span v-if="isSingleSelection">
37
37
  ({{
38
38
  t(
@@ -70,65 +70,69 @@
70
70
  </div>
71
71
  </template>
72
72
  <script lang="ts">
73
- import Vue from "vue";
74
- import { Icon } from "view-design";
75
- import {
76
- BaseQuestionModel,
77
- formatTitle,
78
- QuestionType,
79
- showInput,
80
- } from "@wg-npm/survey-core";
73
+ import Vue from "vue";
74
+ import OptionLayoutMixin from "../../mixins/option-layout-mixin";
75
+ import { Icon } from "view-design";
76
+ import {
77
+ BaseQuestionModel,
78
+ formatTitle,
79
+ QuestionType,
80
+ showInput
81
+ } from "@wg-npm/survey-core";
82
+ import QuestionMixin from "../../mixins/question-mixin";
81
83
 
82
- export default Vue.extend({
83
- name: "question-title",
84
- components: { Icon },
85
- inject: ["$rootComponent"],
86
- props: {
87
- index: {
88
- type: Number,
89
- default: 0,
90
- },
91
- question: {
92
- type: Object,
93
- required: true,
94
- },
95
- language: {
96
- type: String,
97
- },
98
- customQuestion: {
99
- type: Object,
100
- required: false,
84
+ export default Vue.extend({
85
+ name: "question-title",
86
+ mixins: [OptionLayoutMixin, QuestionMixin],
87
+ components: { Icon },
88
+ inject: ["$rootComponent"],
89
+ props: {
90
+ index: {
91
+ type: Number,
92
+ default: 0
93
+ },
94
+ question: {
95
+ type: Object,
96
+ required: true
97
+ },
98
+ language: {
99
+ type: String
100
+ },
101
+ customQuestion: {
102
+ type: Object,
103
+ required: false
104
+ }
101
105
  },
102
- },
103
- computed: {
104
- customFilledTitle() {
105
- return this.customQuestion?.filledTitle;
106
+ computed: {
107
+ customFilledTitle() {
108
+ return this.customQuestion?.filledTitle;
109
+ },
110
+ haveStar() {
111
+ return this.question?.options?.starEnabled ?? false;
112
+ },
113
+ isSingleSelection() {
114
+ return this.question.type == QuestionType.SINGLE_SELECTION;
115
+ }
106
116
  },
107
- haveStar() {
108
- return this.question?.options?.starEnabled ?? false;
109
- },
110
- isSingleSelection() {
111
- return this.question.type == QuestionType.SINGLE_SELECTION;
112
- },
113
- },
114
- methods: {
115
- getShowInput(index, formatTitle) {
116
- return showInput(index, formatTitle);
117
- },
118
- getTitle(question) {
119
- return formatTitle(question, this.$rootComponent.currentLanguage);
120
- },
121
- },
122
- });
117
+ methods: {
118
+ getShowInput(index, formatTitle) {
119
+ return showInput(index, formatTitle);
120
+ },
121
+ getTitle(question) {
122
+ return formatTitle(question, this.$rootComponent.currentLanguage);
123
+ }
124
+ }
125
+ });
123
126
  </script>
124
127
 
125
128
  <style lang="less" scoped>
126
- .flex {
127
- display: flex;
128
- align-items: center;
129
- white-space: nowrap;
130
- }
131
- .pr-sm {
132
- padding-right: 4px;
133
- }
129
+ .flex {
130
+ display: flex;
131
+ align-items: center;
132
+ white-space: nowrap;
133
+ }
134
+
135
+ .pr-sm {
136
+ padding-right: 4px;
137
+ }
134
138
  </style>
@@ -9,14 +9,15 @@
9
9
  }"
10
10
  >
11
11
  <CheckboxGroup v-model="value.answer" @on-change="selChange">
12
- <Row type="flex" justify="start" :gutter="60">
12
+ <Row :type="flexOrBlock" justify="start" :gutter="60" :style="{'display':(isMobile()?'inline-block':'flex')}">
13
13
  <Col
14
14
  v-for="choice in question.choices"
15
15
  :key="choice.id"
16
16
  :class="optionLayout"
17
- style="display: flex"
17
+ :style="{'display':(isMobile()?'inline-block':'flex')}"
18
18
  >
19
19
  <Checkbox
20
+ :style="{'display':(isMobile()?'inline-block':'flex'),'align-items':(isMobile()?'':'center')}"
20
21
  :label="choice.id"
21
22
  :key="choice.id"
22
23
  :disabled="
@@ -55,10 +56,10 @@
55
56
  ]"
56
57
  >
57
58
  <Span v-if="responseStatus=='ENABLED'">
58
- {{inputAnswer.inputText}}</Span>
59
- <Input v-if="responseStatus=='DRAFT'"
60
- v-model.trim="inputAnswer.inputText"
61
- />
59
+ {{ inputAnswer.inputText }}</Span>
60
+ <Input v-if="responseStatus=='DRAFT'"
61
+ v-model.trim="inputAnswer.inputText"
62
+ />
62
63
 
63
64
  </FormItem>
64
65
  </div>
@@ -68,138 +69,134 @@
68
69
  </FormItem>
69
70
  </template>
70
71
  <script lang="ts">
71
- import Vue from "vue";
72
- import _ from "lodash";
73
- import OptionLayoutMixin from "../../../mixins/option-layout-mixin";
74
- import QuestionMixin from "../../../mixins/question-mixin";
75
- import {
76
- FormItem,
77
- CheckboxGroup,
78
- Checkbox,
79
- Row,
80
- Col,
81
- Input,
82
- } from "view-design";
83
-
84
- export default Vue.extend({
85
- name: "multi-selection",
86
- inject: ["responseStatus","$rootComponent"],
87
- mixins: [OptionLayoutMixin, QuestionMixin],
88
- components: {
72
+ import Vue from "vue";
73
+ import _ from "lodash";
74
+ import OptionLayoutMixin from "../../../mixins/option-layout-mixin";
75
+ import QuestionMixin from "../../../mixins/question-mixin";
76
+ import {
89
77
  FormItem,
90
78
  CheckboxGroup,
91
79
  Checkbox,
92
80
  Row,
93
81
  Col,
94
- Input,
95
- },
96
- props: {
97
- question: {
98
- type: Object,
99
- required: true,
82
+ Input
83
+ } from "view-design";
84
+
85
+ export default Vue.extend({
86
+ name: "multi-selection",
87
+ inject: ["responseStatus", "$rootComponent"],
88
+ mixins: [OptionLayoutMixin, QuestionMixin],
89
+ components: {
90
+ FormItem,
91
+ CheckboxGroup,
92
+ Checkbox,
93
+ Row,
94
+ Col,
95
+ Input
100
96
  },
101
- answer: {
102
- type: Object,
103
- required: true,
97
+ props: {
98
+ question: {
99
+ type: Object,
100
+ required: true
101
+ },
102
+ answer: {
103
+ type: Object,
104
+ required: true
105
+ }
104
106
  },
105
- },
106
- data() {
107
- return {
108
- value: this.answer,
109
- };
110
- },
111
- watch: {
112
- answer(n) {
113
- this.value = n;
107
+ data() {
108
+ return {
109
+ value: this.answer
110
+ };
114
111
  },
115
- },
116
- methods: {
117
- inputAnswerProp(inputIndex) {
118
- return this.isMoreSurvey
119
- ? `moreSurveyAnswers[${this.surveyIndex}].answers[${this.index}].inputAnswers[${inputIndex}].inputText`
120
- : `answers[${this.index}].inputAnswers[${inputIndex}].inputText`;
112
+ watch: {
113
+ answer(n) {
114
+ this.value = n;
115
+ }
121
116
  },
122
- setCheckboxStatus() {
123
- let exclusiveChoiceId = "";
124
- const notExclusiveChoices = new Array();
125
- // @ts-ignore
126
- _.each(this.question.choices, (choice) => {
127
- if (choice.options.exclusiveEnabled) {
128
- exclusiveChoiceId = choice.id;
117
+ computed: {
118
+ flexOrBlock() {
119
+ if (this.isMobile()) {
120
+ return "inline-block";
129
121
  } else {
130
- notExclusiveChoices.push(choice);
122
+ return "flex";
131
123
  }
132
- });
124
+ }
125
+ },
126
+ methods: {
127
+ inputAnswerProp(inputIndex) {
128
+ return this.isMoreSurvey
129
+ ? `moreSurveyAnswers[${this.surveyIndex}].answers[${this.index}].inputAnswers[${inputIndex}].inputText`
130
+ : `answers[${this.index}].inputAnswers[${inputIndex}].inputText`;
131
+ },
132
+ setCheckboxStatus() {
133
+ let exclusiveChoiceId = "";
134
+ const notExclusiveChoices = new Array();
135
+ // @ts-ignore
136
+ _.each(this.question.choices, (choice) => {
137
+ if (choice.options.exclusiveEnabled) {
138
+ exclusiveChoiceId = choice.id;
139
+ } else {
140
+ notExclusiveChoices.push(choice);
141
+ }
142
+ });
133
143
 
134
- // @ts-ignore
135
- _.each(notExclusiveChoices, (choice) => {
136
144
  // @ts-ignore
137
- choice.readonly = _.includes(this.value.answer, exclusiveChoiceId);
138
- });
139
- },
140
- selChange(val) {
141
- let score = 0;
142
- let minStarCount = 0;
143
- // @ts-ignore
144
- _.each(this.question.choices, (choice) => {
145
+ _.each(notExclusiveChoices, (choice) => {
146
+ // @ts-ignore
147
+ choice.readonly = _.includes(this.value.answer, exclusiveChoiceId);
148
+ });
149
+ },
150
+ selChange(val) {
151
+ let score = 0;
152
+ let minStarCount = 0;
145
153
  // @ts-ignore
146
- _.each(val, (id) => {
147
- if (choice.id == id) {
148
- if (choice.options.exclusiveEnabled) {
149
- this.value.answer = [id];
150
- score = parseInt(choice?.options?.score ?? 0);
151
- minStarCount = 1;
152
- } else {
153
- score += parseInt(choice?.options?.score ?? 0);
154
- minStarCount++;
154
+ _.each(this.question.choices, (choice) => {
155
+ // @ts-ignore
156
+ _.each(val, (id) => {
157
+ if (choice.id == id) {
158
+ if (choice.options.exclusiveEnabled) {
159
+ this.value.answer = [id];
160
+ score = parseInt(choice?.options?.score ?? 0);
161
+ minStarCount = 1;
162
+ } else {
163
+ score += parseInt(choice?.options?.score ?? 0);
164
+ minStarCount++;
165
+ }
155
166
  }
167
+ });
168
+ });
169
+
170
+ //处理输入题
171
+ _.forEach(this.value.inputAnswers, (input) => {
172
+ if (!_.includes(val, input.choiceId)) {
173
+ input.inputText = null;
156
174
  }
157
175
  });
158
- });
176
+ this.setCheckboxStatus();
159
177
 
160
- //处理输入题
161
- _.forEach(this.value.inputAnswers, (input) => {
162
- if (!_.includes(val, input.choiceId)) {
163
- input.inputText = null;
178
+ // @ts-ignore
179
+ this.answer.score = score;
180
+ if (this.question.options.starEnabled) {
181
+ this.answer.star =
182
+ minStarCount >= this.question.options.starMinCount ? 1 : 0;
164
183
  }
165
- });
166
- this.setCheckboxStatus();
167
-
168
- // @ts-ignore
169
- this.answer.score = score;
170
- if (this.question.options.starEnabled) {
171
- this.answer.star =
172
- minStarCount >= this.question.options.starMinCount ? 1 : 0;
173
184
  }
174
- },
175
- },
176
- });
185
+ }
186
+ });
177
187
  </script>
178
188
 
179
189
  <style lang="less" scoped>
180
- .ivu-row-flex-start {
181
- align-items: center;
182
- }
183
- .ivu-checkbox-group-item {
184
- display: flex;
185
- flex-direction: row;
186
- }
187
-
188
- .choice-title {
189
- margin-left: 8px;
190
- margin-right: 8px;
191
- }
192
-
193
-
194
- .choice-score {
195
- margin-right: 8px;
196
- }
190
+ .choice-title {
191
+ margin-left: 8px;
192
+ margin-right: 8px;
193
+ }
197
194
 
198
- /deep/ .ivu-checkbox-inner {
199
- margin-top: 8px;
200
- }
195
+ .choice-score {
196
+ margin-right: 8px;
197
+ }
201
198
 
202
- .ivu-checkbox-wrapper{
203
- white-space: nowrap;
204
- }
199
+ .ivu-checkbox-wrapper {
200
+ white-space: nowrap;
201
+ }
205
202
  </style>
@@ -11,18 +11,18 @@
11
11
  @on-change="selChange"
12
12
  class="question-choice"
13
13
  >
14
- <Row type="flex" justify="start" :gutter="60">
14
+ <Row :type="flexOrBlock" justify="start" :gutter="60" :style="{'display':(isMobile()?'inline-block':'flex')}">
15
15
  <Col
16
16
  v-for="choice in question.choices"
17
17
  :key="choice.id"
18
18
  :class="optionLayout"
19
- style="display: flex"
19
+ :style="{'display':(isMobile()?'inline-block':'flex')}"
20
20
  >
21
- <Radio
22
- :disabled="question.options.readonly || question.options.disabled"
23
- :label="choice.id"
24
- :key="choice.id"
25
- @click.native="
21
+ <Radio :style="{'display':(isMobile()?'inline-block':'flex'),'align-items':(isMobile()?'':'center')}"
22
+ :disabled="question.options.readonly || question.options.disabled"
23
+ :label="choice.id"
24
+ :key="choice.id"
25
+ @click.native="
26
26
  toggleAnswer($event, choice.id, question.options.disabled)
27
27
  "
28
28
  >
@@ -56,11 +56,11 @@
56
56
  },
57
57
  ]"
58
58
  >
59
- <Span v-if="responseStatus=='ENABLED'">
60
- {{inputAnswer.inputText}}</Span>
61
- <Input v-if="responseStatus=='DRAFT'"
62
- v-model.trim="inputAnswer.inputText"
63
- />
59
+ <Span v-if="responseStatus=='ENABLED'">
60
+ {{ inputAnswer.inputText }}</Span>
61
+ <Input v-if="responseStatus=='DRAFT'"
62
+ v-model.trim="inputAnswer.inputText"
63
+ />
64
64
  </FormItem>
65
65
  </div>
66
66
  </Col>
@@ -70,128 +70,126 @@
70
70
  </template>
71
71
 
72
72
  <script lang="ts">
73
- import Vue from "vue";
74
- import OptionLayoutMixin from "../../../mixins/option-layout-mixin";
75
- import {
76
- Col,
77
- FormItem,
78
- Icon,
79
- Radio,
80
- RadioGroup,
81
- Row,
82
- Input,
83
- } from "view-design";
84
- import _ from "lodash";
85
- import { SurveyLayout } from "@wg-npm/survey-core";
86
- import QuestionMixin from "../../../mixins/question-mixin";
87
-
88
- export default Vue.extend({
89
- name: "single-selection",
90
- components: {
73
+ import Vue from "vue";
74
+ import OptionLayoutMixin from "../../../mixins/option-layout-mixin";
75
+ import {
76
+ Col,
91
77
  FormItem,
92
- RadioGroup,
78
+ Icon,
93
79
  Radio,
80
+ RadioGroup,
94
81
  Row,
95
- Col,
96
- Icon,
97
- Input,
98
- },
99
- mixins: [OptionLayoutMixin, QuestionMixin],
100
- inject: ["responseStatus", "$rootComponent"],
101
- props: {
102
- question: {
103
- type: Object,
104
- required: true,
105
- },
106
- answer: {
107
- type: Object,
108
- required: true,
109
- },
110
- },
111
- data() {
112
- return {
113
- value: this.answer,
114
- // @ts-ignore
115
- choiceClasses: this.buildChoiceClasses(),
116
- };
117
- },
118
- watch: {
119
- "question.options.layout"() {
120
- this.choiceClasses = this.buildChoiceClasses();
121
- },
122
- answer(n) {
123
- this.value = n;
124
- },
125
- },
126
- methods: {
127
- inputAnswerProp(inputIndex) {
128
- return this.isMoreSurvey
129
- ? `moreSurveyAnswers[${this.surveyIndex}].answers[${this.index}].inputAnswers[${inputIndex}].inputText`
130
- : `answers[${this.index}].inputAnswers[${inputIndex}].inputText`;
131
- },
132
- selChange(id) {
133
- // @ts-ignore
134
- _.each(this.question.choices, (choice) => {
135
- if (choice.id == id) {
136
- // @ts-ignore
137
- this.answer.score = parseInt(choice?.options?.score ?? 0);
138
- this.answer.star = parseInt(choice?.options?.starCount ?? 0);
139
- }
140
- });
82
+ Input
83
+ } from "view-design";
84
+ import _ from "lodash";
85
+ import { SurveyLayout } from "@wg-npm/survey-core";
86
+ import QuestionMixin from "../../../mixins/question-mixin";
87
+
88
+ export default Vue.extend({
89
+ name: "single-selection",
90
+ components: {
91
+ FormItem,
92
+ RadioGroup,
93
+ Radio,
94
+ Row,
95
+ Col,
96
+ Icon,
97
+ Input
141
98
  },
142
- buildChoiceClasses() {
143
- return [
144
- `question-choice`,
145
- `question-choice-${_.lowerCase(
146
- this.question.options.layout || SurveyLayout.HORIZONTAL
147
- )}`,
148
- ];
99
+ mixins: [OptionLayoutMixin, QuestionMixin],
100
+ inject: ["responseStatus", "$rootComponent"],
101
+ props: {
102
+ question: {
103
+ type: Object,
104
+ required: true
105
+ },
106
+ answer: {
107
+ type: Object,
108
+ required: true
109
+ }
149
110
  },
150
- haveStar(choice) {
151
- return choice.options?.star ?? false;
111
+ data() {
112
+ return {
113
+ value: this.answer,
114
+ // @ts-ignore
115
+ choiceClasses: this.buildChoiceClasses()
116
+ };
152
117
  },
153
- toggleAnswer(e, value, disabled) {
154
- if (
155
- this.question.options.readonly ||
156
- disabled ||
157
- e.target.tagName !== "INPUT"
158
- ) {
159
- return;
118
+ watch: {
119
+ "question.options.layout"() {
120
+ this.choiceClasses = this.buildChoiceClasses();
121
+ },
122
+ answer(n) {
123
+ this.value = n;
160
124
  }
161
- if (this.responseStatus == this.$consts.STATUS_DRAFT) {
162
- if (this.value.answer && this.value.answer === value) {
163
- this.value.answer = null;
164
- _.forEach(this.value.inputAnswers, (input) => {
165
- input.inputText = null;
166
- });
125
+ },
126
+ computed: {
127
+ flexOrBlock() {
128
+ if (this.isMobile()) {
129
+ return "inline-block";
167
130
  } else {
168
- this.value.answer = value;
131
+ return "flex";
169
132
  }
170
133
  }
171
- this.$emit("singleQuestion", {
172
- questionId: this.question.id,
173
- choiceId: this.value.answer,
174
- });
175
134
  },
176
- },
177
- });
135
+ methods: {
136
+ inputAnswerProp(inputIndex) {
137
+ return this.isMoreSurvey
138
+ ? `moreSurveyAnswers[${this.surveyIndex}].answers[${this.index}].inputAnswers[${inputIndex}].inputText`
139
+ : `answers[${this.index}].inputAnswers[${inputIndex}].inputText`;
140
+ },
141
+ selChange(id) {
142
+ // @ts-ignore
143
+ _.each(this.question.choices, (choice) => {
144
+ if (choice.id == id) {
145
+ // @ts-ignore
146
+ this.answer.score = parseInt(choice?.options?.score ?? 0);
147
+ this.answer.star = parseInt(choice?.options?.starCount ?? 0);
148
+ }
149
+ });
150
+ },
151
+ buildChoiceClasses() {
152
+ return [
153
+ `question-choice`,
154
+ `question-choice-${_.lowerCase(
155
+ this.question.options.layout || SurveyLayout.HORIZONTAL
156
+ )}`
157
+ ];
158
+ },
159
+ haveStar(choice) {
160
+ return choice.options?.star ?? false;
161
+ },
162
+ toggleAnswer(e, value, disabled) {
163
+ if (
164
+ this.question.options.readonly ||
165
+ disabled ||
166
+ e.target.tagName !== "INPUT"
167
+ ) {
168
+ return;
169
+ }
170
+ if (this.responseStatus == this.$consts.STATUS_DRAFT) {
171
+ if (this.value.answer && this.value.answer === value) {
172
+ this.value.answer = null;
173
+ _.forEach(this.value.inputAnswers, (input) => {
174
+ input.inputText = null;
175
+ });
176
+ } else {
177
+ this.value.answer = value;
178
+ }
179
+ }
180
+ this.$emit("singleQuestion", {
181
+ questionId: this.question.id,
182
+ choiceId: this.value.answer
183
+ });
184
+ }
185
+ }
186
+ });
178
187
  </script>
179
188
 
180
189
  <style lang="less" scoped>
181
- .ivu-row-flex-start {
182
- align-items: center;
183
- }
184
- .ivu-radio-group-item {
185
- display: flex;
186
- flex-direction: row;
187
- }
188
-
189
- .choice-title {
190
- margin-left: 8px;
191
- margin-right: 8px;
192
- }
190
+ .choice-title {
191
+ margin-left: 8px;
192
+ margin-right: 8px;
193
+ }
193
194
 
194
- /deep/ .ivu-radio-inner{
195
- margin-top: 8px;
196
- }
197
195
  </style>
@@ -2,29 +2,33 @@ import Vue from "vue";
2
2
  import _ from "lodash";
3
3
 
4
4
  export default Vue.extend({
5
+ props: {
6
+ options: {
7
+ type: Object,
8
+ }
9
+ },
5
10
  methods: {
6
11
  isMobile() {
7
- const flag = navigator.userAgent.match(
12
+ const val = navigator.userAgent.match(
8
13
  /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
9
14
  );
10
- return flag;
15
+ return !_.isEmpty(val);
11
16
  },
12
17
  },
13
18
  computed: {
14
19
  optionLayout() {
15
20
  const globalLayout = _.lowerCase(
16
21
  // @ts-ignore
17
- _.get(this.options, "layout", undefined)
18
- );
19
-
20
- if (this.isMobile() || "vertical" == globalLayout) {
21
- return "";
22
- }
23
- const questionLayout = _.lowerCase(
24
- // @ts-ignore
25
- _.get(this.question.options, "layout", "horizontal")
22
+ _.get(this.options, "layout", "horizontal")
26
23
  );
27
- return `question-choice-${questionLayout}`;
24
+ // if (this.isMobile() || "vertical" == globalLayout) {
25
+ // return "";
26
+ // }
27
+ // const questionLayout = _.lowerCase(
28
+ // // @ts-ignore
29
+ // _.get(this.question.options, "layout", "horizontal")
30
+ // );
31
+ return `question-choice-${globalLayout}`;
28
32
  },
29
33
  },
30
34
  });