@wg-npm/survey-creator 0.5.0 → 0.5.1
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.
- package/package.json +6 -6
- package/src/components/common/question-title.vue +61 -15
- package/src/components/previewer/previewer-question-row.vue +60 -4
- package/src/components/previewer/survey-internal-previewer.vue +7 -1
- package/src/components/survey-previewer.vue +47 -0
- package/src/locale/lang/en-US.ts +1 -0
- package/src/locale/lang/zh-CN.ts +1 -0
- package/src/styles/components/survey-preview.less +4 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wg-npm/survey-creator",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
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.
|
|
16
|
-
"@wg-npm/survey-service-api": "0.5.
|
|
15
|
+
"@wg-npm/survey-core": "0.5.1",
|
|
16
|
+
"@wg-npm/survey-service-api": "0.5.1",
|
|
17
17
|
"axios": "^0.19.2",
|
|
18
18
|
"camelcase": "^6.0.0",
|
|
19
19
|
"deepmerge": "^4.2.2",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"@typescript-eslint/eslint-plugin": "^3.6.0",
|
|
39
39
|
"@typescript-eslint/parser": "^3.6.0",
|
|
40
40
|
"@vue/eslint-config-prettier": "^6.0.0",
|
|
41
|
-
"@wg-npm/survey-core": "0.5.
|
|
42
|
-
"@wg-npm/survey-service-api": "0.5.
|
|
41
|
+
"@wg-npm/survey-core": "0.5.1",
|
|
42
|
+
"@wg-npm/survey-service-api": "0.5.1",
|
|
43
43
|
"acorn": "^7.3.1",
|
|
44
44
|
"axios": "^0.19.2",
|
|
45
45
|
"babelrc-rollup": "^3.0.0",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"publishConfig": {
|
|
80
80
|
"access": "public"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "ecd5a545a11f95650a95c087dbee5281e65d5dbd",
|
|
83
83
|
"rollup": {
|
|
84
84
|
"external": [
|
|
85
85
|
"vue",
|
|
@@ -1,19 +1,37 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="question-title">
|
|
3
3
|
<label class="star">{{ question.options.required ? "*" : "" }}</label>
|
|
4
|
-
<span class="number" v-if="question.header.number"
|
|
4
|
+
<span class="number pl-sm" v-if="question.header.number"
|
|
5
5
|
>{{ question.header.number }}.</span
|
|
6
6
|
>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
v-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
|
|
8
|
+
<div class="flex pl-sm" v-for="(title, index) in formatTitle" :key="index">
|
|
9
|
+
<span v-if="title !== ''" class="content">{{ title }}</span>
|
|
10
|
+
<div
|
|
11
|
+
v-for="customTitle in customFilledTitle"
|
|
12
|
+
:key="index + customTitle.index"
|
|
13
|
+
>
|
|
14
|
+
<Input
|
|
15
|
+
v-if="title === '' && index === customTitle.index"
|
|
16
|
+
v-model.trim="customTitle.title"
|
|
17
|
+
/>
|
|
18
|
+
|
|
19
|
+
<div v-else>
|
|
20
|
+
<Input
|
|
21
|
+
class="pl-sm"
|
|
22
|
+
v-if="showInput(index) && index === customTitle.index"
|
|
23
|
+
v-model.trim="customTitle.title"
|
|
24
|
+
/>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<span class="options-explain pl-sm" v-if="haveMaxScore"
|
|
12
30
|
>({{
|
|
13
31
|
t(`survey_creator.question.max_score`, $rootComponent.currentLanguage)
|
|
14
32
|
}}{{ maxScore }})
|
|
15
33
|
</span>
|
|
16
|
-
<span class="options-explain" v-if="haveScoreRange"
|
|
34
|
+
<span class="options-explain pl-sm" v-if="haveScoreRange"
|
|
17
35
|
>({{
|
|
18
36
|
t(
|
|
19
37
|
`survey_creator.question.scoring.scoreRange`,
|
|
@@ -21,7 +39,7 @@
|
|
|
21
39
|
)
|
|
22
40
|
}}{{ scoreRange }})
|
|
23
41
|
</span>
|
|
24
|
-
<span class="options-explain" v-if="haveStar">
|
|
42
|
+
<span class="options-explain pl-sm" v-if="haveStar">
|
|
25
43
|
<span v-if="isSingleSelection">
|
|
26
44
|
({{
|
|
27
45
|
t(
|
|
@@ -76,8 +94,25 @@ export default Vue.extend({
|
|
|
76
94
|
type: Object as () => BaseQuestionModel,
|
|
77
95
|
required: true,
|
|
78
96
|
},
|
|
97
|
+
surveyCustomQuestions: {
|
|
98
|
+
type: Array,
|
|
99
|
+
required: false,
|
|
100
|
+
},
|
|
79
101
|
},
|
|
80
102
|
computed: {
|
|
103
|
+
customFilledTitle() {
|
|
104
|
+
return _.find(
|
|
105
|
+
this.surveyCustomQuestions,
|
|
106
|
+
(q) => q.id === this.question.id
|
|
107
|
+
).filledTitle;
|
|
108
|
+
},
|
|
109
|
+
formatTitle() {
|
|
110
|
+
let title = this.translate(this.question.header.text, true);
|
|
111
|
+
if (!this.isRichText) {
|
|
112
|
+
return [title];
|
|
113
|
+
}
|
|
114
|
+
return title.split(/_{5,}/g);
|
|
115
|
+
},
|
|
81
116
|
maxScore() {
|
|
82
117
|
return BaseQuestionModel.getMaxScore(this.question);
|
|
83
118
|
},
|
|
@@ -107,15 +142,26 @@ export default Vue.extend({
|
|
|
107
142
|
},
|
|
108
143
|
},
|
|
109
144
|
methods: {
|
|
110
|
-
|
|
111
|
-
if (
|
|
112
|
-
|
|
145
|
+
showInput(index) {
|
|
146
|
+
if (
|
|
147
|
+
index === this.formatTitle.length - 2 &&
|
|
148
|
+
this.formatTitle[this.formatTitle.length - 1] === ""
|
|
149
|
+
) {
|
|
150
|
+
return false;
|
|
113
151
|
}
|
|
114
|
-
|
|
115
|
-
"survey_creator.question.rich_text.input_placeholder"
|
|
116
|
-
)}" />`;
|
|
117
|
-
return title.replace(/_{5,}/g, inputHtml);
|
|
152
|
+
return index < this.formatTitle.length - 1;
|
|
118
153
|
},
|
|
119
154
|
},
|
|
120
155
|
});
|
|
121
156
|
</script>
|
|
157
|
+
|
|
158
|
+
<style lang="less" scoped>
|
|
159
|
+
.flex {
|
|
160
|
+
display: flex;
|
|
161
|
+
align-items: center;
|
|
162
|
+
white-space: nowrap;
|
|
163
|
+
}
|
|
164
|
+
.pl-sm {
|
|
165
|
+
padding-left: 4px;
|
|
166
|
+
}
|
|
167
|
+
</style>
|
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
<div class="question-row-container-left" v-if="enabledSelectQuestion">
|
|
5
5
|
<Checkbox v-model="isSelectedQuestion" @on-change="onSelectQuestion" />
|
|
6
6
|
</div>
|
|
7
|
-
<div class="question-row-container-right">
|
|
7
|
+
<div class="question-row-container-right" :class="getClassStyle">
|
|
8
|
+
<span class="incomplete-tips" v-show="!questionTitleIncomplete">
|
|
9
|
+
{{ t("survey_creator.question.incomplete_tips") }}
|
|
10
|
+
</span>
|
|
8
11
|
<Divider orientation="left" class="question-type-desc">
|
|
9
12
|
{{
|
|
10
13
|
t(
|
|
@@ -13,7 +16,11 @@
|
|
|
13
16
|
)
|
|
14
17
|
}}
|
|
15
18
|
</Divider>
|
|
16
|
-
<question-title
|
|
19
|
+
<question-title
|
|
20
|
+
:question="question"
|
|
21
|
+
:max-score="true"
|
|
22
|
+
:survey-custom-questions="surveyCustomQuestions"
|
|
23
|
+
/>
|
|
17
24
|
<div class="question-row-content">
|
|
18
25
|
<component
|
|
19
26
|
class="question"
|
|
@@ -46,6 +53,7 @@ import TextTitle from "../common/question/text-title.vue";
|
|
|
46
53
|
import Matrix from "../common/question/matrix.vue";
|
|
47
54
|
import Scoring from "../common/question/scoring.vue";
|
|
48
55
|
import Evaluation from "../common/question/evaluation.vue";
|
|
56
|
+
import _ from "lodash";
|
|
49
57
|
|
|
50
58
|
export default Vue.extend({
|
|
51
59
|
name: "previewer-question-row",
|
|
@@ -76,12 +84,16 @@ export default Vue.extend({
|
|
|
76
84
|
type: Object as () => SurveyModel,
|
|
77
85
|
required: true,
|
|
78
86
|
},
|
|
87
|
+
surveyCustomQuestions: {
|
|
88
|
+
type: Array,
|
|
89
|
+
required: false,
|
|
90
|
+
},
|
|
79
91
|
},
|
|
80
92
|
data() {
|
|
81
93
|
return {
|
|
82
94
|
enabledSelectQuestion: false,
|
|
83
|
-
isSelectedQuestion: false
|
|
84
|
-
}
|
|
95
|
+
isSelectedQuestion: false,
|
|
96
|
+
};
|
|
85
97
|
},
|
|
86
98
|
created() {
|
|
87
99
|
// @ts-ignore
|
|
@@ -90,6 +102,30 @@ export default Vue.extend({
|
|
|
90
102
|
"options.enabledSelectQuestion",
|
|
91
103
|
false
|
|
92
104
|
);
|
|
105
|
+
this.enabledQuestionTitleIncompleteTips = _.get(
|
|
106
|
+
this.$rootComponent,
|
|
107
|
+
"options.enabledQuestionTitleIncompleteTips",
|
|
108
|
+
false
|
|
109
|
+
);
|
|
110
|
+
},
|
|
111
|
+
computed: {
|
|
112
|
+
getClassStyle() {
|
|
113
|
+
return this.questionTitleIncomplete ? "" : "question-incomplete";
|
|
114
|
+
},
|
|
115
|
+
questionTitleIncomplete() {
|
|
116
|
+
if (!this.enabledQuestionTitleIncompleteTips) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
let filledTitle = _.find(
|
|
120
|
+
this.surveyCustomQuestions,
|
|
121
|
+
(q) => q.id === this.question.id
|
|
122
|
+
)?.filledTitle;
|
|
123
|
+
if (_.isEmpty(filledTitle)) {
|
|
124
|
+
return true;
|
|
125
|
+
} else {
|
|
126
|
+
return _.every(filledTitle, (t) => t.title !== "");
|
|
127
|
+
}
|
|
128
|
+
},
|
|
93
129
|
},
|
|
94
130
|
methods: {
|
|
95
131
|
getJumpRules(val) {
|
|
@@ -104,3 +140,23 @@ export default Vue.extend({
|
|
|
104
140
|
},
|
|
105
141
|
});
|
|
106
142
|
</script>
|
|
143
|
+
|
|
144
|
+
<style lang="less" scoped>
|
|
145
|
+
.question-incomplete {
|
|
146
|
+
border: 1px solid #ed4014;
|
|
147
|
+
border-radius: 4px;
|
|
148
|
+
.incomplete-tips {
|
|
149
|
+
position: absolute;
|
|
150
|
+
left: 15px;
|
|
151
|
+
top: 16px;
|
|
152
|
+
padding: 2px 4px;
|
|
153
|
+
background: #f85353;
|
|
154
|
+
border-radius: 4px 0px;
|
|
155
|
+
|
|
156
|
+
font-weight: 400;
|
|
157
|
+
font-size: 12px;
|
|
158
|
+
line-height: 18px;
|
|
159
|
+
color: #ffffff;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
</style>
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
:survey="survey"
|
|
9
9
|
@singleQuestion="handleSelected"
|
|
10
10
|
@onSelectQuestion="onSelectQuestion"
|
|
11
|
+
:survey-custom-questions="surveyCustomQuestions"
|
|
11
12
|
></previewer-question-row>
|
|
12
13
|
</div>
|
|
13
14
|
</template>
|
|
@@ -29,6 +30,10 @@ export default Vue.extend({
|
|
|
29
30
|
type: Array,
|
|
30
31
|
required: false,
|
|
31
32
|
},
|
|
33
|
+
surveyCustomQuestions: {
|
|
34
|
+
type: Array,
|
|
35
|
+
required: false,
|
|
36
|
+
},
|
|
32
37
|
},
|
|
33
38
|
data() {
|
|
34
39
|
return {
|
|
@@ -129,7 +134,8 @@ export default Vue.extend({
|
|
|
129
134
|
},
|
|
130
135
|
selectQuestionHandler(selected, question) {
|
|
131
136
|
this.$refs[`question${question.id}`][0].selectQuestion(selected);
|
|
132
|
-
this.selectedQuestions.
|
|
137
|
+
this.selectedQuestions.find((i) => i.id === question.id) ||
|
|
138
|
+
this.selectedQuestions.push(question);
|
|
133
139
|
if (Array.isArray(question.jumps) && question.jumps.length > 0) {
|
|
134
140
|
question.jumps.forEach((item) => {
|
|
135
141
|
const jumpItem = this.sortQuestions.find(
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
:survey="currentSurvey"
|
|
22
22
|
:init-question-ids="initQuestionIds"
|
|
23
23
|
@selected-question-ids="selectedQuestionIds"
|
|
24
|
+
:survey-custom-questions="surveyCustomQuestions"
|
|
24
25
|
></survey-internal-previewer>
|
|
25
26
|
</div>
|
|
26
27
|
</div>
|
|
@@ -57,6 +58,10 @@ export default Vue.extend({
|
|
|
57
58
|
type: Array,
|
|
58
59
|
required: false,
|
|
59
60
|
},
|
|
61
|
+
surveyCustomQuestions: {
|
|
62
|
+
type: Array,
|
|
63
|
+
required: false,
|
|
64
|
+
},
|
|
60
65
|
},
|
|
61
66
|
data() {
|
|
62
67
|
return {
|
|
@@ -67,6 +72,7 @@ export default Vue.extend({
|
|
|
67
72
|
},
|
|
68
73
|
created() {
|
|
69
74
|
this.setSurveyLanguage(this.survey);
|
|
75
|
+
this.prepareSurveyCustomQuestions();
|
|
70
76
|
},
|
|
71
77
|
methods: {
|
|
72
78
|
onBack() {
|
|
@@ -80,6 +86,47 @@ export default Vue.extend({
|
|
|
80
86
|
selectedQuestionIds(questionIds) {
|
|
81
87
|
this.$emit("selected-question-ids", questionIds);
|
|
82
88
|
},
|
|
89
|
+
formatTitle(question) {
|
|
90
|
+
let title = this.translate(question.header.text, true);
|
|
91
|
+
if (!_.get(question, "options.richTextEnabled", false)) {
|
|
92
|
+
return [title];
|
|
93
|
+
}
|
|
94
|
+
return title.split(/_{5,}/g);
|
|
95
|
+
},
|
|
96
|
+
showInput(index, formatTitle) {
|
|
97
|
+
if (
|
|
98
|
+
index === formatTitle.length - 2 &&
|
|
99
|
+
formatTitle[formatTitle.length - 1] === ""
|
|
100
|
+
) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
return index < formatTitle.length - 1;
|
|
104
|
+
},
|
|
105
|
+
prepareSurveyCustomQuestions() {
|
|
106
|
+
if (_.isEmpty(this.surveyCustomQuestions)) {
|
|
107
|
+
this.surveyCustomQuestions = [];
|
|
108
|
+
_.each(this.survey.questions, (q) => {
|
|
109
|
+
let input_titles: any = [];
|
|
110
|
+
_.each(this.formatTitle(q), (t, index) => {
|
|
111
|
+
if (t === "" || this.showInput(index, this.formatTitle(q))) {
|
|
112
|
+
let title = {
|
|
113
|
+
title: "",
|
|
114
|
+
index: index,
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
input_titles.push(title);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
let customQuestion = {
|
|
122
|
+
id: q.id,
|
|
123
|
+
surveyId: this.survey.id,
|
|
124
|
+
filledTitle: input_titles,
|
|
125
|
+
};
|
|
126
|
+
this.surveyCustomQuestions.push(customQuestion);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
},
|
|
83
130
|
},
|
|
84
131
|
});
|
|
85
132
|
</script>
|
package/src/locale/lang/en-US.ts
CHANGED
|
@@ -73,6 +73,7 @@ export default {
|
|
|
73
73
|
"This question is involved in logical jump settings. After deletion, the related" +
|
|
74
74
|
" logical jump relationships will be automatically cleared. Are you sure you want to delete?",
|
|
75
75
|
},
|
|
76
|
+
incomplete_tips: "The title is not set completely",
|
|
76
77
|
optional: "Optional",
|
|
77
78
|
sub_questions: "Sub Question",
|
|
78
79
|
score: "Score",
|
package/src/locale/lang/zh-CN.ts
CHANGED
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
.question-row-container-right {
|
|
34
|
+
padding: 0px 16px;
|
|
34
35
|
flex: 1;
|
|
35
36
|
|
|
36
37
|
.question-type-desc {
|
|
@@ -39,7 +40,9 @@
|
|
|
39
40
|
|
|
40
41
|
.question-title {
|
|
41
42
|
padding: 16px 0;
|
|
42
|
-
|
|
43
|
+
display: flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
|
|
43
46
|
.star {
|
|
44
47
|
color: red;
|
|
45
48
|
}
|