mirror of
https://github.com/aelve/guide.git
synced 2024-12-22 20:31:31 +03:00
Reloading item only after editing
This commit is contained in:
parent
be0784a7f8
commit
90315f9d92
@ -7,7 +7,7 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<category-item-toolbar
|
<category-item-toolbar
|
||||||
:itemUid="item.id"
|
:itemId="item.id"
|
||||||
:itemName="item.name"
|
:itemName="item.name"
|
||||||
:itemLink="item.link"
|
:itemLink="item.link"
|
||||||
:itemHackage="item.hackage"
|
:itemHackage="item.hackage"
|
||||||
@ -185,7 +185,7 @@ export default class CategoryItem extends Vue {
|
|||||||
original,
|
original,
|
||||||
modified
|
modified
|
||||||
})
|
})
|
||||||
await this.$store.dispatch('category/reloadCategory')
|
await this.$store.dispatch('category/reloadItem', { id: this.item.id })
|
||||||
}
|
}
|
||||||
|
|
||||||
@CatchConflictDecorator
|
@CatchConflictDecorator
|
||||||
@ -195,7 +195,7 @@ export default class CategoryItem extends Vue {
|
|||||||
original,
|
original,
|
||||||
modified
|
modified
|
||||||
})
|
})
|
||||||
await this.$store.dispatch('category/reloadCategory')
|
await this.$store.dispatch('category/reloadItem', { id: this.item.id })
|
||||||
}
|
}
|
||||||
|
|
||||||
@CatchConflictDecorator
|
@CatchConflictDecorator
|
||||||
@ -205,7 +205,7 @@ export default class CategoryItem extends Vue {
|
|||||||
original,
|
original,
|
||||||
modified
|
modified
|
||||||
})
|
})
|
||||||
await this.$store.dispatch('category/reloadCategory')
|
await this.$store.dispatch('category/reloadItem', { id: this.item.id })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<v-toolbar-title class="text-h2">
|
<v-toolbar-title class="text-h2">
|
||||||
<span class="category-item-toolbar-title">
|
<span class="category-item-toolbar-title">
|
||||||
<a
|
<a
|
||||||
:href="`#item-${itemUid}`"
|
:href="`#item-${itemId}`"
|
||||||
class="category-item-anchor"
|
class="category-item-anchor"
|
||||||
>#</a>
|
>#</a>
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ import ResponsiveBtnsContainer from 'client/components/ResponsiveBtnsContainer.v
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
export default class CategoryItemToolbar extends Vue {
|
export default class CategoryItemToolbar extends Vue {
|
||||||
@Prop(String) itemUid!: string
|
@Prop(String) itemId!: string
|
||||||
@Prop(String) itemName!: string
|
@Prop(String) itemName!: string
|
||||||
@Prop(String) itemLink!: string
|
@Prop(String) itemLink!: string
|
||||||
@Prop(String) itemHackage!: string
|
@Prop(String) itemHackage!: string
|
||||||
@ -249,14 +249,14 @@ export default class CategoryItemToolbar extends Vue {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
await this.$store.dispatch('categoryItem/updateItemInfo', {
|
await this.$store.dispatch('categoryItem/updateItemInfo', {
|
||||||
id: this.itemUid,
|
id: this.itemId,
|
||||||
body: {
|
body: {
|
||||||
name: this.itemNameEdit,
|
name: this.itemNameEdit,
|
||||||
link: this.getLinkForSave(),
|
link: this.getLinkForSave(),
|
||||||
hackage: this.itemHackageEdit
|
hackage: this.itemHackageEdit
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
await this.$store.dispatch('category/reloadCategory')
|
await this.$store.dispatch('category/reloadItem', { id: this.itemId })
|
||||||
this.toggleEditItemInfoMenu()
|
this.toggleEditItemInfoMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,13 +277,13 @@ export default class CategoryItemToolbar extends Vue {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
async deleteItem (): Promise<void> {
|
async deleteItem (): Promise<void> {
|
||||||
await this.$store.dispatch('categoryItem/deleteItemById', this.itemUid)
|
await this.$store.dispatch('categoryItem/deleteItemById', this.itemId)
|
||||||
await this.$store.dispatch('category/reloadCategory')
|
await this.$store.dispatch('category/reloadCategory')
|
||||||
}
|
}
|
||||||
|
|
||||||
async moveItem (direction: string) {
|
async moveItem (direction: string) {
|
||||||
await this.$store.dispatch('categoryItem/moveItem', {
|
await this.$store.dispatch('categoryItem/moveItem', {
|
||||||
id: this.itemUid,
|
id: this.itemId,
|
||||||
direction
|
direction
|
||||||
})
|
})
|
||||||
await this.$store.dispatch('category/reloadCategory')
|
await this.$store.dispatch('category/reloadCategory')
|
||||||
|
@ -148,7 +148,7 @@ export default class CategoryItemTraits extends Vue {
|
|||||||
modified
|
modified
|
||||||
})
|
})
|
||||||
trait.isEdit = false
|
trait.isEdit = false
|
||||||
await this.$store.dispatch('category/reloadCategory')
|
await this.$store.dispatch('category/reloadItem', { id: this.itemId })
|
||||||
}
|
}
|
||||||
|
|
||||||
async moveTrait (trait: any, direction: string) {
|
async moveTrait (trait: any, direction: string) {
|
||||||
@ -157,7 +157,7 @@ export default class CategoryItemTraits extends Vue {
|
|||||||
traitId: trait.id,
|
traitId: trait.id,
|
||||||
direction
|
direction
|
||||||
})
|
})
|
||||||
await this.$store.dispatch('category/reloadCategory')
|
await this.$store.dispatch('category/reloadItem', { id: this.itemId })
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleAddTrait () {
|
toggleAddTrait () {
|
||||||
@ -171,7 +171,7 @@ export default class CategoryItemTraits extends Vue {
|
|||||||
content: traitText
|
content: traitText
|
||||||
})
|
})
|
||||||
this.toggleAddTrait()
|
this.toggleAddTrait()
|
||||||
await this.$store.dispatch('category/reloadCategory')
|
await this.$store.dispatch('category/reloadItem', { id: this.itemId })
|
||||||
}
|
}
|
||||||
|
|
||||||
@Confirm({
|
@Confirm({
|
||||||
@ -186,7 +186,7 @@ export default class CategoryItemTraits extends Vue {
|
|||||||
itemId: this.itemId,
|
itemId: this.itemId,
|
||||||
traitId: trait.id
|
traitId: trait.id
|
||||||
})
|
})
|
||||||
await this.$store.dispatch('category/reloadCategory')
|
await this.$store.dispatch('category/reloadItem', { id: this.itemId })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -15,6 +15,10 @@ class CategoryItemService {
|
|||||||
link
|
link
|
||||||
}, { requestName: 'create item' })
|
}, { requestName: 'create item' })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getItemById (id: ICategoryItem['id']): Promise<void> {
|
||||||
|
return api.get(`item/${id}`, { requestName: 'get item' })
|
||||||
|
}
|
||||||
async deleteItemById (id: ICategoryItem['id']): Promise<void> {
|
async deleteItemById (id: ICategoryItem['id']): Promise<void> {
|
||||||
await api.delete(`item/${id}`, { requestName: 'delete item' })
|
await api.delete(`item/${id}`, { requestName: 'delete item' })
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { ActionTree, GetterTree, MutationTree, ActionContext, Module } from 'vuex'
|
import { ActionTree, GetterTree, MutationTree, ActionContext, Module } from 'vuex'
|
||||||
import { ICategoryInfo, ICategoryFull, CategoryService } from 'client/service/Category'
|
import { ICategoryInfo, ICategoryFull, CategoryService } from 'client/service/Category'
|
||||||
import { ICategoryItem } from 'client/service/CategoryItem'
|
import { ICategoryItem, CategoryItemService } from 'client/service/CategoryItem'
|
||||||
import { set } from '../helpers'
|
import { set } from '../helpers'
|
||||||
|
|
||||||
interface ICategoryState {
|
interface ICategoryState {
|
||||||
@ -94,6 +94,13 @@ const actions: ActionTree<ICategoryState, any> = {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return createdDescription
|
return createdDescription
|
||||||
|
},
|
||||||
|
async reloadItem (
|
||||||
|
{ commit }: ActionContext<ICategoryState, any>,
|
||||||
|
{ id }: { id: ICategoryItem['id'] }
|
||||||
|
) {
|
||||||
|
const item = await CategoryItemService.getItemById(id)
|
||||||
|
commit('resetItem', item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,6 +116,11 @@ const mutations: MutationTree<ICategoryState> = {
|
|||||||
} else {
|
} else {
|
||||||
sectionEditState.push(itemId)
|
sectionEditState.push(itemId)
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
resetItem (state, item) {
|
||||||
|
const { items } = state.category
|
||||||
|
const index = items.map(({ id }) => id).indexOf(item.id)
|
||||||
|
items.splice(index, 1, item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user