mirror of
https://github.com/aelve/guide.git
synced 2024-12-27 06:45:16 +03:00
428c17048d
* TestCafe added to project. First test written * Search input test added * Seacth input test changed, travis job for testcafe tests added * Travis bugfix test * Travis testcafe bugfix test try 2 * Travis testcafe bugfix test ry 3 * Travis testcafe test sleep increased to 10 * Test adding category added but bug with click occurs - check!!! * Category test (testing the group where test was creating) added - bug fix * Article component rewrite * Article component rewritten * Big with rendering content.html in v-for * Collapse bug fix * MInor category visual changes/fixes * Description, reactivity bug fix * merge * Refactoring after code review * Conflict in styles resolved * Item add/delete feature in category * merge with vue * minor code fix * Update ArticleContent.vue * Merge bug fix * Minor merge bug fix * Code review fixes
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import { ActionTree, GetterTree, MutationTree, ActionContext, Module } from 'vuex'
|
|
import { ICategoryItem, CategoryItemService } from 'client/service/CategoryItem'
|
|
|
|
interface CategoryItemState {
|
|
categoryItemList: ICategoryItem[]
|
|
}
|
|
|
|
const state: CategoryItemState = {
|
|
categoryItemList: []
|
|
}
|
|
|
|
const getters: GetterTree<CategoryItemState, any> = {}
|
|
|
|
const actions: ActionTree<CategoryItemState, any> = {
|
|
async loadCategoryItem({ commit }: ActionContext<CategoryItemState, any>): Promise<any> {
|
|
const data: ICategoryItem[] = await CategoryItemService.getCategoryItem()
|
|
commit('setCategoryItem', data)
|
|
},
|
|
async createItem({ dispatch }, { category, name }: ICategoryItem): Promise<any> {
|
|
const createdId = await CategoryItemService.addItem({
|
|
category,
|
|
name
|
|
})
|
|
dispatch('loadCategoryItem')
|
|
return createdId
|
|
},
|
|
async deleteItem({ dispatch }, { id }: ICategoryItem) {
|
|
const deletedId = await CategoryItemService.deleteItem({
|
|
id
|
|
})
|
|
dispatch('loadCategoryItem')
|
|
return deletedId
|
|
}
|
|
}
|
|
|
|
const mutations: MutationTree<CategoryItemState> = {
|
|
setCategoryItem: (state: CategoryItemState, payload: ICategoryItem[]) => {
|
|
state.categoryItemList = payload
|
|
}
|
|
}
|
|
|
|
const categoryItem: Module<CategoryItemState, any> = {
|
|
namespaced: true,
|
|
state,
|
|
getters,
|
|
actions,
|
|
mutations
|
|
}
|
|
|
|
export default categoryItem |