Commit d51cedb6 authored by Kemm23's avatar Kemm23

save code

parent 28205971
......@@ -67,7 +67,6 @@
accept="image/*"
label="Image"
prepend-icon="mdi-camera"
@change="testLog()"
/>
</v-col>
</v-row>
......@@ -125,25 +124,21 @@
</v-col>
<v-col cols="12">
<v-select
v-model="parent_id"
v-model="eParentId"
:items="categories.filter(category => category.parent_id === null)"
item-text="name"
item-value="id"
label="Parent_id"
@input="testLog()"
/>
</v-col>
<v-col cols="12">
<v-file-input
v-model="eImage"
accept="image/*"
label="Image"
prepend-icon="mdi-camera"
/>
</v-col>
<v-col cols="12">
<v-file-input
label="File input"
/>
</v-col>
</v-row>
</v-container>
<small>*indicates required field</small>
......@@ -161,7 +156,7 @@
color="blue darken-1"
text
type="submit"
@click="dialog2 = false; updateUser();"
@click="dialog2 = false; updateCategory();"
>
Save
</v-btn>
......@@ -333,9 +328,7 @@ export default {
this.getCategories()
},
methods: {
testLog () {
console.log(this.image)
},
testLog () {},
initialize () {
this.users = []
this.categories = []
......@@ -395,20 +388,14 @@ export default {
const set = new Set([this.image])
const image = Array.from(set)
const self = this
console.log({
name: this.name,
ordering: this.ordering,
parent_id: this.parent_id,
images: image
})
const fd = new FormData()
fd.append('name', this.name)
fd.append('ordering', this.ordering)
fd.append('parent_id', this.parent_id)
fd.append('images', image)
this.$axios
.post('/categories/',
{
name: this.name,
ordering: this.ordering,
parent_id: this.parent_id,
images: image
},
fd,
{
headers: {
'Content-Type': 'multipart/form-data',
......@@ -417,16 +404,13 @@ export default {
}
)
.then((response) => {
this.$bvModal.hide('modal-create')
self.$toast.success('Category created successfully!', {
duration: 3000
})
this.editedItem = response.data.data
console.log(this.editedItem)
this.categories.push(this.editedItem)
})
.catch((errors) => {
this.$bvModal.hide('modal-create')
console.log(errors.response.data.message)
this.message = errors.response.data.message
self.$toast.error('something went wrong while trying create!', {
......@@ -476,25 +460,21 @@ export default {
this.eParentId = item.parent_id
this.eImage = item.images
this.editedIndex = this.categories.indexOf(item)
console.log(this?.eID)
console.log(item)
},
updateCategory (userID) {
const set = new Set([this.eImage])
const image = Array.from(set)
const self = this
console.log(this.eName)
console.log(this.eOrdering)
console.log(this?.eID)
const fd = new FormData()
fd.append('name', this.eName)
fd.append('ordering', this.eOrdering)
fd.append('parent_id', this.eParentId)
fd.append('images', image)
try {
this.$axios
.post(`categories/update/${this?.eID}`,
{
name: this.eName,
ordering: this.eOrdering,
parent_id: this.eParentId,
images: image
},
fd,
{
headers: {
'Content-Type': 'multipart/form-data',
......@@ -506,9 +486,7 @@ export default {
self.$toast.success('User updated successfully!', {
duration: 3000
})
console.log(response)
this.editedItem = response.data.data
this.$bvModal.hide('modal-edit')
Object.assign(this.categories[this.editedIndex], this.editedItem)
})
} catch (error) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment