ali hace 3 años
padre
commit
f972a84743

+ 3 - 3
src/api/models/Classroom.js

@@ -1,8 +1,8 @@
 import { appApi } from 'src/boot/axios.js'
 import { Invoice } from 'src/models/Invoice.js'
 import APIRepository from '../classes/APIRepository.js'
+import { Registration } from 'src/models/Registration.js'
 import { Classroom, ClassroomList } from 'src/models/Classroom.js'
-import { EventRegistration } from 'src/models/EventRegistration.js'
 
 export default class ClassroomAPI extends APIRepository {
   constructor() {
@@ -87,8 +87,8 @@ export default class ClassroomAPI extends APIRepository {
           data.type = 'Invoice'
           data.model = new Invoice(response.data)
         } else if (response.data.status === 'REGISTERED') {
-          data.type = 'EventRegistration'
-          data.model = new EventRegistration(response.data)
+          data.type = 'Registration'
+          data.model = new Registration(response.data)
         }
 
         return data

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

@@ -22,6 +22,7 @@ export default class UnitAPI extends APIRepository {
       request: this.APIAdresses.base,
       data: this.getNormalizedSendData({
         category: null, // Number
+        category__type: null, // String
         per_page: 10, // Number
         page: 1 // Number
       }, data),

+ 1 - 1
src/components/Widgets/Classroom/AdminClassroomShow/AdminClassroomShow.vue

@@ -155,7 +155,7 @@ export default {
       if (this.localOptions.classroomType === 'EVENT') {
         return 'لیست برنامه ها'
       }
-      return 'Admin.Classroom.Create'
+      return 'لیست جلسات'
     },
     indexPageRouteName () {
       if (this.localOptions.classroomType === 'TRAINING') {

+ 33 - 10
src/components/Widgets/Classroom/AllClassrooms/AllClassrooms.vue

@@ -3,7 +3,7 @@
     <div class="all-classroom-title">
       <div>
         <q-banner class="banner">
-          دوره های آموزشی
+          {{ classroomTypeTitle }}
         </q-banner>
       </div>
       <div class="all-classroom-filter">
@@ -68,7 +68,10 @@
       <div v-for="classroom in classrooms.list"
            :key="classroom.id"
            class="classroom-col col-md-4">
-        <classroom-item :classroom="classroom" />
+        <classroom-item v-if="localOptions.classroomType === 'TRAINING'"
+                        :classroom="classroom" />
+        <event-item v-else-if="localOptions.classroomType === 'EVENT'"
+                    :event="classroom" />
       </div>
     </div>
     <div v-else-if="!classrooms.loading && classrooms.list.length === 0">
@@ -84,6 +87,7 @@
                :units="units"
                :professors="professors"
                :categories="categories"
+               :classroom-type="localOptions.classroomType"
                @doFilter="doFilter"
                @cancelFilter="cancelFilter"
                @onChangeCategory="onChangeCategory" />
@@ -94,17 +98,18 @@
 <script>
 import { UnitList } from 'src/models/Unit.js'
 import Filters from './components/Filters.vue'
-import { mixinAuth } from 'src/mixin/Mixins.js'
 import { APIGateway } from 'src/api/APIGateway.js'
-import { Classroom, ClassroomList } from 'src/models/Classroom.js'
+import { mixinAuth, mixinWidget } from 'src/mixin/Mixins.js'
 import ClassroomItem from 'src/components/ClassroomItem.vue'
 import { UnitCategoryList } from 'src/models/UnitCategory.js'
+import EventItem from 'src/components/EventItem.vue'
+import { Classroom, ClassroomList } from 'src/models/Classroom.js'
 import { ClassroomRegistrationList } from 'src/models/ClassroomRegistration.js'
 
 export default {
   name: 'AllClassrooms',
-  components: { ClassroomItem, Filters },
-  mixins: [mixinAuth],
+  components: { ClassroomItem, EventItem, Filters },
+  mixins: [mixinAuth, mixinWidget],
   data: () => ({
     loading: false,
     units: new UnitList(),
@@ -121,9 +126,21 @@ export default {
       professor: null
     },
     filterDialog: false,
-    classrooms: new ClassroomList()
+    classrooms: new ClassroomList(),
+    defaultOptions: {
+      classroomType: 'TRAINING'
+    }
   }),
   computed: {
+    classroomTypeTitle () {
+      if (this.localOptions.classroomType === 'TRAINING') {
+        return 'دوره های آموزشی'
+      }
+      if (this.localOptions.classroomType === 'EVENT') {
+        return 'رویدادها'
+      }
+      return 'دوره های آموزشی'
+    },
     classroomStatuses () {
       return (new Classroom()).statusEnums
     },
@@ -206,6 +223,7 @@ export default {
     getClassrooms () {
       this.classrooms.loading = true
       this.filter.per_page = 9999
+      this.filter.unit__category__type = this.localOptions.classroomType
       APIGateway.classroom.index(this.filter)
         .then(classroomList => {
           this.classrooms = new ClassroomList(classroomList.list)
@@ -217,7 +235,9 @@ export default {
     },
     getCategories () {
       this.categories.loading = true
-      APIGateway.unitCategory.index()
+      APIGateway.unitCategory.index({
+        type: this.localOptions.classroomType
+      })
         .then(unitCategoryList => {
           this.categories.loading = false
           this.categories = new UnitCategoryList(unitCategoryList.list)
@@ -240,9 +260,12 @@ export default {
     getUserFullname (user) {
       return user.firstname + ' ' + user.lastname
     },
-    getUnits (categoryId) {
+    getUnits (categoryId = null) {
       this.units.loading = true
-      APIGateway.unit.index({ category: categoryId })
+      APIGateway.unit.index({
+        category: categoryId,
+        category__type: this.localOptions.classroomType
+      })
         .then(unitList => {
           this.units.loading = false
           this.units = new UnitList(unitList.list)

+ 8 - 144
src/components/Widgets/Classroom/AllClassrooms/OptionPanel.vue

@@ -1,163 +1,27 @@
 <template>
   <option-panel-tabs v-model:options="localOptions">
     <template #main-tab>
-      <div class="option-panel-container">
-        <div class="row q-col-gutter-md">
-          <div class="input-container col-12 q-mt-md">
-
-            <div class="outsideLabel">آدرس فایل عکس</div>
-            <q-input v-model="localOptions.imageSource"
-                     label="image" />
-          </div>
-          <!--          <div class="input-container q-py-md">-->
-          <!--            <div class="outsideLabel">height</div>-->
-          <!--            <q-input v-model="localOptions.height"-->
-          <!--                     label="image" />-->
-          <!--          </div>-->
-          <div class="input-container col-4">
-            <div class="outsideLabel">size</div>
-            <q-select v-model="size"
-                      :options="sizeOptions"
-                      label="page size" />
-          </div>
-          <div class="input-container col-4">
-
-            <div class="outsideLabel">عرض در سایز {{size}}</div>
-            <q-input v-model="localOptions[size].width"
-                     label="width" />
-          </div>
-          <div class="input-container col-4">
-
-            <div class="outsideLabel">ارتفاع در سایز {{size}}</div>
-            <q-input v-model="localOptions[size].height"
-                     label="height" />
-          </div>
-          <div class="input-container col-12">
-            <div class="outsideLabel">لینک عکس در سایز {{size}}</div>
-            <q-input v-model="localOptions[size].src"
-                     label="image link" />
-          </div>
-          <div class="action col-md-12">
-            <div class="cehckBox">
-              <q-checkbox v-model="localOptions.useAEEEvent"
-                          label="استفاده از ایونت GTM"
-                          right-label />
-            </div>
-            <div v-if="localOptions.useAEEEvent"
-                 class="action-container q-gutter-lg-md">
-              <div>فیلد های مورد نظر ایونت GTM :</div>
-              <div class="col-9">
-                <div class="outsideLabel">id</div>
-                <q-input v-model="localOptions.AEEEventBody.id"
-                         label="id" />
-              </div>
-              <div class="col-6">
-                <div class="outsideLabel">name</div>
-                <q-input v-model="localOptions.AEEEventBody.name"
-                         label="name" />
-              </div>
-              <div class="col-6">
-                <div class="outsideLabel">creative</div>
-                <q-input v-model="localOptions.AEEEventBody.creative"
-                         label="creative" />
-              </div>
-              <div class="col-6">
-                <div class="outsideLabel">position</div>
-                <q-input v-model="localOptions.AEEEventBody.position"
-                         label="position" />
-              </div>
-            </div>
-            <div class="cehckBox">
-              <q-checkbox v-model="localOptions.hasAction"
-                          label="hasAction"
-                          right-label />
-            </div>
-            <div v-if="localOptions.hasAction"
-                 class="action-container">
-              <div>
-                <q-select v-model="localOptions.action.name"
-                          :options="actionTypes" />
-              </div>
-              <div v-if="localOptions.action.name === 'link'">
-                <q-input v-model="localOptions.action.route"
-                         label="route" />
-              </div>
-              <div v-if="localOptions.action.name === 'event'">
-                <q-input v-model="localOptions.action.eventName"
-                         label="event name" />
-                <q-input v-model="localOptions.action.eventArgs"
-                         label="event args" />
-              </div>
-              <div v-if="localOptions.action.name === 'scroll'">
-                <q-input v-model="localOptions.action.scrollTo"
-                         label="scrollTo class" />
-              </div>
-            </div>
-          </div>
-        </div>
-      </div>
+      <q-option-group v-model="localOptions.classroomType"
+                      :options="classroomTypeOptions" />
     </template>
   </option-panel-tabs>
 </template>
 
 <script>
 import { defineComponent } from 'vue'
+import { UnitCategory } from 'src/models/UnitCategory.js'
 import { mixinOptionPanel } from 'quasar-ui-q-page-builder'
 import OptionPanelTabs from 'quasar-ui-q-page-builder/src/components/OptionPanelComponents/OptionPanelTabs.vue'
 
 export default defineComponent({
   name: 'OptionPanel',
-  components: { OptionPanelTabs },
+  components: {
+    OptionPanelTabs
+  },
   mixins: [mixinOptionPanel],
-  data() {
+  data () {
     return {
-      size: 'xs',
-      sizeOptions: ['xs', 'sm', 'md', 'lg', 'xl'],
-      actionTypes: ['event', 'scroll', 'link'],
-      defaultOptions: {
-        imageSource: null,
-        ratio: null,
-        hasAction: false,
-        useAEEEvent: false,
-        AEEEventBody: {
-          id: '-',
-          name: '-',
-          creative: null,
-          position: null
-        },
-        action: {
-          name: null,
-          route: null,
-          scrollTo: null,
-          eventName: null,
-          eventArgs: null
-        },
-        xs: {
-          height: null,
-          width: null,
-          src: null
-        },
-        sm: {
-          height: null,
-          width: null,
-          src: null
-        },
-        md: {
-          height: null,
-          width: null,
-          src: null
-        },
-        lg: {
-          height: null,
-          width: null,
-          src: null
-        },
-        xl: {
-          height: null,
-          width: null,
-          src: null
-        }
-      }
+      classroomTypeOptions: (new UnitCategory()).typeEnums
     }
   }
 })

+ 16 - 2
src/components/Widgets/Classroom/AllClassrooms/components/Filters.vue

@@ -27,7 +27,8 @@
     </q-card-section>
     <q-card-section class="filter-card-filter-section filter-card-section">
       <div class="row q-col-gutter-md">
-        <div class="col-md-3">
+        <div v-if="classroomType === 'TRAINING'"
+             class="col-md-3">
           <div>گروه آموزشی</div>
           <select-control v-model:value="localFilters.unit__category"
                           :options="categories.list"
@@ -38,7 +39,7 @@
                           @update:model-value="onChangeCategory" />
         </div>
         <div class="col-md-3">
-          <div>درس</div>
+          <div>{{ unitTitle }}</div>
           <select-control v-model:value="localFilters.unit"
                           :options="units.list"
                           :disable="units.loading"
@@ -119,6 +120,10 @@ export default {
     units: {
       type: UnitList,
       default: new UnitList()
+    },
+    classroomType: {
+      type: String,
+      default: 'TRAINING'
     }
   },
   emits: ['doFilter', 'cancelFilter', 'onChangeCategory', 'update:filters'],
@@ -128,6 +133,15 @@ export default {
     }
   },
   computed: {
+    unitTitle () {
+      if (this.classroomType === 'TRAINING') {
+        return 'درس'
+      }
+      if (this.classroomType === 'EVENT') {
+        return 'برنامه'
+      }
+      return 'درس'
+    },
     localFilters: {
       get () {
         return this.filters

+ 13 - 17
src/components/Widgets/Other/Shop/ShopCompleteInfo/ShopCompleteInfo.vue

@@ -240,23 +240,15 @@ export default {
         .catch(() => {})
     },
     createInvoiceForClassroomOrRegisterEvent () {
-      if (this.$route.query.source === 'event') {
-        this.registerEvent()
-          .then((data) => {
-            if (data === 'Invoice') {
-              this.$router.push({ name: 'UserPanel.ShopPaymentFromWallet', query: this.$route.query })
-            }
-          })
-          .catch(() => {})
-      } else {
-        this.createInvoice()
-          .then(() => {
+      this.register()
+        .then((data) => {
+          if (data === 'Invoice') {
             this.$router.push({ name: 'UserPanel.ShopPaymentFromWallet', query: this.$route.query })
-          })
-          .catch(() => {})
-      }
+          }
+        })
+        .catch(() => {})
     },
-    registerEvent () {
+    register () {
       return new Promise((resolve, reject) => {
         this.invoice.loading = true
         APIGateway.classroom.register(this.classroom.id)
@@ -270,13 +262,17 @@ export default {
                 type: 'positive'
               })
               resolve('Invoice')
-            } else if (data.type === 'EventRegistration') {
+            } else if (data.type === 'Registration') {
               this.$q.notify({
                 message: 'ثبت نام شما با موفقیت انجام شد.',
                 type: 'positive'
               })
               const eventRegistrationId = data.model.id
-              this.$router.push({ name: 'UserPanel.Profile.EventInfo', params: { id: eventRegistrationId } })
+              if (this.$route.query.source === 'event') {
+                this.$router.push({ name: 'UserPanel.Profile.EventInfo', params: { id: eventRegistrationId } })
+              } else {
+                this.$router.push({ name: 'UserPanel.Profile.ClassroomInfo', params: { id: eventRegistrationId } })
+              }
             }
           })
           .catch(() => {

+ 9 - 2
src/components/Widgets/Registration/RegistrationList/OptionPanel.vue

@@ -1,13 +1,15 @@
 <template>
   <option-panel-tabs v-model:options="localOptions">
     <template #main-tab>
-      ...
+      <q-option-group v-model="localOptions.classroomType"
+                      :options="classroomTypeOptions" />
     </template>
   </option-panel-tabs>
 </template>
 
 <script>
 import { defineComponent } from 'vue'
+import { UnitCategory } from 'src/models/UnitCategory.js'
 import { mixinOptionPanel } from 'quasar-ui-q-page-builder'
 import OptionPanelTabs from 'quasar-ui-q-page-builder/src/components/OptionPanelComponents/OptionPanelTabs.vue'
 
@@ -16,6 +18,11 @@ export default defineComponent({
   components: {
     OptionPanelTabs
   },
-  mixins: [mixinOptionPanel]
+  mixins: [mixinOptionPanel],
+  data () {
+    return {
+      classroomTypeOptions: (new UnitCategory()).typeEnums
+    }
+  }
 })
 </script>

+ 2 - 13
src/pages/Public/Events.vue

@@ -6,20 +6,9 @@
 </template>
 
 <script>
-// import { mixinSEO, mixinPageOptions, mixinPrefetchServerData } from 'src/mixin/Mixins.js'
+import { mixinSEO, mixinPageOptions, mixinPrefetchServerData } from 'src/mixin/Mixins.js'
 export default {
   name: 'Public.AllEvents',
-  // mixins: [mixinPrefetchServerData, mixinPageOptions, mixinSEO],
-  data () {
-    return {
-      pageConfig: {},
-      pageBuilderEditable: false,
-      pageBuilderLoading: false,
-      currenSections: [{ data: { rows: [{ cols: [{ widgets: [{ name: 'AllEvents', options: { imageSource: null, ratio: null, hasAction: false, useAEEEvent: false, AEEEventBody: { id: '-', name: '-', creative: null, position: null }, action: { name: null, route: null, scrollTo: null, eventName: null, eventArgs: null }, xs: { height: null, width: null, src: null }, sm: { height: null, width: null, src: null }, md: { height: null, width: null, src: null }, lg: { height: null, width: null, src: null }, xl: { height: null, width: null, src: null }, style: { marginBottom: '32px' } } }, { name: 'RegistrationList', options: { style: { marginBottom: '32px' } } }] }], options: { boxed: true } }] } }]
-    }
-  }
-  // mounted() {
-  //   this.currenSections = this.sections
-  // }
+  mixins: [mixinPrefetchServerData, mixinPageOptions, mixinSEO]
 }
 </script>