@wg-npm/survey-creator 0.5.0 → 0.5.2

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.
@@ -76,6 +76,7 @@ var defaultLang = {
76
76
  delete_option_desc: "该选项参与逻辑跳转设置,删除后,相关逻辑跳转关系会自动清除,是否确认要删除?",
77
77
  delete_question_desc: "该题目参与逻辑跳转设置,删除后,相关逻辑跳转关系会自动清除,是否确认要删除?",
78
78
  },
79
+ incomplete_tips: "题目未设置完整",
79
80
  optional: "选项",
80
81
  sub_questions: "子题",
81
82
  score: "分值",
@@ -985,8 +986,22 @@ var script$J = Vue.extend({
985
986
  type: Object,
986
987
  required: true,
987
988
  },
989
+ surveyCustomQuestions: {
990
+ type: Array,
991
+ required: false,
992
+ },
988
993
  },
989
994
  computed: {
995
+ customFilledTitle() {
996
+ return _$1.find(this.surveyCustomQuestions, (q) => q.id === this.question.id).filledTitle;
997
+ },
998
+ formatTitle() {
999
+ let title = this.translate(this.question.header.text, true);
1000
+ if (!this.isRichText) {
1001
+ return [title];
1002
+ }
1003
+ return title.split(/_{5,}/g);
1004
+ },
990
1005
  maxScore() {
991
1006
  return BaseQuestionModel.getMaxScore(this.question);
992
1007
  },
@@ -1011,24 +1026,77 @@ var script$J = Vue.extend({
1011
1026
  },
1012
1027
  },
1013
1028
  methods: {
1014
- formatTitle(title) {
1015
- if (!this.isRichText) {
1016
- return title;
1029
+ showInput(index) {
1030
+ if (index === this.formatTitle.length - 2 &&
1031
+ this.formatTitle[this.formatTitle.length - 1] === "") {
1032
+ return false;
1017
1033
  }
1018
- const inputHtml = `<Input style="border: 1px solid #dcdee2;border-radius: 3px;font-size: 12px;margin: 0 16px 8px;padding: 4px;" placeholder="${this.t("survey_creator.question.rich_text.input_placeholder")}" />`;
1019
- return title.replace(/_{5,}/g, inputHtml);
1034
+ return index < this.formatTitle.length - 1;
1020
1035
  },
1021
1036
  },
1022
1037
  });
1023
1038
 
1039
+ const isOldIE = typeof navigator !== 'undefined' &&
1040
+ /msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());
1041
+ function createInjector(context) {
1042
+ return (id, style) => addStyle(id, style);
1043
+ }
1044
+ let HEAD;
1045
+ const styles = {};
1046
+ function addStyle(id, css) {
1047
+ const group = isOldIE ? css.media || 'default' : id;
1048
+ const style = styles[group] || (styles[group] = { ids: new Set(), styles: [] });
1049
+ if (!style.ids.has(id)) {
1050
+ style.ids.add(id);
1051
+ let code = css.source;
1052
+ if (css.map) {
1053
+ // https://developer.chrome.com/devtools/docs/javascript-debugging
1054
+ // this makes source maps inside style tags work properly in Chrome
1055
+ code += '\n/*# sourceURL=' + css.map.sources[0] + ' */';
1056
+ // http://stackoverflow.com/a/26603875
1057
+ code +=
1058
+ '\n/*# sourceMappingURL=data:application/json;base64,' +
1059
+ btoa(unescape(encodeURIComponent(JSON.stringify(css.map)))) +
1060
+ ' */';
1061
+ }
1062
+ if (!style.element) {
1063
+ style.element = document.createElement('style');
1064
+ style.element.type = 'text/css';
1065
+ if (css.media)
1066
+ style.element.setAttribute('media', css.media);
1067
+ if (HEAD === undefined) {
1068
+ HEAD = document.head || document.getElementsByTagName('head')[0];
1069
+ }
1070
+ HEAD.appendChild(style.element);
1071
+ }
1072
+ if ('styleSheet' in style.element) {
1073
+ style.styles.push(code);
1074
+ style.element.styleSheet.cssText = style.styles
1075
+ .filter(Boolean)
1076
+ .join('\n');
1077
+ }
1078
+ else {
1079
+ const index = style.ids.size - 1;
1080
+ const textNode = document.createTextNode(code);
1081
+ const nodes = style.element.childNodes;
1082
+ if (nodes[index])
1083
+ style.element.removeChild(nodes[index]);
1084
+ if (nodes.length)
1085
+ style.element.insertBefore(textNode, nodes[index]);
1086
+ else
1087
+ style.element.appendChild(textNode);
1088
+ }
1089
+ }
1090
+ }
1091
+
1024
1092
  /* script */
1025
1093
  const __vue_script__$J = script$J;
1026
1094
 
1027
1095
  /* template */
1028
- var __vue_render__$J = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"question-title"},[_c('label',{staticClass:"star"},[_vm._v(_vm._s(_vm.question.options.required ? "*" : ""))]),_vm._v(" "),(_vm.question.header.number)?_c('span',{staticClass:"number"},[_vm._v(_vm._s(_vm.question.header.number)+".")]):_vm._e(),_vm._v(" "),_c('span',{staticClass:"content",domProps:{"innerHTML":_vm._s(_vm.formatTitle(_vm.translate(_vm.question.header.text, true)))}}),_vm._v(" "),(_vm.haveMaxScore)?_c('span',{staticClass:"options-explain"},[_vm._v("("+_vm._s(_vm.t("survey_creator.question.max_score", _vm.$rootComponent.currentLanguage))+_vm._s(_vm.maxScore)+")\n ")]):_vm._e(),_vm._v(" "),(_vm.haveScoreRange)?_c('span',{staticClass:"options-explain"},[_vm._v("("+_vm._s(_vm.t(
1096
+ var __vue_render__$J = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"question-title"},[_c('label',{staticClass:"star"},[_vm._v(_vm._s(_vm.question.options.required ? "*" : ""))]),_vm._v(" "),(_vm.question.header.number)?_c('span',{staticClass:"number pl-sm"},[_vm._v(_vm._s(_vm.question.header.number)+".")]):_vm._e(),_vm._v(" "),_vm._l((_vm.formatTitle),function(title,index){return _c('div',{key:index,staticClass:"flex pl-sm"},[(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('Input',{model:{value:(customTitle.title),callback:function ($$v) {_vm.$set(customTitle, "title", (typeof $$v === 'string'? $$v.trim(): $$v));},expression:"customTitle.title"}}):_c('div',[(_vm.showInput(index) && index === customTitle.index)?_c('Input',{staticClass:"pl-sm",model:{value:(customTitle.title),callback:function ($$v) {_vm.$set(customTitle, "title", (typeof $$v === 'string'? $$v.trim(): $$v));},expression:"customTitle.title"}}):_vm._e()],1)],1)})],2)}),_vm._v(" "),(_vm.haveMaxScore)?_c('span',{staticClass:"options-explain pl-sm"},[_vm._v("("+_vm._s(_vm.t("survey_creator.question.max_score", _vm.$rootComponent.currentLanguage))+_vm._s(_vm.maxScore)+")\n ")]):_vm._e(),_vm._v(" "),(_vm.haveScoreRange)?_c('span',{staticClass:"options-explain pl-sm"},[_vm._v("("+_vm._s(_vm.t(
1029
1097
  "survey_creator.question.scoring.scoreRange",
1030
1098
  _vm.$rootComponent.currentLanguage
1031
- ))+_vm._s(_vm.scoreRange)+")\n ")]):_vm._e(),_vm._v(" "),(_vm.haveStar)?_c('span',{staticClass:"options-explain"},[(_vm.isSingleSelection)?_c('span',[_vm._v("\n ("+_vm._s(_vm.t(
1099
+ ))+_vm._s(_vm.scoreRange)+")\n ")]):_vm._e(),_vm._v(" "),(_vm.haveStar)?_c('span',{staticClass:"options-explain pl-sm"},[(_vm.isSingleSelection)?_c('span',[_vm._v("\n ("+_vm._s(_vm.t(
1032
1100
  "survey_creator.question.star_single",
1033
1101
  _vm.$rootComponent.currentLanguage
1034
1102
  ))+"\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(
@@ -1040,19 +1108,21 @@ var __vue_render__$J = function () {var _vm=this;var _h=_vm.$createElement;var _
1040
1108
  ))+"\n "+_vm._s(_vm.question.options.starMinCount)+"\n "+_vm._s(_vm.t(
1041
1109
  "survey_creator.question.star_multi_suffix",
1042
1110
  _vm.$rootComponent.currentLanguage
1043
- ))+"\n )\n ")],1)]):_vm._e()])};
1111
+ ))+"\n )\n ")],1)]):_vm._e()],2)};
1044
1112
  var __vue_staticRenderFns__$J = [];
1045
1113
 
1046
1114
  /* style */
1047
- const __vue_inject_styles__$J = undefined;
1115
+ const __vue_inject_styles__$J = function (inject) {
1116
+ if (!inject) return
1117
+ inject("data-v-d10d41aa_0", { source: ".flex[data-v-d10d41aa]{display:flex;align-items:center;white-space:nowrap}.pl-sm[data-v-d10d41aa]{padding-left:4px}", map: undefined, media: undefined });
1118
+
1119
+ };
1048
1120
  /* scoped */
1049
- const __vue_scope_id__$J = undefined;
1121
+ const __vue_scope_id__$J = "data-v-d10d41aa";
1050
1122
  /* module identifier */
1051
1123
  const __vue_module_identifier__$J = undefined;
1052
1124
  /* functional template */
1053
1125
  const __vue_is_functional_template__$J = false;
1054
- /* style inject */
1055
-
1056
1126
  /* style inject SSR */
1057
1127
 
1058
1128
  /* style inject shadow dom */
@@ -1067,7 +1137,7 @@ var __vue_staticRenderFns__$J = [];
1067
1137
  __vue_is_functional_template__$J,
1068
1138
  __vue_module_identifier__$J,
1069
1139
  false,
1070
- undefined,
1140
+ createInjector,
1071
1141
  undefined,
1072
1142
  undefined
1073
1143
  );
@@ -1102,59 +1172,6 @@ var script$I = Vue.extend({
1102
1172
  },
1103
1173
  });
1104
1174
 
1105
- const isOldIE = typeof navigator !== 'undefined' &&
1106
- /msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());
1107
- function createInjector(context) {
1108
- return (id, style) => addStyle(id, style);
1109
- }
1110
- let HEAD;
1111
- const styles = {};
1112
- function addStyle(id, css) {
1113
- const group = isOldIE ? css.media || 'default' : id;
1114
- const style = styles[group] || (styles[group] = { ids: new Set(), styles: [] });
1115
- if (!style.ids.has(id)) {
1116
- style.ids.add(id);
1117
- let code = css.source;
1118
- if (css.map) {
1119
- // https://developer.chrome.com/devtools/docs/javascript-debugging
1120
- // this makes source maps inside style tags work properly in Chrome
1121
- code += '\n/*# sourceURL=' + css.map.sources[0] + ' */';
1122
- // http://stackoverflow.com/a/26603875
1123
- code +=
1124
- '\n/*# sourceMappingURL=data:application/json;base64,' +
1125
- btoa(unescape(encodeURIComponent(JSON.stringify(css.map)))) +
1126
- ' */';
1127
- }
1128
- if (!style.element) {
1129
- style.element = document.createElement('style');
1130
- style.element.type = 'text/css';
1131
- if (css.media)
1132
- style.element.setAttribute('media', css.media);
1133
- if (HEAD === undefined) {
1134
- HEAD = document.head || document.getElementsByTagName('head')[0];
1135
- }
1136
- HEAD.appendChild(style.element);
1137
- }
1138
- if ('styleSheet' in style.element) {
1139
- style.styles.push(code);
1140
- style.element.styleSheet.cssText = style.styles
1141
- .filter(Boolean)
1142
- .join('\n');
1143
- }
1144
- else {
1145
- const index = style.ids.size - 1;
1146
- const textNode = document.createTextNode(code);
1147
- const nodes = style.element.childNodes;
1148
- if (nodes[index])
1149
- style.element.removeChild(nodes[index]);
1150
- if (nodes.length)
1151
- style.element.insertBefore(textNode, nodes[index]);
1152
- else
1153
- style.element.appendChild(textNode);
1154
- }
1155
- }
1156
- }
1157
-
1158
1175
  /* script */
1159
1176
  const __vue_script__$I = script$I;
1160
1177
 
@@ -4983,15 +5000,37 @@ var script$6 = Vue.extend({
4983
5000
  type: Object,
4984
5001
  required: true,
4985
5002
  },
5003
+ surveyCustomQuestions: {
5004
+ type: Array,
5005
+ required: false,
5006
+ },
4986
5007
  },
4987
5008
  data() {
4988
5009
  return {
4989
5010
  enabledSelectQuestion: false,
4990
- isSelectedQuestion: false
5011
+ isSelectedQuestion: false,
4991
5012
  };
4992
5013
  },
4993
5014
  created() {
4994
- this.enabledSelectQuestion = _.get(this.$rootComponent, "options.enabledSelectQuestion", false);
5015
+ this.enabledSelectQuestion = _$1.get(this.$rootComponent, "options.enabledSelectQuestion", false);
5016
+ this.enabledQuestionTitleIncompleteTips = _$1.get(this.$rootComponent, "options.enabledQuestionTitleIncompleteTips", false);
5017
+ },
5018
+ computed: {
5019
+ getClassStyle() {
5020
+ return this.questionTitleIncomplete ? "" : "question-incomplete";
5021
+ },
5022
+ questionTitleIncomplete() {
5023
+ if (!this.enabledQuestionTitleIncompleteTips) {
5024
+ return true;
5025
+ }
5026
+ let filledTitle = _$1.find(this.surveyCustomQuestions, (q) => q.id === this.question.id)?.filledTitle;
5027
+ if (_$1.isEmpty(filledTitle)) {
5028
+ return true;
5029
+ }
5030
+ else {
5031
+ return _$1.every(filledTitle, (t) => t.title !== "");
5032
+ }
5033
+ },
4995
5034
  },
4996
5035
  methods: {
4997
5036
  getJumpRules(val) {
@@ -5010,22 +5049,24 @@ var script$6 = Vue.extend({
5010
5049
  const __vue_script__$6 = script$6;
5011
5050
 
5012
5051
  /* template */
5013
- var __vue_render__$6 = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('Card',{staticClass:"question-row",attrs:{"padding":0,"bordered":false,"dis-hover":true}},[_c('div',{staticClass:"question-row-container"},[(_vm.enabledSelectQuestion)?_c('div',{staticClass:"question-row-container-left"},[_c('Checkbox',{on:{"on-change":_vm.onSelectQuestion},model:{value:(_vm.isSelectedQuestion),callback:function ($$v) {_vm.isSelectedQuestion=$$v;},expression:"isSelectedQuestion"}})],1):_vm._e(),_vm._v(" "),_c('div',{staticClass:"question-row-container-right"},[_c('Divider',{staticClass:"question-type-desc",attrs:{"orientation":"left"}},[_vm._v("\n "+_vm._s(_vm.t(
5052
+ var __vue_render__$6 = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('Card',{staticClass:"question-row",attrs:{"padding":0,"bordered":false,"dis-hover":true}},[_c('div',{staticClass:"question-row-container"},[(_vm.enabledSelectQuestion)?_c('div',{staticClass:"question-row-container-left"},[_c('Checkbox',{on:{"on-change":_vm.onSelectQuestion},model:{value:(_vm.isSelectedQuestion),callback:function ($$v) {_vm.isSelectedQuestion=$$v;},expression:"isSelectedQuestion"}})],1):_vm._e(),_vm._v(" "),_c('div',{staticClass:"question-row-container-right",class:_vm.getClassStyle},[_c('span',{directives:[{name:"show",rawName:"v-show",value:(!_vm.questionTitleIncomplete),expression:"!questionTitleIncomplete"}],staticClass:"incomplete-tips"},[_vm._v("\n "+_vm._s(_vm.t("survey_creator.question.incomplete_tips"))+"\n ")]),_vm._v(" "),_c('Divider',{staticClass:"question-type-desc",attrs:{"orientation":"left"}},[_vm._v("\n "+_vm._s(_vm.t(
5014
5053
  ("survey_creator.question.types." + (_vm.question.type)),
5015
5054
  _vm.$rootComponent.currentLanguage
5016
- ))+"\n ")]),_vm._v(" "),_c('question-title',{attrs:{"question":_vm.question,"max-score":true}}),_vm._v(" "),_c('div',{staticClass:"question-row-content"},[_c(_vm.question.type,{tag:"component",staticClass:"question",attrs:{"question":_vm.question,"survey":_vm.survey},on:{"singleQuestion":_vm.getJumpRules}})],1)],1)])])};
5055
+ ))+"\n ")]),_vm._v(" "),_c('question-title',{attrs:{"question":_vm.question,"max-score":true,"survey-custom-questions":_vm.surveyCustomQuestions}}),_vm._v(" "),_c('div',{staticClass:"question-row-content"},[_c(_vm.question.type,{tag:"component",staticClass:"question",attrs:{"question":_vm.question,"survey":_vm.survey},on:{"singleQuestion":_vm.getJumpRules}})],1)],1)])])};
5017
5056
  var __vue_staticRenderFns__$6 = [];
5018
5057
 
5019
5058
  /* style */
5020
- const __vue_inject_styles__$6 = undefined;
5059
+ const __vue_inject_styles__$6 = function (inject) {
5060
+ if (!inject) return
5061
+ inject("data-v-05fe3060_0", { source: ".question-incomplete[data-v-05fe3060]{border:1px solid #ed4014;border-radius:4px}.question-incomplete .incomplete-tips[data-v-05fe3060]{position:absolute;left:15px;top:16px;padding:2px 4px;background:#f85353;border-radius:4px 0;font-weight:400;font-size:12px;line-height:18px;color:#fff}", map: undefined, media: undefined });
5062
+
5063
+ };
5021
5064
  /* scoped */
5022
- const __vue_scope_id__$6 = undefined;
5065
+ const __vue_scope_id__$6 = "data-v-05fe3060";
5023
5066
  /* module identifier */
5024
5067
  const __vue_module_identifier__$6 = undefined;
5025
5068
  /* functional template */
5026
5069
  const __vue_is_functional_template__$6 = false;
5027
- /* style inject */
5028
-
5029
5070
  /* style inject SSR */
5030
5071
 
5031
5072
  /* style inject shadow dom */
@@ -5040,7 +5081,7 @@ var __vue_staticRenderFns__$6 = [];
5040
5081
  __vue_is_functional_template__$6,
5041
5082
  __vue_module_identifier__$6,
5042
5083
  false,
5043
- undefined,
5084
+ createInjector,
5044
5085
  undefined,
5045
5086
  undefined
5046
5087
  );
@@ -5059,6 +5100,10 @@ var script$5 = Vue.extend({
5059
5100
  type: Array,
5060
5101
  required: false,
5061
5102
  },
5103
+ surveyCustomQuestions: {
5104
+ type: Array,
5105
+ required: false,
5106
+ },
5062
5107
  },
5063
5108
  data() {
5064
5109
  return {
@@ -5141,7 +5186,8 @@ var script$5 = Vue.extend({
5141
5186
  },
5142
5187
  selectQuestionHandler(selected, question) {
5143
5188
  this.$refs[`question${question.id}`][0].selectQuestion(selected);
5144
- this.selectedQuestions.push(question);
5189
+ this.selectedQuestions.find((i) => i.id === question.id) ||
5190
+ this.selectedQuestions.push(question);
5145
5191
  if (Array.isArray(question.jumps) && question.jumps.length > 0) {
5146
5192
  question.jumps.forEach((item) => {
5147
5193
  const jumpItem = this.sortQuestions.find((i) => item.toQuestionId === i.id);
@@ -5183,7 +5229,7 @@ var script$5 = Vue.extend({
5183
5229
  const __vue_script__$5 = script$5;
5184
5230
 
5185
5231
  /* template */
5186
- var __vue_render__$5 = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"survey-internal-previewer-wrapper"},_vm._l((_vm.sortQuestions),function(question){return _c('previewer-question-row',{key:question.id,ref:("question" + (question.id)),refInFor:true,attrs:{"question":question,"survey":_vm.survey},on:{"singleQuestion":_vm.handleSelected,"onSelectQuestion":_vm.onSelectQuestion}})}),1)};
5232
+ var __vue_render__$5 = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"survey-internal-previewer-wrapper"},_vm._l((_vm.sortQuestions),function(question){return _c('previewer-question-row',{key:question.id,ref:("question" + (question.id)),refInFor:true,attrs:{"question":question,"survey":_vm.survey,"survey-custom-questions":_vm.surveyCustomQuestions},on:{"singleQuestion":_vm.handleSelected,"onSelectQuestion":_vm.onSelectQuestion}})}),1)};
5187
5233
  var __vue_staticRenderFns__$5 = [];
5188
5234
 
5189
5235
  /* style */
@@ -5853,6 +5899,10 @@ var script = Vue.extend({
5853
5899
  type: Array,
5854
5900
  required: false,
5855
5901
  },
5902
+ surveyCustomQuestions: {
5903
+ type: Array,
5904
+ required: false,
5905
+ },
5856
5906
  },
5857
5907
  data() {
5858
5908
  return {
@@ -5862,6 +5912,7 @@ var script = Vue.extend({
5862
5912
  },
5863
5913
  created() {
5864
5914
  this.setSurveyLanguage(this.survey);
5915
+ this.prepareSurveyCustomQuestions();
5865
5916
  },
5866
5917
  methods: {
5867
5918
  onBack() {
@@ -5875,6 +5926,43 @@ var script = Vue.extend({
5875
5926
  selectedQuestionIds(questionIds) {
5876
5927
  this.$emit("selected-question-ids", questionIds);
5877
5928
  },
5929
+ formatTitle(question) {
5930
+ let title = this.translate(question.header.text, true);
5931
+ if (!_$1.get(question, "options.richTextEnabled", false)) {
5932
+ return [title];
5933
+ }
5934
+ return title.split(/_{5,}/g);
5935
+ },
5936
+ showInput(index, formatTitle) {
5937
+ if (index === formatTitle.length - 2 &&
5938
+ formatTitle[formatTitle.length - 1] === "") {
5939
+ return false;
5940
+ }
5941
+ return index < formatTitle.length - 1;
5942
+ },
5943
+ prepareSurveyCustomQuestions() {
5944
+ if (_$1.isEmpty(this.surveyCustomQuestions)) {
5945
+ this.surveyCustomQuestions = [];
5946
+ _$1.each(this.survey.questions, (q) => {
5947
+ let input_titles = [];
5948
+ _$1.each(this.formatTitle(q), (t, index) => {
5949
+ if (t === "" || this.showInput(index, this.formatTitle(q))) {
5950
+ let title = {
5951
+ title: "",
5952
+ index: index,
5953
+ };
5954
+ input_titles.push(title);
5955
+ }
5956
+ });
5957
+ let customQuestion = {
5958
+ id: q.id,
5959
+ surveyId: this.survey.id,
5960
+ filledTitle: input_titles,
5961
+ };
5962
+ this.surveyCustomQuestions.push(customQuestion);
5963
+ });
5964
+ }
5965
+ },
5878
5966
  },
5879
5967
  });
5880
5968
 
@@ -5882,7 +5970,7 @@ var script = Vue.extend({
5882
5970
  const __vue_script__ = script;
5883
5971
 
5884
5972
  /* template */
5885
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.currentSurvey)?_c('div',{staticClass:"survey-preview-wrapper"},[_c('Row',{attrs:{"type":"flex","justify":"space-between","align":"middle"}},[_c('Col',[(_vm.options.back)?_c('Button',{attrs:{"icon":"ios-arrow-back"},on:{"click":_vm.onBack}},[_vm._v("\n "+_vm._s(_vm.t("survey_creator.common.back"))+"\n ")]):_vm._e()],1),_vm._v(" "),_c('Col',[_c('toolbar',{attrs:{"survey":_vm.currentSurvey,"create-question":false,"translate":true,"preview":false,"change-language":_vm.options.changeLanguage}})],1)],1),_vm._v(" "),_c('div',{staticClass:"survey-editor-wrapper"},[_c('survey-internal-previewer',{attrs:{"survey":_vm.currentSurvey,"init-question-ids":_vm.initQuestionIds},on:{"selected-question-ids":_vm.selectedQuestionIds}})],1)],1):_vm._e()};
5973
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.currentSurvey)?_c('div',{staticClass:"survey-preview-wrapper"},[_c('Row',{attrs:{"type":"flex","justify":"space-between","align":"middle"}},[_c('Col',[(_vm.options.back)?_c('Button',{attrs:{"icon":"ios-arrow-back"},on:{"click":_vm.onBack}},[_vm._v("\n "+_vm._s(_vm.t("survey_creator.common.back"))+"\n ")]):_vm._e()],1),_vm._v(" "),_c('Col',[_c('toolbar',{attrs:{"survey":_vm.currentSurvey,"create-question":false,"translate":true,"preview":false,"change-language":_vm.options.changeLanguage}})],1)],1),_vm._v(" "),_c('div',{staticClass:"survey-editor-wrapper"},[_c('survey-internal-previewer',{attrs:{"survey":_vm.currentSurvey,"init-question-ids":_vm.initQuestionIds,"survey-custom-questions":_vm.surveyCustomQuestions},on:{"selected-question-ids":_vm.selectedQuestionIds}})],1)],1):_vm._e()};
5886
5974
  var __vue_staticRenderFns__ = [];
5887
5975
 
5888
5976
  /* style */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wg-npm/survey-creator",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
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.0",
16
- "@wg-npm/survey-service-api": "0.5.0",
15
+ "@wg-npm/survey-core": "0.5.2",
16
+ "@wg-npm/survey-service-api": "0.5.2",
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.0",
42
- "@wg-npm/survey-service-api": "0.5.0",
41
+ "@wg-npm/survey-core": "0.5.2",
42
+ "@wg-npm/survey-service-api": "0.5.2",
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": "f23e8c46f4c8377fe82943b3ec66d71c37d4f013",
82
+ "gitHead": "14683b8a6ce3c490c399141c6b395bbddfb69329",
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
- <span
8
- class="content"
9
- v-html="formatTitle(translate(question.header.text, true))"
10
- />
11
- <span class="options-explain" v-if="haveMaxScore"
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
- formatTitle(title) {
111
- if (!this.isRichText) {
112
- return title;
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
- const inputHtml = `<Input style="border: 1px solid #dcdee2;border-radius: 3px;font-size: 12px;margin: 0 16px 8px;padding: 4px;" placeholder="${this.t(
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 :question="question" :max-score="true" />
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,31 @@ export default Vue.extend({
90
102
  "options.enabledSelectQuestion",
91
103
  false
92
104
  );
105
+ // @ts-ignore
106
+ this.enabledQuestionTitleIncompleteTips = _.get(
107
+ this.$rootComponent,
108
+ "options.enabledQuestionTitleIncompleteTips",
109
+ false
110
+ );
111
+ },
112
+ computed: {
113
+ getClassStyle() {
114
+ return this.questionTitleIncomplete ? "" : "question-incomplete";
115
+ },
116
+ questionTitleIncomplete() {
117
+ if (!this.enabledQuestionTitleIncompleteTips) {
118
+ return true;
119
+ }
120
+ let filledTitle = _.find(
121
+ this.surveyCustomQuestions,
122
+ (q) => q.id === this.question.id
123
+ )?.filledTitle;
124
+ if (_.isEmpty(filledTitle)) {
125
+ return true;
126
+ } else {
127
+ return _.every(filledTitle, (t) => t.title !== "");
128
+ }
129
+ },
93
130
  },
94
131
  methods: {
95
132
  getJumpRules(val) {
@@ -104,3 +141,23 @@ export default Vue.extend({
104
141
  },
105
142
  });
106
143
  </script>
144
+
145
+ <style lang="less" scoped>
146
+ .question-incomplete {
147
+ border: 1px solid #ed4014;
148
+ border-radius: 4px;
149
+ .incomplete-tips {
150
+ position: absolute;
151
+ left: 15px;
152
+ top: 16px;
153
+ padding: 2px 4px;
154
+ background: #f85353;
155
+ border-radius: 4px 0px;
156
+
157
+ font-weight: 400;
158
+ font-size: 12px;
159
+ line-height: 18px;
160
+ color: #ffffff;
161
+ }
162
+ }
163
+ </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.push(question);
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,48 @@ 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
+ // @ts-ignore
92
+ if (!_.get(question, "options.richTextEnabled", false)) {
93
+ return [title];
94
+ }
95
+ return title.split(/_{5,}/g);
96
+ },
97
+ showInput(index, formatTitle) {
98
+ if (
99
+ index === formatTitle.length - 2 &&
100
+ formatTitle[formatTitle.length - 1] === ""
101
+ ) {
102
+ return false;
103
+ }
104
+ return index < formatTitle.length - 1;
105
+ },
106
+ prepareSurveyCustomQuestions() {
107
+ if (_.isEmpty(this.surveyCustomQuestions)) {
108
+ this.surveyCustomQuestions = [];
109
+ _.each(this.survey.questions, (q) => {
110
+ let input_titles: any = [];
111
+ _.each(this.formatTitle(q), (t, index) => {
112
+ if (t === "" || this.showInput(index, this.formatTitle(q))) {
113
+ let title = {
114
+ title: "",
115
+ index: index,
116
+ };
117
+
118
+ input_titles.push(title);
119
+ }
120
+ });
121
+
122
+ let customQuestion = {
123
+ id: q.id,
124
+ surveyId: this.survey.id,
125
+ filledTitle: input_titles,
126
+ };
127
+ this.surveyCustomQuestions.push(customQuestion);
128
+ });
129
+ }
130
+ },
83
131
  },
84
132
  });
85
133
  </script>
@@ -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",
@@ -72,6 +72,7 @@ export default {
72
72
  delete_question_desc:
73
73
  "该题目参与逻辑跳转设置,删除后,相关逻辑跳转关系会自动清除,是否确认要删除?",
74
74
  },
75
+ incomplete_tips: "题目未设置完整",
75
76
  optional: "选项",
76
77
  sub_questions: "子题",
77
78
  score: "分值",
@@ -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
  }