@wg-npm/survey-response 0.5.1 → 0.5.123

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.
@@ -2,58 +2,43 @@
2
2
  <div>
3
3
  <!-- question slider -->
4
4
  <Row v-if="showQuestionScoreSlider">
5
- <div style="margin-right: 134px; margin-bottom: 18px">
6
- <Slider
7
- style="float: left; width: 562px; margin-right: 16px"
5
+ <Col
6
+ :xs="24"
7
+ :sm="$rootComponent.layout === 'vertical' ? 24 : 12"
8
+ :xl="$rootComponent.layout === 'vertical' ? 24 : 12"
9
+ :md="$rootComponent.layout === 'vertical' ? 24 : 12"
10
+ :lg="$rootComponent.layout === 'vertical' ? 24 : 12"
11
+ >
12
+ <slider-input-number
8
13
  v-model="value.score"
9
14
  :min="question.options.minRange"
10
15
  :max="question.options.maxRange"
11
- :step="sliderStep"
12
- show-tips="always"
16
+ :slider-step="sliderStep"
17
+ :form-item-prop="answerProp"
13
18
  :disabled="question.options.readonly || question.options.disabled"
14
- ></Slider>
15
- <FormItem
16
- style="display: flex"
17
- :prop="`answers[${index}].score`"
18
- :rules="[
19
- {
20
- required: question.options.required && !question.options.disabled,
21
- message: t('survey_response.question.question_required'),
22
- },
23
- ]"
24
- >
25
- <InputNumber
26
- style="float: left"
27
- v-model="value.score"
28
- :precision="question.options.decimalPlaces"
29
- :min="question.options.minRange"
30
- :max="question.options.maxRange"
31
- >
32
- </InputNumber>
33
- </FormItem>
34
- <div v-show="extremeValueLabelSelected">
35
- <span style="float: left; margin-left: 36px">
36
- {{
37
- t(
38
- `survey_creator.question.scoring.extreme_value_labels.${question.options.extremeValueLabel}.minValue`
39
- )
40
- }}
41
- </span>
42
- <span style="float: right; align-items: flex-end; margin-right: 88px">
43
- {{
44
- t(
45
- `survey_creator.question.scoring.extreme_value_labels.${question.options.extremeValueLabel}.maxValue`
46
- )
47
- }}
48
- </span>
49
- </div>
50
- </div>
19
+ :precision="question.options.decimalPlaces"
20
+ :show-label="extremeValueLabelSelected"
21
+ :required="question.options.required && !question.options.disabled"
22
+ :required-desc="t('survey_response.question.question_required')"
23
+ :min-label="
24
+ t(
25
+ `survey_creator.question.scoring.extreme_value_labels.${question.options.extremeValueLabel}.minValue`
26
+ )
27
+ "
28
+ :max-label="
29
+ t(
30
+ `survey_creator.question.scoring.extreme_value_labels.${question.options.extremeValueLabel}.maxValue`
31
+ )
32
+ "
33
+ />
34
+ </Col>
51
35
  </Row>
52
36
  <div
53
37
  v-else
54
38
  v-for="(subQuestion, subIndex) in question.subQuestions"
55
39
  :key="subIndex"
56
40
  class="sub-question"
41
+ :class="subIndex > 0 ? 'score-sub-question' : ''"
57
42
  >
58
43
  <span class="number">
59
44
  {{ question.header.number }}-{{ subQuestion.number }}.</span
@@ -61,57 +46,38 @@
61
46
  <span class="title"> {{ i18nText(subQuestion.text) }} </span>
62
47
  <!-- sub question slider -->
63
48
  <Row>
64
- <div style="margin-right: 134px; margin-bottom: 18px">
65
- <Slider
66
- style="float: left; width: 562px; margin-right: 16px"
49
+ <Col
50
+ :xs="24"
51
+ :sm="$rootComponent.layout === 'vertical' ? 24 : 12"
52
+ :xl="$rootComponent.layout === 'vertical' ? 24 : 12"
53
+ :md="$rootComponent.layout === 'vertical' ? 24 : 12"
54
+ :lg="$rootComponent.layout === 'vertical' ? 24 : 12"
55
+ >
56
+ <slider-input-number
67
57
  v-model="value.answer[subIndex].score"
68
58
  :min="question.options.minRange"
69
59
  :max="question.options.maxRange"
70
- :step="sliderStep"
71
- show-tips="always"
60
+ :slider-step="sliderStep"
61
+ :form-item-prop="subAnswerProp(subIndex)"
72
62
  :disabled="
73
63
  subQuestion.options.readonly || question.options.disabled
74
64
  "
75
- ></Slider>
76
- <FormItem
77
- style="display: flex"
78
- :prop="`answers[${index}].answer[${subIndex}].score`"
79
- :rules="[
80
- {
81
- required:
82
- question.options.required && !question.options.disabled,
83
- message: t('survey_response.question.question_required'),
84
- },
85
- ]"
86
- >
87
- <InputNumber
88
- style="float: left"
89
- v-model="value.answer[subIndex].score"
90
- :precision="question.options.decimalPlaces"
91
- :min="question.options.minRange"
92
- :max="question.options.maxRange"
93
- >
94
- </InputNumber>
95
- </FormItem>
96
- <div v-show="extremeValueLabelSelected">
97
- <span style="float: left; margin-left: 36px">
98
- {{
99
- t(
100
- `survey_creator.question.scoring.extreme_value_labels.${question.options.extremeValueLabel}.minValue`
101
- )
102
- }}
103
- </span>
104
- <span
105
- style="float: right; align-items: flex-end; margin-right: 88px"
106
- >
107
- {{
108
- t(
109
- `survey_creator.question.scoring.extreme_value_labels.${question.options.extremeValueLabel}.maxValue`
110
- )
111
- }}
112
- </span>
113
- </div>
114
- </div>
65
+ :precision="question.options.decimalPlaces"
66
+ :show-label="extremeValueLabelSelected"
67
+ :required="question.options.required && !question.options.disabled"
68
+ :required-desc="t('survey_response.question.question_required')"
69
+ :min-label="
70
+ t(
71
+ `survey_creator.question.scoring.extreme_value_labels.${question.options.extremeValueLabel}.minValue`
72
+ )
73
+ "
74
+ :max-label="
75
+ t(
76
+ `survey_creator.question.scoring.extreme_value_labels.${question.options.extremeValueLabel}.maxValue`
77
+ )
78
+ "
79
+ />
80
+ </Col>
115
81
  </Row>
116
82
  </div>
117
83
  </div>
@@ -120,7 +86,8 @@
120
86
  <script lang="ts">
121
87
  import Vue from "vue";
122
88
  import OptionLayoutMixin from "../../../mixins/option-layout-mixin";
123
- import { Row, Slider, FormItem, InputNumber } from "view-design";
89
+ import { Row, Col } from "view-design";
90
+ import SliderInputNumber from "../../../components/slider-input-number.vue";
124
91
  import _ from "lodash";
125
92
 
126
93
  export default Vue.extend({
@@ -130,9 +97,8 @@ export default Vue.extend({
130
97
 
131
98
  components: {
132
99
  Row,
133
- Slider,
134
- FormItem,
135
- InputNumber,
100
+ Col,
101
+ SliderInputNumber,
136
102
  },
137
103
  props: {
138
104
  question: {
@@ -140,6 +106,12 @@ export default Vue.extend({
140
106
  required: true,
141
107
  },
142
108
  index: Number,
109
+ surveyIndex: Number,
110
+ isMoreSurvey: {
111
+ type: Boolean,
112
+ required: false,
113
+ default: false,
114
+ },
143
115
  answer: {
144
116
  type: Object,
145
117
  required: true,
@@ -173,8 +145,19 @@ export default Vue.extend({
173
145
  this.value.answer.push(_answer);
174
146
  });
175
147
  },
176
- methods: {},
148
+ methods: {
149
+ subAnswerProp(subIndex) {
150
+ return this.isMoreSurvey
151
+ ? `moreSurveyAnswers[${this.surveyIndex}].answers[${this.index}].answer[${subIndex}].score`
152
+ : `answers[${this.index}].answer[${subIndex}].score`;
153
+ },
154
+ },
177
155
  computed: {
156
+ answerProp() {
157
+ return this.isMoreSurvey
158
+ ? `moreSurveyAnswers[${this.surveyIndex}].answers[${this.index}].score`
159
+ : `answers[${this.index}].score`;
160
+ },
178
161
  showQuestionScoreSlider() {
179
162
  return !(
180
163
  this.question.subQuestions && this.question.subQuestions.length > 0
@@ -194,6 +177,15 @@ export default Vue.extend({
194
177
  _.forEach(this.value.answer, (a) => (a.score = 0));
195
178
  }
196
179
  },
180
+ answer(n) {
181
+ this.value = n;
182
+ },
197
183
  },
198
184
  });
199
185
  </script>
186
+
187
+ <style lang="less" scoped>
188
+ .score-sub-question {
189
+ padding-top: 24px;
190
+ }
191
+ </style>
@@ -1,36 +1,19 @@
1
1
  <template>
2
2
  <div>
3
- <div
4
- v-if="readonly || question.options.disabled"
5
- class="processed-answer"
6
- v-html="decodeHTML(value)"
7
- />
8
3
  <FormItem
9
- v-else
10
- :prop="`answers[${index}].answer`"
4
+ :prop="answerProp"
11
5
  :rules="{
12
6
  required: question.options.required,
13
7
  message: t('survey_response.question.question_required'),
14
8
  }"
15
9
  >
16
- <Input
17
- v-if="question.options && question.options.wordLimit"
10
+ <quill-rich-text
18
11
  v-model.trim="value.answer"
19
- type="textarea"
20
- :rows="4"
21
- show-word-limit
12
+ :disabled="readonly || question.options.readonly"
22
13
  :placeholder="placeholder"
23
14
  :maxlength="question.options.wordLimit"
24
- :disabled="question.options.readonly"
25
- />
26
- <Input
27
- v-else
28
- v-model.trim="value.answer"
29
- type="textarea"
30
- :rows="4"
31
- :placeholder="placeholder"
32
- :disabled="question.options.readonly"
33
- />
15
+ ></quill-rich-text>
16
+ <div></div>
34
17
  </FormItem>
35
18
  </div>
36
19
  </template>
@@ -38,19 +21,22 @@
38
21
  <script lang="ts">
39
22
  import Vue from "vue";
40
23
  import { FormItem, Input } from "view-design";
24
+ import QuestionMixin from "../../../mixins/question-mixin";
25
+ import QuillRichText from "./quill-rich-text.vue";
41
26
 
42
27
  export default Vue.extend({
43
28
  name: "short-answer",
29
+ mixins: [QuestionMixin],
44
30
  components: {
31
+ QuillRichText,
45
32
  FormItem,
46
- Input,
47
33
  },
34
+ inject: ["$rootComponent"],
48
35
  props: {
49
36
  question: {
50
37
  type: Object,
51
38
  required: true,
52
39
  },
53
- index: Number,
54
40
  answer: {
55
41
  type: Object,
56
42
  required: true,
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <FormItem
3
- :prop="`answers[${index}].answer`"
3
+ :prop="answerProp"
4
4
  :rules="{
5
5
  required: question.options.required && !question.options.disabled,
6
6
  message: t('survey_response.question.question_required'),
@@ -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
  >
@@ -39,7 +39,7 @@
39
39
  v-if="
40
40
  choice.id === inputAnswer.choiceId && choice.id === value.answer
41
41
  "
42
- :prop="`answers[${index}].inputAnswers[${inputIndex}].inputText`"
42
+ :prop="inputAnswerProp(inputIndex)"
43
43
  :rules="[
44
44
  {
45
45
  required: true,
@@ -56,11 +56,10 @@
56
56
  },
57
57
  ]"
58
58
  >
59
- <Input
60
- :disabled="
61
- question.options.readonly || question.options.disabled
62
- "
63
- v-model.trim="inputAnswer.inputText"
59
+ <Span v-if="responseStatus=='ENABLED'">
60
+ {{ inputAnswer.inputText }}</Span>
61
+ <Input v-if="responseStatus=='DRAFT'"
62
+ v-model.trim="inputAnswer.inputText"
64
63
  />
65
64
  </FormItem>
66
65
  </div>
@@ -71,120 +70,126 @@
71
70
  </template>
72
71
 
73
72
  <script lang="ts">
74
- import Vue from "vue";
75
- import OptionLayoutMixin from "../../../mixins/option-layout-mixin";
76
- import {
77
- Col,
78
- FormItem,
79
- Icon,
80
- Radio,
81
- RadioGroup,
82
- Row,
83
- Input,
84
- } from "view-design";
85
- import _ from "lodash";
86
- import { SurveyLayout } from "@wg-npm/survey-core";
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],
100
- inject: ["responseStatus", "$rootComponent"],
101
- props: {
102
- question: {
103
- type: Object,
104
- required: true,
105
- },
106
- index: Number,
107
- answer: {
108
- type: Object,
109
- required: true,
110
- },
111
- },
112
- data() {
113
- return {
114
- value: this.answer,
115
- // @ts-ignore
116
- choiceClasses: this.buildChoiceClasses(),
117
- };
118
- },
119
- watch: {
120
- "question.options.layout"() {
121
- this.choiceClasses = this.buildChoiceClasses();
122
- },
123
- answer(n) {
124
- this.value = n;
125
- },
126
- },
127
- methods: {
128
- selChange(id) {
129
- // @ts-ignore
130
- _.each(this.question.choices, (choice) => {
131
- if (choice.id == id) {
132
- // @ts-ignore
133
- this.answer.score = parseInt(choice?.options?.score ?? 0);
134
- this.answer.star = parseInt(choice?.options?.starCount ?? 0);
135
- }
136
- });
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
137
98
  },
138
- buildChoiceClasses() {
139
- return [
140
- `question-choice`,
141
- `question-choice-${_.lowerCase(
142
- this.question.options.layout || SurveyLayout.HORIZONTAL
143
- )}`,
144
- ];
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
+ }
145
110
  },
146
- haveStar(choice) {
147
- return choice.options?.star ?? false;
111
+ data() {
112
+ return {
113
+ value: this.answer,
114
+ // @ts-ignore
115
+ choiceClasses: this.buildChoiceClasses()
116
+ };
148
117
  },
149
- toggleAnswer(e, value, disabled) {
150
- if (
151
- this.question.options.readonly ||
152
- disabled ||
153
- e.target.tagName !== "INPUT"
154
- ) {
155
- return;
118
+ watch: {
119
+ "question.options.layout"() {
120
+ this.choiceClasses = this.buildChoiceClasses();
121
+ },
122
+ answer(n) {
123
+ this.value = n;
156
124
  }
157
- if (this.responseStatus == this.$consts.STATUS_DRAFT) {
158
- if (this.value.answer && this.value.answer === value) {
159
- this.value.answer = null;
160
- _.forEach(this.value.inputAnswers, (input) => {
161
- input.inputText = null;
162
- });
125
+ },
126
+ computed: {
127
+ flexOrBlock() {
128
+ if (this.isMobile()) {
129
+ return "inline-block";
163
130
  } else {
164
- this.value.answer = value;
131
+ return "flex";
165
132
  }
166
133
  }
167
- this.$emit("singleQuestion", {
168
- questionId: this.question.id,
169
- choiceId: this.value.answer,
170
- });
171
134
  },
172
- },
173
- });
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
+ });
174
187
  </script>
175
188
 
176
189
  <style lang="less" scoped>
177
- .ivu-row-flex-start {
178
- align-items: center;
179
- }
180
- .ivu-radio-group-item {
181
- display: flex;
182
- flex-direction: row;
183
- align-items: center;
184
- }
190
+ .choice-title {
191
+ margin-left: 8px;
192
+ margin-right: 8px;
193
+ }
185
194
 
186
- .choice-title {
187
- margin-left: 8px;
188
- margin-right: 8px;
189
- }
190
195
  </style>