@wg-npm/survey-response 0.5.165 → 0.5.167

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.
@@ -875,8 +875,8 @@ var script$c = Vue.extend({
875
875
  });
876
876
  this.value.score = score;
877
877
  },
878
- toggleAnswer(subValue, subIndex) {
879
- if (this.responseStatus == this.$consts.STATUS_DRAFT) {
878
+ toggleAnswer(subValue, subIndex, disabled) {
879
+ if (this.responseStatus == this.$consts.STATUS_DRAFT && !disabled) {
880
880
  let subAnswer = this.value.answer[subIndex].answer;
881
881
  this.value.answer[subIndex].answer = _.isEmpty(subAnswer)
882
882
  ? subValue
@@ -893,7 +893,11 @@ const __vue_script__$c = script$c;
893
893
  var __vue_render__$c = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',_vm._l((_vm.question.subQuestions),function(subQuestion,subIndex){return _c('div',{key:subIndex,staticClass:"sub-question"},[_c('span',{staticClass:"number"},[_vm._v("\n "+_vm._s(_vm.question.header.number)+"-"+_vm._s(subQuestion.number)+".")]),_vm._v(" "),_c('span',{staticClass:"title"},[_vm._v(" "+_vm._s(_vm.i18nText(subQuestion.text))+" ")]),_vm._v(" "),_c('FormItem',{attrs:{"prop":_vm.answerProp(subIndex),"rules":{
894
894
  required: _vm.question.options.required && !_vm.question.options.disabled,
895
895
  message: _vm.t('survey_response.question.question_required'),
896
- }}},[_c('RadioGroup',{on:{"on-change":_vm.selChange},model:{value:(_vm.value.answer[subIndex].answer),callback:function ($$v) {_vm.$set(_vm.value.answer[subIndex], "answer", $$v);},expression:"value.answer[subIndex].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},[_c('Radio',{key:choice.id,attrs:{"label":choice.id,"disabled":subQuestion.options.readonly || _vm.question.options.disabled},nativeOn:{"click":function($event){return _vm.toggleAnswer(choice.id, subIndex)}}},[_c('span',[_vm._v(_vm._s(_vm.i18nText(choice.text)))])])],1)}),1)],1)],1)],1)}),0)};
896
+ }}},[_c('RadioGroup',{on:{"on-change":_vm.selChange},model:{value:(_vm.value.answer[subIndex].answer),callback:function ($$v) {_vm.$set(_vm.value.answer[subIndex], "answer", $$v);},expression:"value.answer[subIndex].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},[_c('Radio',{key:choice.id,attrs:{"label":choice.id,"disabled":subQuestion.options.readonly || _vm.question.options.disabled},nativeOn:{"click":function($event){return _vm.toggleAnswer(
897
+ choice.id,
898
+ subIndex,
899
+ subQuestion.options.readonly || _vm.question.options.disabled
900
+ )}}},[_c('span',[_vm._v(_vm._s(_vm.i18nText(choice.text)))])])],1)}),1)],1)],1)],1)}),0)};
897
901
  var __vue_staticRenderFns__$c = [];
898
902
 
899
903
  /* style */
@@ -1205,96 +1209,113 @@ var __vue_staticRenderFns__$9 = [];
1205
1209
 
1206
1210
  var Star = __vue_component__$9;
1207
1211
 
1208
- class ExprEvaluationQuestion {
1209
- constructor(questions, scope) {
1210
- this.questions = questions;
1211
- this.scope = _.sortBy(scope);
1212
- this.questionMap = this.buildQuestionMap();
1213
- }
1214
- calculateNumbers() {
1215
- const checkedQuestions = this.checkedQuestion();
1216
- const checkedNumberElements = new Array();
1217
- this.recurs(checkedQuestions, checkedNumberElements);
1218
- return checkedNumberElements;
1219
- }
1220
- buildQuestionMap() {
1221
- const questionMap = {};
1222
- _.forEach(this.questions, (question) => {
1223
- questionMap[question.id] = question;
1224
- if (question.type == "MATRIX") {
1225
- _.forEach(_.get(question, "subQuestions", []), (subQuestion) => {
1226
- questionMap[subQuestion.id] = subQuestion;
1227
- });
1228
- }
1229
- });
1230
- return questionMap;
1231
- }
1232
- checkedQuestion() {
1233
- const questions = new Array();
1234
- _.forEach(this.questions, (question) => {
1235
- if (_.get(question, "type") == "MATRIX") {
1236
- const markedQuestions = new Array();
1237
- _.forEach(_.get(question, "subQuestions", []), (subQuestion) => {
1238
- if (_.includes(this.scope, subQuestion.id)) {
1239
- const newSubQuestion = _.cloneDeep(subQuestion);
1240
- _.set(newSubQuestion, "type", "MATRIX");
1241
- _.set(newSubQuestion, "parentId", _.get(question, "id"));
1242
- markedQuestions.push(newSubQuestion);
1243
- }
1244
- });
1245
- if (!_.isEmpty(markedQuestions)) {
1246
- questions.push(markedQuestions);
1247
- }
1248
- }
1249
- else if (_.includes(this.scope, question.id)) {
1250
- questions.push(question);
1251
- }
1252
- });
1253
- return questions;
1254
- }
1255
- recurs(elements, numbers) {
1256
- for (let i = 0; i < elements.length; i++) {
1257
- const element = elements[i];
1258
- if (_.isArray(element)) {
1259
- numbers.push(new Array());
1260
- this.recurs(element, numbers[numbers.length - 1]);
1261
- }
1262
- else {
1263
- const temp = new Array();
1264
- temp.push(this.getFullNumber(element));
1265
- if (i == elements.length - 1) {
1266
- numbers.push(temp);
1267
- continue;
1268
- }
1269
- for (let j = i + 1;; j++) {
1270
- if (j == elements.length ||
1271
- !this.isContinuous(elements[j - 1], elements[j])) {
1272
- numbers.push(temp);
1273
- i = j - 1;
1274
- break;
1275
- }
1276
- if (_.size(temp) > 1) {
1277
- temp.pop();
1278
- }
1279
- temp.push(this.getFullNumber(elements[j]));
1280
- }
1281
- }
1282
- }
1283
- }
1284
- isContinuous(front, hind) {
1285
- return (!_.isArray(hind) && this.getNumber(hind) - this.getNumber(front) == 1);
1286
- }
1287
- getFullNumber(question) {
1288
- if (question.type == "MATRIX") {
1289
- return (this.questionMap[question.parentId].header.number +
1290
- "." +
1291
- this.getNumber(question));
1292
- }
1293
- return this.getNumber(question).toString();
1294
- }
1295
- getNumber(question) {
1296
- return question.type == "MATRIX" ? question.number : question.header.number;
1297
- }
1212
+ class ExprEvaluationQuestion {
1213
+ questions;
1214
+ scope;
1215
+ questionMap;
1216
+
1217
+ constructor(questions, scope) {
1218
+ this.questions = questions;
1219
+ this.scope = _.sortBy(scope);
1220
+
1221
+ this.questionMap = this.buildQuestionMap();
1222
+ }
1223
+
1224
+ calculateNumbers() {
1225
+ const checkedQuestions = this.checkedQuestion();
1226
+ const checkedNumberElements = new Array();
1227
+ this.recurs(checkedQuestions, checkedNumberElements);
1228
+
1229
+ return checkedNumberElements;
1230
+ }
1231
+
1232
+ buildQuestionMap() {
1233
+ const questionMap = {};
1234
+ _.forEach(this.questions, (question) => {
1235
+ questionMap[question.id] = question;
1236
+ if (question.type == "MATRIX") {
1237
+ _.forEach(_.get(question, "subQuestions", []), (subQuestion) => {
1238
+ questionMap[subQuestion.id] = subQuestion;
1239
+ });
1240
+ }
1241
+ });
1242
+ return questionMap;
1243
+ }
1244
+
1245
+ checkedQuestion() {
1246
+ const questions = new Array();
1247
+ _.forEach(this.questions, (question) => {
1248
+ if (_.get(question, "type") == "MATRIX") {
1249
+ const markedQuestions = new Array();
1250
+ _.forEach(_.get(question, "subQuestions", []), (subQuestion) => {
1251
+ if (_.includes(this.scope, subQuestion.id)) {
1252
+ const newSubQuestion = _.cloneDeep(subQuestion);
1253
+ _.set(newSubQuestion, "type", "MATRIX");
1254
+ _.set(newSubQuestion, "parentId", _.get(question, "id"));
1255
+ markedQuestions.push(newSubQuestion);
1256
+ }
1257
+ });
1258
+ if (!_.isEmpty(markedQuestions)) {
1259
+ questions.push(markedQuestions);
1260
+ }
1261
+ } else if (_.includes(this.scope, question.id)) {
1262
+ questions.push(question);
1263
+ }
1264
+ });
1265
+ return questions;
1266
+ }
1267
+
1268
+ recurs(elements, numbers) {
1269
+ for (let i = 0; i < elements.length; i++) {
1270
+ const element = elements[i];
1271
+ if (_.isArray(element)) {
1272
+ numbers.push(new Array());
1273
+ this.recurs(element, numbers[numbers.length - 1]);
1274
+ } else {
1275
+ const temp = new Array();
1276
+ temp.push(this.getFullNumber(element));
1277
+ if (i == elements.length - 1) {
1278
+ numbers.push(temp);
1279
+ continue;
1280
+ }
1281
+ for (let j = i + 1; ; j++) {
1282
+ if (
1283
+ j == elements.length ||
1284
+ !this.isContinuous(elements[j - 1], elements[j])
1285
+ ) {
1286
+ numbers.push(temp);
1287
+ i = j - 1;
1288
+ break;
1289
+ }
1290
+ if (_.size(temp) > 1) {
1291
+ temp.pop();
1292
+ }
1293
+ temp.push(this.getFullNumber(elements[j]));
1294
+ }
1295
+ }
1296
+ }
1297
+ }
1298
+
1299
+ isContinuous(front, hind) {
1300
+ return (
1301
+ !_.isArray(hind) && this.getNumber(hind) - this.getNumber(front) == 1
1302
+ );
1303
+ }
1304
+
1305
+ getFullNumber(question) {
1306
+ if (question.type == "MATRIX") {
1307
+ return (
1308
+ this.questionMap[question.parentId].header.number +
1309
+ "." +
1310
+ this.getNumber(question)
1311
+ );
1312
+ }
1313
+ return this.getNumber(question).toString();
1314
+ }
1315
+
1316
+ getNumber(question) {
1317
+ return question.type == "MATRIX" ? question.number : question.header.number;
1318
+ }
1298
1319
  }
1299
1320
 
1300
1321
  const SPLIT_LENGTH = 50;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wg-npm/survey-response",
3
- "version": "0.5.165",
3
+ "version": "0.5.167",
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.165",
16
- "@wg-npm/survey-service-api": "0.5.165",
15
+ "@wg-npm/survey-core": "0.5.167",
16
+ "@wg-npm/survey-service-api": "0.5.167",
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.165",
38
- "@wg-npm/survey-service-api": "0.5.165",
37
+ "@wg-npm/survey-core": "0.5.167",
38
+ "@wg-npm/survey-service-api": "0.5.167",
39
39
  "acorn": "^7.3.1",
40
40
  "axios": "^0.19.2",
41
41
  "babelrc-rollup": "^3.0.0",
@@ -29,7 +29,13 @@
29
29
  <Radio
30
30
  :label="choice.id"
31
31
  :key="choice.id"
32
- @click.native="toggleAnswer(choice.id, subIndex)"
32
+ @click.native="
33
+ toggleAnswer(
34
+ choice.id,
35
+ subIndex,
36
+ subQuestion.options.readonly || question.options.disabled
37
+ )
38
+ "
33
39
  :disabled="
34
40
  subQuestion.options.readonly || question.options.disabled
35
41
  "
@@ -138,8 +144,8 @@ export default Vue.extend({
138
144
  // @ts-ignore
139
145
  this.value.score = score;
140
146
  },
141
- toggleAnswer(subValue, subIndex) {
142
- if (this.responseStatus == this.$consts.STATUS_DRAFT) {
147
+ toggleAnswer(subValue, subIndex, disabled) {
148
+ if (this.responseStatus == this.$consts.STATUS_DRAFT && !disabled) {
143
149
  let subAnswer = this.value.answer[subIndex].answer;
144
150
  this.value.answer[subIndex].answer = _.isEmpty(subAnswer)
145
151
  ? subValue