diff --git a/frontend/src/components/submission_notes/SubmissionCorrection.vue b/frontend/src/components/submission_notes/SubmissionCorrection.vue index 030e868c43830ce807a76a581e233afbfc5d3e2b..83611dd1485cde1e4948a7638a57fb89854bb186 100644 --- a/frontend/src/components/submission_notes/SubmissionCorrection.vue +++ b/frontend/src/components/submission_notes/SubmissionCorrection.vue @@ -60,7 +60,7 @@ import AnnotatedSubmissionBottomToolbar from '@/components/submission_notes/toolbars/AnnotatedSubmissionBottomToolbar' import BaseAnnotatedSubmission from '@/components/submission_notes/base/BaseAnnotatedSubmission' import SubmissionLine from '@/components/submission_notes/base/SubmissionLine' - import {subNotesMut} from '@/store/modules/submission-notes' + import {subNotesMut, subNotesNamespace} from '@/store/modules/submission-notes' export default { components: { @@ -114,15 +114,15 @@ }, methods: { deleteFeedback (lineNo) { - this.$store.commit(subNotesMut.DELETE_FEEDBACK_LINE, lineNo) + this.$store.commit(subNotesNamespace(subNotesMut.DELETE_FEEDBACK_LINE), lineNo) }, toggleEditorOnLine (lineNo, comment = '') { - this.$store.commit(subNotesMut.TOGGLE_EDITOR_ON_LINE, {lineNo, comment}) + this.$store.commit(subNotesNamespace(subNotesMut.TOGGLE_EDITOR_ON_LINE), {lineNo, comment}) }, submitFeedback () { this.loading = true - this.$store.dispatch('submitFeedback', this.assignment).then(() => { - this.$store.commit(subNotesMut.RESET_STATE) + this.$store.dispatch(subNotesNamespace('submitFeedback'), this.assignment).then(() => { + this.$store.commit(subNotesNamespace(subNotesMut.RESET_STATE)) this.$emit('feedbackCreated') }).catch(err => { this.$notify({ @@ -135,9 +135,9 @@ }) }, init () { - this.$store.commit(subNotesMut.RESET_STATE) - this.$store.commit(subNotesMut.SET_RAW_SUBMISSION, this.submissionObj.text) - this.$store.commit(subNotesMut.SET_RAW_SUBMISSION, this.feedbackObj) + this.$store.commit(subNotesNamespace(subNotesMut.RESET_STATE)) + this.$store.commit(subNotesNamespace(subNotesMut.SET_RAW_SUBMISSION), this.submissionObj.text) + this.$store.commit(subNotesNamespace(subNotesMut.SET_ORIG_FEEDBACK), this.feedbackObj) this.$nextTick(() => { window.PR.prettyPrint() }) diff --git a/frontend/src/components/submission_notes/base/CommentForm.vue b/frontend/src/components/submission_notes/base/CommentForm.vue index e7faec3664c460c786eb099799663b9503aa402b..dd82fa19db79f887a326863e20d132ced1232123 100644 --- a/frontend/src/components/submission_notes/base/CommentForm.vue +++ b/frontend/src/components/submission_notes/base/CommentForm.vue @@ -20,7 +20,7 @@ <script> - import {subNotesMut} from '@/store/modules/submission-notes' + import {subNotesMut, subNotesNamespace} from '@/store/modules/submission-notes' export default { name: 'comment-form', @@ -49,7 +49,7 @@ this.$emit('collapseFeedbackForm') }, submitFeedback () { - this.$store.commit(subNotesMut.UPDATE_FEEDBACK_LINE, { + this.$store.commit(subNotesNamespace(subNotesMut.UPDATE_FEEDBACK_LINE), { lineNo: this.lineNo, comment: { text: this.currentFeedback diff --git a/frontend/src/components/submission_notes/toolbars/AnnotatedSubmissionBottomToolbar.vue b/frontend/src/components/submission_notes/toolbars/AnnotatedSubmissionBottomToolbar.vue index 223693bdcda703bb26815983a8a3f8594557a796..f5b0e268ab3f7850f45209a4c8b519648da2497d 100644 --- a/frontend/src/components/submission_notes/toolbars/AnnotatedSubmissionBottomToolbar.vue +++ b/frontend/src/components/submission_notes/toolbars/AnnotatedSubmissionBottomToolbar.vue @@ -39,7 +39,7 @@ </template> <script> - import {subNotesMut} from '@/store/modules/submission-notes' + import {subNotesMut, subNotesNamespace} from '@/store/modules/submission-notes' export default { name: 'annotated-submission-bottom-toolbar', @@ -64,7 +64,7 @@ return this.$store.getters['submissionNotes/score'] }, set: function (score) { - this.$store.commit(subNotesMut.UPDATE_FEEDBACK_SCORE, Number(score)) + this.$store.commit(subNotesNamespace(subNotesMut.UPDATE_FEEDBACK_SCORE), Number(score)) } } }, diff --git a/frontend/src/store/modules/submission-notes.js b/frontend/src/store/modules/submission-notes.js index ef8741d4c6276e9d4645908b33d5c95574c7e406..cd75a44f7d50a549177c30291e6360b3e15eab70 100644 --- a/frontend/src/store/modules/submission-notes.js +++ b/frontend/src/store/modules/submission-notes.js @@ -1,5 +1,18 @@ import Vue from 'vue' import * as api from '@/api' +import {nameSpacer} from '@/store/util/helpers' + +export const subNotesNamespace = nameSpacer('submissionNotes/') + +export const subNotesMut = Object.freeze({ + SET_RAW_SUBMISSION: 'SET_RAW_SUBMISSION', + SET_ORIG_FEEDBACK: 'SET_ORIG_FEEDBACK', + UPDATE_FEEDBACK_LINE: 'UPDATE_FEEDBACK_LINE', + UPDATE_FEEDBACK_SCORE: 'UPDATE_FEEDBACK_SCORE', + DELETE_FEEDBACK_LINE: 'DELETE_FEEDBACK_LINE', + TOGGLE_EDITOR_ON_LINE: 'TOGGLE_EDITOR_ON_LINE', + RESET_STATE: 'RESET_STATE' +}) function initialState () { return { @@ -20,16 +33,6 @@ function initialState () { } } -export const subNotesMut = Object.freeze({ - SET_RAW_SUBMISSION: 'SET_RAW_SUBMISSION', - SET_ORIG_FEEDBACK: 'SET_ORIG_FEEDBACK', - UPDATE_FEEDBACK_LINE: 'UPDATE_FEEDBACK_LINE', - UPDATE_FEEDBACK_SCORE: 'UPDATE_FEEDBACK_SCORE', - DELETE_FEEDBACK_LINE: 'DELETE_FEEDBACK_LINE', - TOGGLE_EDITOR_ON_LINE: 'TOGGLE_EDITOR_ON_LINE', - RESET_STATE: 'RESET_STATE' -}) - const submissionNotes = { namespaced: true, state: initialState(), diff --git a/frontend/src/store/store.js b/frontend/src/store/store.js index 4e1d15819682fb5acb109cbbc95fc79fe47691c0..b036d787bbab5bba1f9640bdcb0f303252bb63c9 100644 --- a/frontend/src/store/store.js +++ b/frontend/src/store/store.js @@ -9,7 +9,7 @@ import authentication from './modules/authentication' import actions from './actions' import getters from './getters' import mutations from '@/store/mutations' -import {lastInteraction} from '@/store/lastInteractionPlugin' +import {lastInteraction} from '@/store/util/lastInteractionPlugin' Vue.use(Vuex) diff --git a/frontend/src/store/util/helpers.js b/frontend/src/store/util/helpers.js new file mode 100644 index 0000000000000000000000000000000000000000..ec0f674e1dde87987537d8542f7d7b368a835f83 --- /dev/null +++ b/frontend/src/store/util/helpers.js @@ -0,0 +1,6 @@ + +export function nameSpacer (namespace) { + return function (commitType) { + return namespace + commitType + } +} diff --git a/frontend/src/store/lastInteractionPlugin.js b/frontend/src/store/util/lastInteractionPlugin.js similarity index 100% rename from frontend/src/store/lastInteractionPlugin.js rename to frontend/src/store/util/lastInteractionPlugin.js