@wg-npm/survey-creator 0.3.4143 → 0.3.4156

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.
@@ -4324,6 +4324,16 @@ var script$1 = Vue.extend({
4324
4324
  options: {
4325
4325
  type: Object,
4326
4326
  required: true
4327
+ },
4328
+ showQuestionWhenPageLoad: {
4329
+ type: Boolean,
4330
+ required: false,
4331
+ default: false
4332
+ },
4333
+ showQuestionType: {
4334
+ type: String,
4335
+ required: false,
4336
+ default: "EVALUATION"
4327
4337
  }
4328
4338
  },
4329
4339
  data: function () {
@@ -4355,6 +4365,15 @@ var script$1 = Vue.extend({
4355
4365
  this.currentSurvey.questions[0].active = true;
4356
4366
  }
4357
4367
  this.primaryLanguage = _.camelCase(this.currentSurvey.options.primaryLanguage);
4368
+ if (this.showQuestionWhenPageLoad) {
4369
+ const question = _.findLast(this.currentSurvey?.questions, questions => { return questions.type === this.showQuestionType; });
4370
+ if (_.isUndefined(question)) {
4371
+ this.createQuestion(this.showQuestionType);
4372
+ }
4373
+ else {
4374
+ this.showQuestionEditDrawer(question);
4375
+ }
4376
+ }
4358
4377
  },
4359
4378
  computed: {
4360
4379
  isEditMode() {
@@ -4456,6 +4475,10 @@ var script$1 = Vue.extend({
4456
4475
  }
4457
4476
  BaseQuestionModel.refreshSurvey(this.currentSurvey);
4458
4477
  BaseQuestionModel.setActiveQuestion(newQuestion, this.currentSurvey.questions);
4478
+ if (this.showQuestionWhenPageLoad) {
4479
+ this.onSave();
4480
+ this.onBack();
4481
+ }
4459
4482
  },
4460
4483
  onQuestionDelete(id) {
4461
4484
  _.remove(this.currentSurvey.questions, function (question) {
@@ -4486,7 +4509,7 @@ var script$1 = Vue.extend({
4486
4509
  const __vue_script__$1 = script$1;
4487
4510
 
4488
4511
  /* template */
4489
- var __vue_render__$1 = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"survey-creator-wrapper"},[_c('Card',{attrs:{"shadow":""}},[_c('Row',{attrs:{"align":"middle","justify":"space-between","type":"flex"}},[_c('Col',{attrs:{"span":"20"}},[_c('Icon',{staticClass:"icon-clipboard",attrs:{"custom":"i-icon icon-clipboard","size":"24"}}),_vm._v(" "),_c('span',{staticClass:"title"},[_vm._v("\n "+_vm._s(_vm._f("translate")(_vm.survey.name.text,true))+"\n ")])],1),_vm._v(" "),_c('Col',[_c('Button',{attrs:{"icon":"ios-arrow-back"},on:{"click":_vm.onBack}},[_vm._v(_vm._s(_vm.t('survey_creator.common.back')))])],1)],1)],1),_vm._v(" "),(_vm.isPreviewMode)?_c('survey-internal-previewer',{staticStyle:{"min-height":"calc(100vh - 128px)"},attrs:{"options":this.options,"survey":this.currentSurvey,"operation-type":_vm.questionOperationType}}):_c('Card',{staticStyle:{"min-height":"calc(100vh - 128px)"},attrs:{"shadow":""}},[_c('Tabs',{attrs:{"type":"card"},model:{value:(_vm.activeTab),callback:function ($$v) {_vm.activeTab=$$v;},expression:"activeTab"}},[_c('TabPane',{attrs:{"label":_vm.t('survey_creator.common.tab.question_setting'),"name":"EDIT"}},[(_vm.activeTab == 'EDIT')?_c('div',[_c('Row',{staticClass:"survey-operate",attrs:{"type":"flex","justify":"space-between","align":"middle","gutter":48}},[_c('Col',[_c('create-question-dropdown')],1),_vm._v(" "),_c('Col',[_c('edit-options',{staticClass:"edit-option",attrs:{"survey":this.currentSurvey}})],1)],1),_vm._v(" "),_c('Scroll',{staticClass:"question-content",attrs:{"height":_vm.height}},[_c('survey-editor',{attrs:{"options":this.options,"survey":this.currentSurvey}})],1)],1):_vm._e()]),_vm._v(" "),_c('TabPane',{attrs:{"label":_vm.t('survey_creator.common.tab.language'),"name":"TRANSLATE"}},[(_vm.activeTab == 'TRANSLATE')?_c('survey-translator',{attrs:{"options":this.options,"survey":this.currentSurvey}}):_vm._e()],1)],1)],1),_vm._v(" "),_c('question-edit-drawer',{ref:"editDrawer",attrs:{"question":_vm.editingQuestion,"operation-type":_vm.operationType},model:{value:(_vm.questionEditDrawerVisible),callback:function ($$v) {_vm.questionEditDrawerVisible=$$v;},expression:"questionEditDrawerVisible"}}),_vm._v(" "),_c('Card',{attrs:{"shadow":""}},[_c('Row',{attrs:{"gutter":30,"align":"middle","justify":"center","type":"flex"}},[_c('Col',[_c('Button',{attrs:{"loading":_vm.loading,"type":"primary","disabled":_vm.isSaved},on:{"click":_vm.onSave}},[_vm._v(_vm._s(_vm.t("survey_creator.common.save"))+"\n ")])],1)],1)],1)],1)};
4512
+ var __vue_render__$1 = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[(_vm.showQuestionWhenPageLoad)?_c('div',[_c('question-edit-drawer',{ref:"editDrawer",attrs:{"question":_vm.editingQuestion,"operation-type":_vm.operationType},model:{value:(_vm.questionEditDrawerVisible),callback:function ($$v) {_vm.questionEditDrawerVisible=$$v;},expression:"questionEditDrawerVisible"}})],1):_c('div',{staticClass:"survey-creator-wrapper"},[_c('Card',{attrs:{"shadow":""}},[_c('Row',{attrs:{"align":"middle","justify":"space-between","type":"flex"}},[_c('Col',{attrs:{"span":"20"}},[_c('Icon',{staticClass:"icon-clipboard",attrs:{"custom":"i-icon icon-clipboard","size":"24"}}),_vm._v(" "),_c('span',{staticClass:"title"},[_vm._v("\n "+_vm._s(_vm._f("translate")(_vm.survey.name.text,true))+"\n ")])],1),_vm._v(" "),_c('Col',[_c('Button',{attrs:{"icon":"ios-arrow-back"},on:{"click":_vm.onBack}},[_vm._v(_vm._s(_vm.t('survey_creator.common.back')))])],1)],1)],1),_vm._v(" "),(_vm.isPreviewMode)?_c('survey-internal-previewer',{staticStyle:{"min-height":"calc(100vh - 128px)"},attrs:{"options":this.options,"survey":this.currentSurvey,"operation-type":_vm.questionOperationType}}):_c('Card',{staticStyle:{"min-height":"calc(100vh - 128px)"},attrs:{"shadow":""}},[_c('Tabs',{attrs:{"type":"card"},model:{value:(_vm.activeTab),callback:function ($$v) {_vm.activeTab=$$v;},expression:"activeTab"}},[_c('TabPane',{attrs:{"label":_vm.t('survey_creator.common.tab.question_setting'),"name":"EDIT"}},[(_vm.activeTab == 'EDIT')?_c('div',[_c('Row',{staticClass:"survey-operate",attrs:{"type":"flex","justify":"space-between","align":"middle","gutter":48}},[_c('Col',[_c('create-question-dropdown')],1),_vm._v(" "),_c('Col',[_c('edit-options',{staticClass:"edit-option",attrs:{"survey":this.currentSurvey}})],1)],1),_vm._v(" "),_c('Scroll',{staticClass:"question-content",attrs:{"height":_vm.height}},[_c('survey-editor',{attrs:{"options":this.options,"survey":this.currentSurvey}})],1)],1):_vm._e()]),_vm._v(" "),_c('TabPane',{attrs:{"label":_vm.t('survey_creator.common.tab.language'),"name":"TRANSLATE"}},[(_vm.activeTab == 'TRANSLATE')?_c('survey-translator',{attrs:{"options":this.options,"survey":this.currentSurvey}}):_vm._e()],1)],1)],1),_vm._v(" "),_c('question-edit-drawer',{ref:"editDrawer",attrs:{"question":_vm.editingQuestion,"operation-type":_vm.operationType},model:{value:(_vm.questionEditDrawerVisible),callback:function ($$v) {_vm.questionEditDrawerVisible=$$v;},expression:"questionEditDrawerVisible"}}),_vm._v(" "),_c('Card',{attrs:{"shadow":""}},[_c('Row',{attrs:{"gutter":30,"align":"middle","justify":"center","type":"flex"}},[_c('Col',[_c('Button',{attrs:{"loading":_vm.loading,"type":"primary","disabled":_vm.isSaved},on:{"click":_vm.onSave}},[_vm._v(_vm._s(_vm.t("survey_creator.common.save"))+"\n ")])],1)],1)],1)],1)])};
4490
4513
  var __vue_staticRenderFns__$1 = [];
4491
4514
 
4492
4515
  /* style */
@@ -4526,7 +4549,7 @@ var script = Vue.extend({
4526
4549
  components: { Card, Row, Col, Button, Toolbar, SurveyInternalPreviewer },
4527
4550
  provide() {
4528
4551
  return {
4529
- $rootComponent: this.$rootComponent
4552
+ $rootComponent: this
4530
4553
  };
4531
4554
  },
4532
4555
  props: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wg-npm/survey-creator",
3
- "version": "0.3.4143",
3
+ "version": "0.3.4156",
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.4143",
16
- "@wg-npm/survey-service-api": "0.3.4143",
15
+ "@wg-npm/survey-core": "0.3.4156",
16
+ "@wg-npm/survey-service-api": "0.3.4156",
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.3.4143",
42
- "@wg-npm/survey-service-api": "0.3.4143",
41
+ "@wg-npm/survey-core": "0.3.4156",
42
+ "@wg-npm/survey-service-api": "0.3.4156",
43
43
  "acorn": "^7.3.1",
44
44
  "axios": "^0.19.2",
45
45
  "babelrc-rollup": "^3.0.0",
@@ -1,5 +1,14 @@
1
1
  <template>
2
- <div class="survey-creator-wrapper">
2
+ <div>
3
+ <div v-if="showQuestionWhenPageLoad">
4
+ <question-edit-drawer
5
+ :question="editingQuestion"
6
+ ref="editDrawer"
7
+ v-model="questionEditDrawerVisible"
8
+ :operation-type="operationType"
9
+ />
10
+ </div>
11
+ <div class="survey-creator-wrapper" v-else>
3
12
  <Card shadow>
4
13
  <Row align="middle" justify="space-between" type="flex">
5
14
  <Col span="20">
@@ -69,6 +78,7 @@
69
78
  </Col>
70
79
  </Row>
71
80
  </Card>
81
+ </div>
72
82
  </div>
73
83
  </template>
74
84
  <script lang="ts">
@@ -136,6 +146,16 @@
136
146
  options: {
137
147
  type: Object as () => SurveyCreatorOptions,
138
148
  required: true
149
+ },
150
+ showQuestionWhenPageLoad: {
151
+ type: Boolean,
152
+ required: false,
153
+ default: false
154
+ },
155
+ showQuestionType: {
156
+ type: String,
157
+ required: false,
158
+ default: QuestionType.EVALUATION
139
159
  }
140
160
  },
141
161
  data: function () {
@@ -170,6 +190,15 @@
170
190
  this.currentSurvey.questions[0].active = true;
171
191
  }
172
192
  this.primaryLanguage = _.camelCase(this.currentSurvey.options.primaryLanguage);
193
+
194
+ if (this.showQuestionWhenPageLoad) {
195
+ const question = _.findLast(this.currentSurvey?.questions, questions=> { return questions.type === this.showQuestionType})
196
+ if (_.isUndefined(question)) {
197
+ this.createQuestion(this.showQuestionType)
198
+ } else {
199
+ this.showQuestionEditDrawer(<BaseQuestionModel>question)
200
+ }
201
+ }
173
202
  },
174
203
  computed: {
175
204
  isEditMode() {
@@ -292,6 +321,11 @@
292
321
  newQuestion,
293
322
  this.currentSurvey.questions
294
323
  );
324
+
325
+ if (this.showQuestionWhenPageLoad) {
326
+ this.onSave()
327
+ this.onBack()
328
+ }
295
329
  },
296
330
  onQuestionDelete(id) {
297
331
  _.remove(this.currentSurvey.questions, function (
@@ -36,7 +36,7 @@
36
36
  components: {Card, Row, Col, Button, Toolbar, SurveyInternalPreviewer},
37
37
  provide() {
38
38
  return {
39
- $rootComponent: this.$rootComponent
39
+ $rootComponent: this
40
40
  };
41
41
  },
42
42
  props: {