From 9a6b9bf3e35f98218bb6cb2fdd62886ee7b8ffeb Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Wed, 21 Nov 2018 14:56:43 +0100 Subject: [PATCH] Add edit objective form wizard to client --- client/src/App.vue | 4 +- .../EditObjectiveGroupWizard.vue | 107 ++++++++++++++++++ .../NewObjectiveGroupWizard.vue | 47 ++------ .../objective-groups/ObjectiveForm.vue | 6 +- .../objective-groups/ObjectiveGroup.vue | 14 ++- .../objective-groups/ObjectiveGroupForm.vue | 64 +++++++++++ client/src/graphql/client.js | 3 +- .../gql/fragments/objectiveGroupParts.gql | 1 + .../gql/mutations/updateObjectiveGroup.gql | 16 +++ .../src/graphql/gql/objectiveGroupQuery.gql | 14 +++ client/src/store/index.js | 11 +- 11 files changed, 245 insertions(+), 42 deletions(-) create mode 100644 client/src/components/objective-groups/EditObjectiveGroupWizard.vue create mode 100644 client/src/components/objective-groups/ObjectiveGroupForm.vue create mode 100644 client/src/graphql/gql/mutations/updateObjectiveGroup.gql create mode 100644 client/src/graphql/gql/objectiveGroupQuery.gql diff --git a/client/src/App.vue b/client/src/App.vue index 9e17d019..e78c6e57 100644 --- a/client/src/App.vue +++ b/client/src/App.vue @@ -15,6 +15,7 @@ import NewRoomEntryWizard from '@/components/rooms/room-entries/NewRoomEntryWizard'; import EditRoomEntryWizard from '@/components/rooms/room-entries/EditRoomEntryWizard'; import NewObjectiveGroupWizard from '@/components/objective-groups/NewObjectiveGroupWizard'; + import EditObjectiveGroupWizard from '@/components/objective-groups/EditObjectiveGroupWizard'; export default { name: 'App', @@ -28,7 +29,8 @@ EditContentBlockWizard, NewRoomEntryWizard, EditRoomEntryWizard, - NewObjectiveGroupWizard + NewObjectiveGroupWizard, + EditObjectiveGroupWizard }, computed: { diff --git a/client/src/components/objective-groups/EditObjectiveGroupWizard.vue b/client/src/components/objective-groups/EditObjectiveGroupWizard.vue new file mode 100644 index 00000000..9e67b362 --- /dev/null +++ b/client/src/components/objective-groups/EditObjectiveGroupWizard.vue @@ -0,0 +1,107 @@ + + + + + diff --git a/client/src/components/objective-groups/NewObjectiveGroupWizard.vue b/client/src/components/objective-groups/NewObjectiveGroupWizard.vue index 84497951..a09c69f9 100644 --- a/client/src/components/objective-groups/NewObjectiveGroupWizard.vue +++ b/client/src/components/objective-groups/NewObjectiveGroupWizard.vue @@ -1,27 +1,15 @@ diff --git a/client/src/components/objective-groups/ObjectiveForm.vue b/client/src/components/objective-groups/ObjectiveForm.vue index b1c5bc62..a2e94d15 100644 --- a/client/src/components/objective-groups/ObjectiveForm.vue +++ b/client/src/components/objective-groups/ObjectiveForm.vue @@ -2,10 +2,10 @@
- +
@@ -14,7 +14,7 @@ diff --git a/client/src/components/objective-groups/ObjectiveGroupForm.vue b/client/src/components/objective-groups/ObjectiveGroupForm.vue new file mode 100644 index 00000000..b32ca67e --- /dev/null +++ b/client/src/components/objective-groups/ObjectiveGroupForm.vue @@ -0,0 +1,64 @@ + + + + + diff --git a/client/src/graphql/client.js b/client/src/graphql/client.js index 48b7f090..c7031b1a 100644 --- a/client/src/graphql/client.js +++ b/client/src/graphql/client.js @@ -44,7 +44,8 @@ const cache = new InMemoryCache({ contentBlock: (_, args, {getCacheKey}) => getCacheKey({__typename: 'ContentBlockNode', id: args.id}), chapter: (_, args, {getCacheKey}) => getCacheKey({__typename: 'ChapterNode', id: args.id}), assignment: (_, args, {getCacheKey}) => getCacheKey({__typename: 'AssignmentNode', id: args.id}), - objective: (_, args, {getCacheKey}) => getCacheKey({__typename: 'ObjectiveNode', id: args.id}) + objective: (_, args, {getCacheKey}) => getCacheKey({__typename: 'ObjectiveNode', id: args.id}), + objectiveGroup: (_, args, {getCacheKey}) => getCacheKey({__typename: 'ObjectiveGroupNode', id: args.id}) } } }); diff --git a/client/src/graphql/gql/fragments/objectiveGroupParts.gql b/client/src/graphql/gql/fragments/objectiveGroupParts.gql index 38e6f8b7..a806919a 100644 --- a/client/src/graphql/gql/fragments/objectiveGroupParts.gql +++ b/client/src/graphql/gql/fragments/objectiveGroupParts.gql @@ -2,6 +2,7 @@ fragment ObjectiveGroupParts on ObjectiveGroupNode { id title displayTitle + mine owner { id } diff --git a/client/src/graphql/gql/mutations/updateObjectiveGroup.gql b/client/src/graphql/gql/mutations/updateObjectiveGroup.gql new file mode 100644 index 00000000..4a0bfa68 --- /dev/null +++ b/client/src/graphql/gql/mutations/updateObjectiveGroup.gql @@ -0,0 +1,16 @@ +#import "../fragments/objectiveGroupParts.gql" +mutation UpdateObjectiveGroup($input: UpdateObjectiveGroupInput!) { + updateObjectiveGroup(input: $input) { + objectiveGroup { + ...ObjectiveGroupParts + objectives { + edges { + node { + id + text + } + } + } + } + } +} diff --git a/client/src/graphql/gql/objectiveGroupQuery.gql b/client/src/graphql/gql/objectiveGroupQuery.gql new file mode 100644 index 00000000..c4b6b653 --- /dev/null +++ b/client/src/graphql/gql/objectiveGroupQuery.gql @@ -0,0 +1,14 @@ +#import "./fragments/objectiveGroupParts.gql" +query ObjectiveGroupQuery($id: ID!) { + objectiveGroup(id: $id) { + ...ObjectiveGroupParts + objectives { + edges { + node { + id + text + } + } + } + } +} diff --git a/client/src/store/index.js b/client/src/store/index.js index 759dbd75..5950370a 100644 --- a/client/src/store/index.js +++ b/client/src/store/index.js @@ -16,7 +16,8 @@ export default new Vuex.Store({ currentRoomEntry: '', parentRoom: null, parentModule: '', - objectiveGroupType: '' + objectiveGroupType: '', + currentObjectiveGroup: '' }, getters: {}, @@ -37,6 +38,7 @@ export default new Vuex.Store({ commit('setParentRoom', null); commit('setParentModule', ''); commit('setObjectiveGroupType', ''); + commit('setCurrentObjectiveGroup', ''); }, resetContentBlockPosition({commit}) { commit('setContentBlockPosition', {}); @@ -65,6 +67,10 @@ export default new Vuex.Store({ commit('setObjectiveGroupType', type); dispatch('showModal', 'new-objective-group-wizard'); }, + editObjectiveGroup({commit, dispatch}, payload) { + commit('setCurrentObjectiveGroup', payload); + dispatch('showModal', 'edit-objective-group-wizard'); + }, showModal({commit}, payload) { document.body.classList.add('no-scroll'); // won't get at the body any other way commit('setModal', payload); @@ -107,6 +113,9 @@ export default new Vuex.Store({ }, setObjectiveGroupType(state, payload) { state.objectiveGroupType = payload; + }, + setCurrentObjectiveGroup(state, payload) { + state.currentObjectiveGroup = payload; } } })