|
|
@@ -1,5 +1,7 @@
|
|
|
<template>
|
|
|
<div class="AdminClassroomCreate">
|
|
|
+ <q-linear-progress v-if="unitsLoading"
|
|
|
+ indeterminate />
|
|
|
<entity-create v-if="mounted"
|
|
|
ref="classroomEntityCreate"
|
|
|
:key="classroomEntityCreateKey"
|
|
|
@@ -28,16 +30,18 @@
|
|
|
<script>
|
|
|
import { EntityCreate } from 'quasar-crud'
|
|
|
import Enums from 'src/assets/Enums/Enums.js'
|
|
|
-import { APIGateway } from 'src/api/APIGateway'
|
|
|
+import { APIGateway } from 'src/api/APIGateway.js'
|
|
|
+import { FormBuilderAssist } from 'quasar-form-builder'
|
|
|
|
|
|
export default {
|
|
|
- name: 'Admin.Classroom.Create',
|
|
|
+ name: 'Admin.Classroom.DiscussionCircles.Create',
|
|
|
components: {
|
|
|
EntityCreate
|
|
|
},
|
|
|
data () {
|
|
|
return {
|
|
|
mounted: false,
|
|
|
+ unitsLoading: false,
|
|
|
classroomEntityCreateKey: Date.now(),
|
|
|
newUnitLoading: false,
|
|
|
newUnitName: null,
|
|
|
@@ -47,22 +51,22 @@ export default {
|
|
|
entityParamKey: 'id',
|
|
|
showRouteName: 'Admin.Classroom.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' },
|
|
|
+ { type: 'separator', name: 'space', label: 'مشخصات حلقه', className: 'custom-separator', col: 'col-12' },
|
|
|
+ { type: 'file', name: 'thumbnail', responseKey: 'thumbnail', label: 'آپلود عکس حلقه', col: 'col-md-3 col-12' },
|
|
|
{ type: 'separator', name: 'space', size: '0', col: 'col-md-12' },
|
|
|
{ type: 'select', name: 'category', responseKey: 'unit_info.category', options: [], value: null, placeholder: ' ', label: 'دسته بندی', col: 'col-md-3 col-12' },
|
|
|
{ type: 'select', name: 'unit', responseKey: 'unit', options: [], value: null, placeholder: ' ', label: 'درس', col: 'col-md-3 col-12' },
|
|
|
{ type: 'select', name: 'holding_type', responseKey: 'holding_type', options: Enums.classroomHoldingTypes, value: null, placeholder: ' ', label: 'نوع برگزاری', col: 'col-md-3 col-12' },
|
|
|
{ type: 'input', name: 'price', responseKey: 'price', placeholder: ' ', label: 'هزینه برگزاری', col: 'col-md-3 col-12' },
|
|
|
- { type: 'input', name: 'live_streaming_url', responseKey: 'live_streaming_url', placeholder: ' ', label: 'لینک مکان مجازی دوره', col: 'col-12' },
|
|
|
- { type: 'inputEditor', name: 'classroom_address', responseKey: 'classroom_address', placeholder: ' ', label: 'آدرس مکان فیزیکی دوره', col: 'col-12' },
|
|
|
+ { type: 'input', name: 'live_streaming_url', responseKey: 'live_streaming_url', placeholder: ' ', label: 'لینک مکان مجازی حلقه', col: 'col-12' },
|
|
|
+ { type: 'inputEditor', name: 'classroom_address', responseKey: 'classroom_address', placeholder: ' ', label: 'آدرس مکان فیزیکی حلقه', col: 'col-12' },
|
|
|
{
|
|
|
type: 'select',
|
|
|
name: 'holding_year',
|
|
|
responseKey: 'holding_year',
|
|
|
options: [1402, 1403, 1404, 1405, 1406, 1407, 1408, 1409, 1410],
|
|
|
value: null,
|
|
|
- label: 'انتخاب سال دوره',
|
|
|
+ label: 'انتخاب سال حلقه',
|
|
|
placeholder: ' ',
|
|
|
col: 'col-md-3'
|
|
|
},
|
|
|
@@ -85,12 +89,12 @@ export default {
|
|
|
'اسفند'
|
|
|
],
|
|
|
value: null,
|
|
|
- label: 'انتخاب ماه دوره',
|
|
|
+ label: 'انتخاب ماه حلقه',
|
|
|
placeholder: ' ',
|
|
|
col: 'col-md-3'
|
|
|
},
|
|
|
{ type: 'input', name: 'sessions_frequency', responseKey: 'sessions_frequency', placeholder: ' ', label: 'دوره تناوب', col: 'col-12' },
|
|
|
- { type: 'select', name: 'professor', responseKey: 'professor', options: [], value: null, placeholder: ' ', label: 'استاد دوره', col: 'col-md-3 col-12' },
|
|
|
+ { type: 'select', name: 'professor', responseKey: 'professor', options: [], value: null, placeholder: ' ', label: 'استاد حلقه', col: 'col-md-3 col-12' },
|
|
|
|
|
|
{ type: 'separator', name: 'space', label: 'مشخصات اندیشه جو', className: 'custom-separator', col: 'col-12' },
|
|
|
{ type: 'select', name: 'audience_status_wwwww', responseKey: 'audience_status_wwwww', options: [], placeholder: ' ', label: 'وضعیت(؟)', col: 'col-md-3 col-12' },
|
|
|
@@ -98,7 +102,7 @@ export default {
|
|
|
{ type: 'select', name: 'audience_gender_type', responseKey: 'audience_gender_type', options: Enums.genders, placeholder: ' ', label: 'جنسیت', col: 'col-md-3 col-12' },
|
|
|
{ type: 'select', name: 'audience_bashgah_wwwww', responseKey: 'audience_bashgah_wwwww', options: [], placeholder: ' ', label: 'باشگاه(؟)', col: 'col-md-3 col-12' },
|
|
|
|
|
|
- { type: 'separator', name: 'space', label: 'تنظیمات دوره', className: 'custom-separator', col: 'col-12' },
|
|
|
+ { type: 'separator', name: 'space', label: 'تنظیمات حلقه', className: 'custom-separator', col: 'col-12' },
|
|
|
{ type: 'input', name: 'capacity', responseKey: 'capacity', placeholder: ' ', label: 'ظرفیت گروه درسی', col: 'col-md-3 col-12' },
|
|
|
{ type: 'input', name: 'allowed_absence_count', responseKey: 'allowed_absence_count', placeholder: ' ', label: 'تعداد مجاز غیبت', col: 'col-md-3 col-12' },
|
|
|
{ type: 'input', name: 'effective_absence_coefficient', responseKey: 'effective_absence_coefficient', placeholder: ' ', label: 'ضریب نمره حضور و غیاب', col: 'col-md-3 col-12' },
|
|
|
@@ -127,7 +131,7 @@ export default {
|
|
|
{ type: 'dateTime', name: 'publish_time', responseKey: 'publish_time', placeholder: ' ', label: 'تاریخ انتشار', col: 'col-md-6 col-12' },
|
|
|
|
|
|
{ type: 'separator', name: 'space', label: 'قوانین', className: 'custom-separator', col: 'col-12' },
|
|
|
- { type: 'inputEditor', name: 'rules', responseKey: 'rules', label: 'قوانین دوره آموزشی', col: 'col-12' },
|
|
|
+ { type: 'inputEditor', name: 'rules', responseKey: 'rules', label: 'قوانین حلقه آموزشی', col: 'col-12' },
|
|
|
// -----------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
{ type: 'separator', name: 'space', label: 'موارد زیر در طرح نبودند', className: 'custom-separator', col: 'col-12' },
|
|
|
@@ -140,44 +144,47 @@ export default {
|
|
|
},
|
|
|
computed: {
|
|
|
selectedCategoryId () {
|
|
|
- return this.getInputValue('category')
|
|
|
+ return FormBuilderAssist.getInputsByName(this.inputs, 'category')?.value
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
selectedCategoryId () {
|
|
|
- this.setInputValue('unit', null)
|
|
|
+ FormBuilderAssist.setAttributeByName(this.inputs, 'unit', 'value', null)
|
|
|
+ FormBuilderAssist.setAttributeByName(this.inputs, 'unit', 'options', [])
|
|
|
this.getUnits(this.selectedCategoryId)
|
|
|
}
|
|
|
},
|
|
|
mounted () {
|
|
|
- this.mounted = true
|
|
|
this.preLoadData()
|
|
|
+ .then(() => {
|
|
|
+ this.mounted = true
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ })
|
|
|
},
|
|
|
methods: {
|
|
|
setInputAttr (name, attr, value) {
|
|
|
this.$refs.classroomEntityCreate.setInputAttributeByName(name, attr, value)
|
|
|
},
|
|
|
preLoadData () {
|
|
|
- this.beforeLoadInputData()
|
|
|
- },
|
|
|
- beforeLoadInputData () {
|
|
|
- const promise1 = this.getProfessors()
|
|
|
- const promise2 = this.getCategories()
|
|
|
- const promise3 = this.getUnits()
|
|
|
- this.$nextTick(() => {
|
|
|
- Promise.all([promise1, promise2, promise3])
|
|
|
- .then(() => {
|
|
|
- // this.setInputAttr('category', 'value', responseData.unit_info.category)
|
|
|
- // this.setInputAttr('unit', 'value', responseData.unit)
|
|
|
- this.classroomEntityCreateKey = Date.now()
|
|
|
- })
|
|
|
- .catch(() => {})
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ const promise1 = this.getProfessors()
|
|
|
+ const promise2 = this.getCategories()
|
|
|
+ this.$nextTick(() => {
|
|
|
+ Promise.all([promise1, promise2])
|
|
|
+ .then(() => {
|
|
|
+ resolve()
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ reject()
|
|
|
+ })
|
|
|
+ })
|
|
|
})
|
|
|
},
|
|
|
getProfessors () {
|
|
|
return APIGateway.user.index({ per_page: 9999, role: 'professor' })
|
|
|
.then((users) => {
|
|
|
- this.setInputAttr('professor', 'options', users.list.list.map(item => {
|
|
|
+ FormBuilderAssist.setAttributeByName(this.inputs, 'professor', 'options', users.list.list.map(item => {
|
|
|
return {
|
|
|
value: item.id,
|
|
|
label: this.getUserFullname(item)
|
|
|
@@ -189,7 +196,7 @@ export default {
|
|
|
getCategories () {
|
|
|
return APIGateway.unitCategory.index({ per_page: 9999, type: 'DISCUSSION_CIRCLE' })
|
|
|
.then((categories) => {
|
|
|
- this.setInputAttr('category', 'options', categories.list.list.map(item => {
|
|
|
+ FormBuilderAssist.setAttributeByName(this.inputs, 'category', 'options', categories.list.list.map(item => {
|
|
|
return {
|
|
|
value: item.id,
|
|
|
label: item.title
|
|
|
@@ -199,46 +206,26 @@ export default {
|
|
|
.catch(() => {})
|
|
|
},
|
|
|
getUnits (selectedcategoryId = null) {
|
|
|
- return APIGateway.unit.index({ per_page: 9999, category: selectedcategoryId })
|
|
|
+ this.unitsLoading = true
|
|
|
+ APIGateway.unit.index({ per_page: 9999, category: selectedcategoryId })
|
|
|
.then((units) => {
|
|
|
- this.setInputAttr('unit', 'options', units.list.list.map(item => {
|
|
|
+ FormBuilderAssist.setAttributeByName(this.inputs, 'unit', 'options', units.list.list.map(item => {
|
|
|
return {
|
|
|
value: item.id,
|
|
|
label: item.title
|
|
|
}
|
|
|
}))
|
|
|
+ this.unitsLoading = false
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.unitsLoading = false
|
|
|
})
|
|
|
- .catch(() => {})
|
|
|
},
|
|
|
-
|
|
|
getUserFullname (user) {
|
|
|
return user.firstname + ' ' + user.lastname
|
|
|
},
|
|
|
- getSelectOptions (result, value, label) {
|
|
|
- return result.map(item => {
|
|
|
- return {
|
|
|
- value: item[value],
|
|
|
- label: item[label]
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- setInputValue (name, value) {
|
|
|
- const inputIndex = this.inputs.findIndex(input => input.name === name)
|
|
|
- this.inputs[inputIndex].value = value
|
|
|
- },
|
|
|
- loadSelectOptions (name, value, setNewInputData) {
|
|
|
- const inputIndex = this.inputs.findIndex(input => input.name === name)
|
|
|
- this.inputs[inputIndex].options = value
|
|
|
- if (typeof setNewInputData === 'function') {
|
|
|
- setNewInputData(this.inputs)
|
|
|
- }
|
|
|
- },
|
|
|
createClassroom () {
|
|
|
this.$refs.classroomEntityCreate.createEntity()
|
|
|
- },
|
|
|
- getInputValue (name) {
|
|
|
- const inputIndex = this.inputs.findIndex(input => input.name === name)
|
|
|
- return this.inputs[inputIndex].value
|
|
|
}
|
|
|
}
|
|
|
}
|