Explorar el Código

see also #248

ali hace 2 años
padre
commit
7f90beace8

+ 6 - 7
src/components/FormBuilderCustumComponents/QuestionsSelector/QuestionsSelector.vue

@@ -25,8 +25,7 @@
       </div>
     </div>
     <div class="content-list q-mt-lg">
-      <entity-index v-if="selectedSessionId"
-                    ref="entityIndexQuestions"
+      <entity-index ref="entityIndexQuestions"
                     v-model:value="inputs"
                     :title="'لیست سوالات ' + selectedSession?.title"
                     :api="api"
@@ -282,10 +281,10 @@ export default {
       this.localValue = this.selectedQuestions
     },
     filterQuestionList () {
-      if (!this.selectedSessionId) {
-        return
+      if (this.selectedSessionId) {
+        FormBuilderAssist.setAttributeByName(this.inputs, 'session_template_questions__session_template__unit', 'value', this.selectedSessionId)
       }
-      FormBuilderAssist.setAttributeByName(this.inputs, 'session_template_questions__session_template', 'value', this.selectedSessionId)
+
       this.$refs.entityIndexQuestions.search()
     },
     getSessions () {
@@ -294,9 +293,9 @@ export default {
         .then((data) => {
           this.sessions = new SessionTemplateList(data.list)
           if (this.sessions.list.length > 0) {
-            this.selectedSession = this.sessions.list[0]
-            this.filterQuestionList()
+            // this.selectedSession = this.sessions.list[0]
           }
+          this.filterQuestionList()
           this.sessions.loading = false
         })
         .catch(() => {

+ 3 - 2
src/components/Widgets/TestSet/AdminTestSetCreate/AdminTestSetCreate.vue

@@ -42,6 +42,7 @@ export default {
   components: { EntityCreate },
   mixins: [mixinWidget],
   data () {
+    const unitId = this.$route.params.unit_id
     return {
       mounted: false,
       entityLoading: false,
@@ -52,8 +53,8 @@ export default {
       inputs: [
         { type: 'input', name: 'title', responseKey: 'title', label: 'عنوان آزمون', placeholder: ' ', col: 'col-md-6 col-12' },
         { type: 'inputEditor', name: 'description', responseKey: 'description', label: 'توضیحات آزمون', col: 'col-md-12 col-12' },
-        { type: 'hidden', name: 'unit', responseKey: 'unit', value: this.$route.params.unit_id },
-        { type: QuestionsSelectorComp, name: 'test_set_questions', responseKey: 'test_set_questions', unitId: this.$route.params.unit_id, col: 'col-md-12 col-12' },
+        { type: 'hidden', name: 'unit', responseKey: 'unit', value: unitId },
+        { type: QuestionsSelectorComp, name: 'test_set_questions', responseKey: 'test_set_questions', unitId, col: 'col-md-12 col-12' },
         { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'تایید نهایی', placeholder: ' ', atClick: () => {}, col: 'col-12 flex justify-end' }
       ]
     }