Explorar o código

update discussion-circles-classrooms categories and unit select

ali %!s(int64=3) %!d(string=hai) anos
pai
achega
04f01504d8

+ 5 - 1
src/pages/Admin/DiscussionCirclesClassroom/create.vue

@@ -49,7 +49,7 @@ export default {
       api: APIGateway.classroom.APIAdresses.base,
       entityIdKey: 'id',
       entityParamKey: 'id',
-      showRouteName: 'Admin.Classroom.Show',
+      showRouteName: 'Admin.Classroom.DiscussionCircles.Show',
       inputs: [
         { type: 'separator', name: 'space', label: 'مشخصات حلقه', className: 'custom-separator', col: 'col-12' },
         { type: 'file', name: 'thumbnail', responseKey: 'thumbnail', label: 'آپلود عکس حلقه', col: 'col-md-3 col-12' },
@@ -206,6 +206,10 @@ export default {
         .catch(() => {})
     },
     getUnits (selectedcategoryId = null) {
+      if (!selectedcategoryId) {
+        FormBuilderAssist.setAttributeByName(this.inputs, 'unit', 'options', [])
+        return
+      }
       this.unitsLoading = true
       APIGateway.unit.index({ per_page: 9999, category: selectedcategoryId })
         .then((units) => {

+ 14 - 3
src/pages/Admin/DiscussionCirclesClassroom/show.vue

@@ -27,6 +27,8 @@
                   animated>
       <q-tab-panel name="classroomInfo"
                    class="q-pa-none">
+        <q-linear-progress v-if="unitsLoading"
+                           indeterminate />
         <entity-edit v-if="mounted"
                      ref="classroomEntityEdit"
                      :key="classroomEntityEditKey"
@@ -163,6 +165,7 @@ export default {
   data () {
     return {
       mounted: false,
+      unitsLoading: false,
       classroomEntityEditKey: Date.now(),
       tab: 'classroomInfo',
       api: null,
@@ -469,7 +472,7 @@ export default {
       return new Promise((resolve, reject) => {
         const promise1 = this.getProfessors()
         const promise2 = this.getCategories()
-        const promise3 = this.getUnits(responseData.unit_info.category)
+        const promise3 = this.getUnits(responseData.unit_info.category_info.id)
         this.$nextTick(() => {
           Promise.all([promise1, promise2, promise3])
             .then(() => {
@@ -497,7 +500,7 @@ export default {
         .catch(() => {})
     },
     getCategories () {
-      return APIGateway.unitCategory.index({ per_page: 9999 })
+      return APIGateway.unitCategory.index({ per_page: 9999, type: 'DISCUSSION_CIRCLE' })
         .then((categories) => {
           this.setInputAttr('category', 'options', categories.list.list.map(item => {
             return {
@@ -509,6 +512,11 @@ export default {
         .catch(() => {})
     },
     getUnits (selectedcategoryId) {
+      if (!selectedcategoryId) {
+        this.setInputAttr('unit', 'options', [])
+        return
+      }
+      this.unitsLoading = true
       return APIGateway.unit.index({ per_page: 9999, category: selectedcategoryId })
         .then((units) => {
           this.setInputAttr('unit', 'options', units.list.list.map(item => {
@@ -517,8 +525,11 @@ export default {
               label: item.title
             }
           }))
+          this.unitsLoading = false
+        })
+        .catch(() => {
+          this.unitsLoading = false
         })
-        .catch(() => {})
     },
     getUserFullname (user) {
       return user.firstname + ' ' + user.lastname