|
@@ -42,9 +42,15 @@
|
|
<div class="field">
|
|
<div class="field">
|
|
<label class="label">Category</label>
|
|
<label class="label">Category</label>
|
|
<div class="select is-medium">
|
|
<div class="select is-medium">
|
|
- <select>
|
|
|
|
- <option value="default">Select Category</option>
|
|
|
|
- <!-- <option> </option> -->
|
|
|
|
|
|
+ <select
|
|
|
|
+ :value="course.category._id"
|
|
|
|
+ @change="($event) => emitCourseValue($event, 'category')">
|
|
|
|
+ <!-- <option value="default">Select Category</option> -->
|
|
|
|
+ <option
|
|
|
|
+ v-for="category in categories"
|
|
|
|
+ :key="category._id"
|
|
|
|
+ :value="category._id"
|
|
|
|
+ >{{category.name}}</option>
|
|
</select>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@@ -104,9 +110,22 @@ export default {
|
|
required : true
|
|
required : true
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ computed : {
|
|
|
|
+ categories() {
|
|
|
|
+ return this.$store.state.category.items
|
|
|
|
+ }
|
|
|
|
+ },
|
|
methods : {
|
|
methods : {
|
|
emitCourseValue(e, field){
|
|
emitCourseValue(e, field){
|
|
- this.$emit('courseValueUpdated', {value : e.target.value, field})
|
|
|
|
|
|
+ const {value} = e.target
|
|
|
|
+ if(field === 'category'){
|
|
|
|
+ return this.emitCategory(value, field)
|
|
|
|
+ }
|
|
|
|
+ this.$emit('courseValueUpdated', {value, field})
|
|
|
|
+ },
|
|
|
|
+ emitCategory(categoryId, field){
|
|
|
|
+ const foundCategory = this.categories.find(c => c._id === categoryId)
|
|
|
|
+ this.$emit('courseValueUpdated', {value : foundCategory, field})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|