From c9cbfb4be33179840ab128cf2f743e9130d8c0c7 Mon Sep 17 00:00:00 2001 From: Hironsan Date: Thu, 29 Aug 2019 15:23:47 +0900 Subject: [PATCH] Update project page --- frontend/api/routes/projects.js | 1 + frontend/components/BaseCard.vue | 63 ++++++++ frontend/components/FormProjectCreation.vue | 104 ++++++------- .../containers/ProjectCreationButton.vue | 9 ++ .../components/containers/ProjectList.vue | 45 ++++++ .../organisms/ProjectCreationButton.vue | 37 +++++ .../organisms/ProjectDeletionButton.vue | 63 ++++++++ frontend/components/organisms/ProjectList.vue | 57 +++++++ frontend/layouts/projects.vue | 15 +- frontend/pages/projects/index.vue | 143 ++---------------- frontend/store/ProjectList.js | 61 ++++++++ 11 files changed, 406 insertions(+), 192 deletions(-) create mode 100644 frontend/components/BaseCard.vue create mode 100644 frontend/components/containers/ProjectCreationButton.vue create mode 100644 frontend/components/containers/ProjectList.vue create mode 100644 frontend/components/organisms/ProjectCreationButton.vue create mode 100644 frontend/components/organisms/ProjectDeletionButton.vue create mode 100644 frontend/components/organisms/ProjectList.vue create mode 100644 frontend/store/ProjectList.js diff --git a/frontend/api/routes/projects.js b/frontend/api/routes/projects.js index eda99e71..e8928627 100644 --- a/frontend/api/routes/projects.js +++ b/frontend/api/routes/projects.js @@ -29,6 +29,7 @@ router.post('/', (req, res) => { updated_at: '2019-08-21T02:49:48.790813Z', randomize_document_order: false } + db.push(project) res.json(project) }) diff --git a/frontend/components/BaseCard.vue b/frontend/components/BaseCard.vue new file mode 100644 index 00000000..7015d66a --- /dev/null +++ b/frontend/components/BaseCard.vue @@ -0,0 +1,63 @@ + + + diff --git a/frontend/components/FormProjectCreation.vue b/frontend/components/FormProjectCreation.vue index e0b78737..f237043c 100644 --- a/frontend/components/FormProjectCreation.vue +++ b/frontend/components/FormProjectCreation.vue @@ -1,68 +1,51 @@ \ No newline at end of file diff --git a/frontend/components/containers/ProjectList.vue b/frontend/components/containers/ProjectList.vue new file mode 100644 index 00000000..a5f3f885 --- /dev/null +++ b/frontend/components/containers/ProjectList.vue @@ -0,0 +1,45 @@ + + + diff --git a/frontend/components/organisms/ProjectCreationButton.vue b/frontend/components/organisms/ProjectCreationButton.vue new file mode 100644 index 00000000..456684fd --- /dev/null +++ b/frontend/components/organisms/ProjectCreationButton.vue @@ -0,0 +1,37 @@ + + + diff --git a/frontend/components/organisms/ProjectDeletionButton.vue b/frontend/components/organisms/ProjectDeletionButton.vue new file mode 100644 index 00000000..d5aab251 --- /dev/null +++ b/frontend/components/organisms/ProjectDeletionButton.vue @@ -0,0 +1,63 @@ + + + diff --git a/frontend/components/organisms/ProjectList.vue b/frontend/components/organisms/ProjectList.vue new file mode 100644 index 00000000..4f937e38 --- /dev/null +++ b/frontend/components/organisms/ProjectList.vue @@ -0,0 +1,57 @@ + + + diff --git a/frontend/layouts/projects.vue b/frontend/layouts/projects.vue index b6f42cf0..72c87989 100644 --- a/frontend/layouts/projects.vue +++ b/frontend/layouts/projects.vue @@ -1,7 +1,20 @@ diff --git a/frontend/pages/projects/index.vue b/frontend/pages/projects/index.vue index 81ce2551..45cebbf7 100644 --- a/frontend/pages/projects/index.vue +++ b/frontend/pages/projects/index.vue @@ -1,141 +1,24 @@ diff --git a/frontend/store/ProjectList.js b/frontend/store/ProjectList.js new file mode 100644 index 00000000..1cf0b45d --- /dev/null +++ b/frontend/store/ProjectList.js @@ -0,0 +1,61 @@ +import ProjectService from '@/services/project.service' + +export default { + namespaced: true, + + state: () => ({ + projects: [], + selected: [] + }), + + mutations: { + setProjectList(state, payload) { + state.projects = payload + }, + createProject(state, project) { + state.projects.unshift(project) + }, + deleteProject(state, projectId) { + state.projects = state.projects.filter(item => item.id !== projectId) + }, + updateSelected(state, selected) { + state.selected = selected + }, + resetSelected(state) { + state.selected = [] + } + }, + + actions: { + getProjectList(context, config) { + return ProjectService.getProjectList() + .then((response) => { + context.commit('setProjectList', response) + }) + .catch((error) => { + alert(error) + }) + }, + createProject({ commit }, project) { + ProjectService.createProject(project) + .then((response) => { + commit('createProject', response) + }) + .catch((error) => { + alert(error) + }) + }, + deleteProject({ commit, state }, config) { + for (const project of state.selected) { + ProjectService.deleteProject(project.id) + .then((response) => { + commit('deleteProject', project.id) + }) + .catch((error) => { + alert(error) + }) + } + commit('resetSelected') + } + } +}