@wg-npm/survey-response 0.3.3791 → 0.3.4060

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.
@@ -1013,14 +1013,14 @@ var script$5 = Vue.extend({
1013
1013
  data() {
1014
1014
  return {
1015
1015
  desc: "",
1016
- descTitle: ""
1016
+ descTitle: "",
1017
1017
  };
1018
1018
  },
1019
1019
  props: {
1020
1020
  conditions: {
1021
1021
  type: Array,
1022
- required: true
1023
- }
1022
+ required: true,
1023
+ },
1024
1024
  },
1025
1025
  created() {
1026
1026
  this.initialDesc();
@@ -1028,23 +1028,39 @@ var script$5 = Vue.extend({
1028
1028
  computed: {
1029
1029
  questions() {
1030
1030
  return _.clone(this.survey.questions);
1031
- }
1031
+ },
1032
1032
  },
1033
1033
  methods: {
1034
1034
  getDesc(condition) {
1035
1035
  let payload = condition.payload;
1036
- let numbers = new ExprEvaluationQuestion(this.questions, payload.scope).calculateNumbers();
1037
- let scope = _.join(_.map(numbers, number => {
1038
- if (_.isArray(_.head(number))) {
1039
- return _.join(_.map(number, e => _.join(e, "-")), ", ");
1040
- }
1041
- return _.join(number, "-");
1042
- }), ", ");
1043
- if (condition.type == "ASSIGN") {
1044
- return this.t('survey_creator.question.evaluation.condition.assign_template', [scope, _.join(payload.values, "、"), payload.operator, payload.size]);
1036
+ if (condition.type == "SCORE") {
1037
+ return this.t("survey_creator.question.evaluation.condition.score_template", [
1038
+ payload.minScore,
1039
+ payload.leftOperator,
1040
+ payload.rightOperator,
1041
+ payload.maxScore,
1042
+ ]);
1045
1043
  }
1046
- else if (condition.type == "AUTO") {
1047
- return this.t('survey_creator.question.evaluation.condition.auto_template', [scope, _.join(payload.values, "、")]);
1044
+ else {
1045
+ let numbers = new ExprEvaluationQuestion(this.questions, payload.scope).calculateNumbers();
1046
+ let scope = _.join(_.map(numbers, (number) => {
1047
+ if (_.isArray(_.head(number))) {
1048
+ return _.join(_.map(number, (e) => _.join(e, "-")), ", ");
1049
+ }
1050
+ return _.join(number, "-");
1051
+ }), ", ");
1052
+ if (condition.type == "ASSIGN") {
1053
+ return this.t("survey_creator.question.evaluation.condition.assign_template", [
1054
+ scope,
1055
+ _.join(payload.values, "、"),
1056
+ _.unescape(payload.operator),
1057
+ payload.size,
1058
+ ]);
1059
+ }
1060
+ else if (condition.type == "AUTO") {
1061
+ return this.t("survey_creator.question.evaluation.condition.auto_template", [scope, _.join(payload.values, "、")]);
1062
+ }
1063
+ return "";
1048
1064
  }
1049
1065
  },
1050
1066
  getChineseLength(_str) {
@@ -1057,20 +1073,21 @@ var script$5 = Vue.extend({
1057
1073
  return chinese ? chinese.length : 0;
1058
1074
  },
1059
1075
  initialDesc() {
1060
- let desc = '';
1076
+ let desc = "";
1061
1077
  let ds = _.map(this.conditions, (c) => {
1062
1078
  return this.getDesc(c);
1063
1079
  });
1064
- desc = _.join(ds, '</br>');
1080
+ desc = _.join(ds, "</br>");
1065
1081
  this.desc = desc;
1066
1082
  let strLength = desc.length;
1067
1083
  let cLength = this.getChineseLength(desc.substring(0, SPLIT_LENGTH));
1068
1084
  if (strLength > SPLIT_LENGTH) {
1069
- this.desc = desc.substring(0, SPLIT_LENGTH - _.ceil(cLength / 2)) + "...";
1085
+ this.desc =
1086
+ desc.substring(0, SPLIT_LENGTH - _.ceil(cLength / 2)) + "...";
1070
1087
  }
1071
1088
  this.descTitle = desc;
1072
- }
1073
- }
1089
+ },
1090
+ },
1074
1091
  });
1075
1092
 
1076
1093
  /* script */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wg-npm/survey-response",
3
- "version": "0.3.3791",
3
+ "version": "0.3.4060",
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.3.3791",
16
- "@wg-npm/survey-service-api": "0.3.3791",
15
+ "@wg-npm/survey-core": "0.3.4060",
16
+ "@wg-npm/survey-service-api": "0.3.4060",
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.3.3791",
38
- "@wg-npm/survey-service-api": "0.3.3791",
37
+ "@wg-npm/survey-core": "0.3.4060",
38
+ "@wg-npm/survey-service-api": "0.3.4060",
39
39
  "acorn": "^7.3.1",
40
40
  "axios": "^0.19.2",
41
41
  "babelrc-rollup": "^3.0.0",
@@ -1,36 +1,35 @@
1
1
  <template>
2
2
  <Tooltip max-width="200">
3
3
  <span v-html="this.descTitle" slot="content"></span>
4
- <span v-html="this.desc" class="desc">
5
- </span>
4
+ <span v-html="this.desc" class="desc"> </span>
6
5
  </Tooltip>
7
6
  </template>
8
7
 
9
8
  <script lang="ts">
10
9
  const SPLIT_LENGTH = 50;
11
10
  import Vue from "vue";
12
- import {Tooltip} from "view-design";
13
- import {ExprConditionType} from "@wg-npm/survey-core/src/models";
11
+ import { Tooltip } from "view-design";
12
+ import { ExprConditionType } from "@wg-npm/survey-core/src/models";
14
13
  import LocaleMixin from "../../../../mixins/locale-mixin";
15
14
  import _ from "lodash";
16
- import {ExprEvaluationQuestion} from "@wg-npm/survey-core/src/expr-evaluation-question";
15
+ import { ExprEvaluationQuestion } from "@wg-npm/survey-core/src/expr-evaluation-question";
17
16
 
18
17
  export default Vue.extend({
19
18
  name: "expr-if",
20
- components: {Tooltip},
19
+ components: { Tooltip },
21
20
  mixins: [LocaleMixin],
22
21
  inject: ["survey"],
23
22
  data() {
24
23
  return {
25
24
  desc: "",
26
- descTitle: ""
27
- }
25
+ descTitle: "",
26
+ };
28
27
  },
29
28
  props: {
30
29
  conditions: {
31
30
  type: Array,
32
- required: true
33
- }
31
+ required: true,
32
+ },
34
33
  },
35
34
  created() {
36
35
  this.initialDesc();
@@ -38,23 +37,55 @@ export default Vue.extend({
38
37
  computed: {
39
38
  questions() {
40
39
  return _.clone(this.survey.questions);
41
- }
40
+ },
42
41
  },
43
42
  methods: {
44
43
  getDesc(condition) {
45
44
  let payload = condition.payload;
46
- let numbers = new ExprEvaluationQuestion(this.questions, payload.scope).calculateNumbers();
47
- let scope = _.join(_.map(numbers, number => {
48
- if (_.isArray(_.head(number))) {
49
- return _.join(_.map(number, e => _.join(e, "-")), ", ");
45
+ if (condition.type == ExprConditionType.SCORE) {
46
+ return this.t(
47
+ "survey_creator.question.evaluation.condition.score_template",
48
+ [
49
+ payload.minScore,
50
+ payload.leftOperator,
51
+ payload.rightOperator,
52
+ payload.maxScore,
53
+ ]
54
+ );
55
+ } else {
56
+ let numbers = new ExprEvaluationQuestion(
57
+ this.questions,
58
+ payload.scope
59
+ ).calculateNumbers();
60
+ let scope = _.join(
61
+ _.map(numbers, (number) => {
62
+ if (_.isArray(_.head(number))) {
63
+ return _.join(
64
+ _.map(number, (e) => _.join(e, "-")),
65
+ ", "
66
+ );
67
+ }
68
+ return _.join(number, "-");
69
+ }),
70
+ ", "
71
+ );
72
+ if (condition.type == ExprConditionType.ASSIGN) {
73
+ return this.t(
74
+ "survey_creator.question.evaluation.condition.assign_template",
75
+ [
76
+ scope,
77
+ _.join(payload.values, "、"),
78
+ _.unescape(payload.operator),
79
+ payload.size,
80
+ ]
81
+ );
82
+ } else if (condition.type == ExprConditionType.AUTO) {
83
+ return this.t(
84
+ "survey_creator.question.evaluation.condition.auto_template",
85
+ [scope, _.join(payload.values, "、")]
86
+ );
50
87
  }
51
- return _.join(number, "-");
52
- }), ", ");
53
-
54
- if (condition.type == ExprConditionType.ASSIGN) {
55
- return this.t('survey_creator.question.evaluation.condition.assign_template', [scope, _.join(payload.values, "、"), payload.operator, payload.size]);
56
- } else if (condition.type == ExprConditionType.AUTO) {
57
- return this.t('survey_creator.question.evaluation.condition.auto_template', [scope, _.join(payload.values, "、")]);
88
+ return "";
58
89
  }
59
90
  },
60
91
  getChineseLength(_str) {
@@ -67,19 +98,20 @@ export default Vue.extend({
67
98
  return chinese ? chinese.length : 0;
68
99
  },
69
100
  initialDesc() {
70
- let desc = '';
101
+ let desc = "";
71
102
  let ds = _.map(this.conditions, (c) => {
72
103
  return this.getDesc(c);
73
104
  });
74
- desc = _.join(ds, '</br>')
105
+ desc = _.join(ds, "</br>");
75
106
  this.desc = desc;
76
107
  let strLength = desc.length;
77
- let cLength = this.getChineseLength(desc.substring(0, SPLIT_LENGTH))
108
+ let cLength = this.getChineseLength(desc.substring(0, SPLIT_LENGTH));
78
109
  if (strLength > SPLIT_LENGTH) {
79
- this.desc = desc.substring(0, SPLIT_LENGTH - _.ceil(cLength / 2)) + "..."
110
+ this.desc =
111
+ desc.substring(0, SPLIT_LENGTH - _.ceil(cLength / 2)) + "...";
80
112
  }
81
113
  this.descTitle = desc;
82
- }
83
- }
114
+ },
115
+ },
84
116
  });
85
117
  </script>