ali 2 年 前
親
コミット
a6db3e194c

+ 14 - 0
src/api/models/SessionTemplate.js

@@ -50,6 +50,20 @@ export default class SessionTemplateAPI extends APIRepository {
     })
   }
 
+  get (id) {
+    return this.sendRequest({
+      apiMethod: 'get',
+      api: this.api,
+      request: this.APIAdresses.byId(id),
+      resolveCallback: (response) => {
+        return new SessionTemplate(response.data)
+      },
+      rejectCallback: (error) => {
+        return error
+      }
+    })
+  }
+
   create (data) {
     return this.sendRequest({
       apiMethod: 'post',

+ 14 - 0
src/api/models/Unit.js

@@ -49,6 +49,20 @@ export default class UnitAPI extends APIRepository {
     })
   }
 
+  get (id) {
+    return this.sendRequest({
+      apiMethod: 'get',
+      api: this.api,
+      request: this.APIAdresses.byId(id),
+      resolveCallback: (response) => {
+        return new Unit(response.data)
+      },
+      rejectCallback: (error) => {
+        return error
+      }
+    })
+  }
+
   create (data) {
     return this.sendRequest({
       apiMethod: 'post',

+ 71 - 18
src/components/Widgets/SessionTemplate/AdminSessionTemplateQuestionList/AdminSessionTemplateQuestionList.vue

@@ -1,11 +1,11 @@
 <template>
   <div class="AdminSessionTemplateQuestionList"
        :style="localOptions.style">
-    <!--    <q-skeleton v-if="mounted"-->
-    <!--                type="text"-->
-    <!--                width="200px" />-->
-    <!--    <breadcrumbs v-else-->
-    <!--                 style="margin-top: 29px; margin-bottom: 19px;" />-->
+    <q-skeleton v-if="!unit.id || !sessionTemplate.id"
+                type="text"
+                width="200px" />
+    <breadcrumbs v-else
+                 style="margin-top: 29px; margin-bottom: 19px;" />
     <div class="flex justify-end q-mb-md">
       <q-btn label="ایجاد سوال جدید"
              color="primary"
@@ -53,22 +53,26 @@
 
 <script>
 import { EntityIndex } from 'quasar-crud'
+import { Unit } from 'src/models/Unit.js'
 import { Question } from 'src/models/Question.js'
 import { mixinWidget } from 'src/mixin/Mixins.js'
 import { APIGateway } from 'src/api/APIGateway.js'
 import DeleteBtn from 'src/components/Control/DeleteBtn.vue'
-// import Breadcrumbs from 'src/components/Widgets/Breadcrumbs/Breadcrumbs.vue'
+import { SessionTemplate } from 'src/models/SessionTemplate.js'
+import Breadcrumbs from 'src/components/Widgets/Breadcrumbs/Breadcrumbs.vue'
 
 export default {
   name: 'AdminSessionTemplateQuestionList',
   components: {
-    EntityIndex,
-    // Breadcrumbs,
-    DeleteBtn
+    DeleteBtn,
+    Breadcrumbs,
+    EntityIndex
   },
   mixins: [mixinWidget],
   data () {
     return {
+      unit: new Unit(),
+      sessionTemplate: new SessionTemplate(),
       api: APIGateway.question.APIAdresses.base,
       tableKeys: {
         data: 'results',
@@ -133,22 +137,71 @@ export default {
   },
   mounted() {
     this.mounted = true
-    // this.updateBreadcrumbs()
+    Promise.all([
+      this.getUnit(),
+      this.getSessionTemplate()
+    ])
+      .then(() => {
+        this.updateBreadcrumbs()
+      })
+      .catch(() => {
+      })
   },
   methods: {
+    getUnit () {
+      return new Promise((resolve, reject) => {
+        this.unit.loading = true
+        APIGateway.unit.get(this.$route.params.unit_id)
+          .then((unit) => {
+            this.unit = new Unit(unit)
+            this.unit.loading = false
+            resolve()
+          })
+          .catch(() => {
+            this.unit.loading = false
+            reject()
+          })
+      })
+    },
+    getSessionTemplate () {
+      return new Promise((resolve, reject) => {
+        this.sessionTemplate.loading = true
+        APIGateway.sessionTemplate.get(this.$route.params.session_template_id)
+          .then((sessionTemplate) => {
+            this.sessionTemplate = new SessionTemplate(sessionTemplate)
+            this.sessionTemplate.loading = false
+            resolve()
+          })
+          .catch(() => {
+            this.sessionTemplate.loading = false
+            reject()
+          })
+      })
+    },
     updateBreadcrumbs () {
       this.$store.commit('AppLayout/updateBreadcrumbs', {
         visible: true,
         loading: false,
         path: [
-          // {
-          //   label: 'لیست ',
-          //   to: { name: this.indexPageRouteName }
-          // },
-          // {
-          //   label: 'this.classroom.title',
-          //   to: { name: this.showPageRouteName, params: { id: 12 } }
-          // }
+          {
+            label: 'درس ها و چارت آموزشی',
+            to: { name: 'Admin.Category.Index' }
+          },
+          {
+            label: this.unit.category_info.title,
+            to: { name: 'Admin.Category.Show', params: { id: this.unit.category_info.id } }
+          },
+          {
+            label: this.unit.title,
+            to: { name: 'Admin.Unit.Show', params: { id: this.unit.id } }
+          },
+          {
+            label: this.sessionTemplate.title,
+            to: { name: 'Admin.SessionTemplate.Show', params: { id: this.sessionTemplate.id } }
+          },
+          {
+            label: 'لیست سوالات'
+          }
         ]
       })
     },

+ 2 - 2
src/components/Widgets/Test/AdminTestShow/AdminTestShow.vue

@@ -34,15 +34,15 @@
 <script>
 import { shallowRef } from 'vue'
 import { EntityEdit } from 'quasar-crud'
+import { Test } from 'src/models/Test.js'
 import { mixinWidget } from 'src/mixin/Mixins.js'
 import { APIGateway } from 'src/api/APIGateway.js'
 import { Classroom } from 'src/models/Classroom.js'
 import { FormBuilderAssist } from 'quasar-form-builder'
 import BtnControl from 'src/components/Control/btn.vue'
+import { UnitCategory } from 'src/models/UnitCategory.js'
 import Breadcrumbs from 'src/components/Widgets/Breadcrumbs/Breadcrumbs.vue'
 import UsersOfTestSelector from 'src/components/FormBuilderCustumComponents/UsersOfTestSelector/UsersOfTestSelector.vue'
-import { Test } from 'src/models/Test'
-import { UnitCategory } from 'src/models/UnitCategory'
 
 const BtnControlComp = shallowRef(BtnControl)
 const UsersOfTestSelectorComp = shallowRef(UsersOfTestSelector)