Commit d51cedb6 authored by Kemm23's avatar Kemm23

save code

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