Skip to content

Commit c861eab

Browse files
committed
additional error checking to prevent deletion when modal is open for adding notes. needs prevention of note deletion with a dialog or something. also added a REMOVE_ALL_STATE_PROPS_ACTIONS mutation to facilitate removal of these on load
1 parent 46d58f4 commit c861eab

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

src/components/ComponentDisplay.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<!--
2-
Description:
1+
<!--
2+
Description:
33
Handles display grid functionality
44
Functionality includes: resizing/dragging component boxes, display grid image, active component
55
-->
@@ -162,16 +162,21 @@ Description:
162162
label="Add your note here"
163163
filled
164164
dark
165+
autogrow
165166
max-height=15%
166167
autofocus true
167168
></q-input>
168169
<q-btn
169170
color="secondary"
170171
label="Submit Note"
171-
type="submit"
172172
:disable="noteText.length > 0 ? false : true"
173173
@click="submitNote"
174174
/>
175+
<q-btn
176+
color="secondary"
177+
label="Exit Notes"
178+
@click="this.openNoteModal"
179+
/>
175180
</q-form>
176181
</div>
177182
</div>
@@ -435,7 +440,7 @@ export default {
435440
},
436441
// renders modal with Update Children and Layer in it
437442
handleAddNotes(){
438-
if (this.wasDragged === false){
443+
if (this.wasDragged === false && this.activeComponent !== ''){
439444
this.openNoteModal();
440445
}
441446
},

src/store/actions.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import * as types from "./types";
44
const actions = {
55
// Actions that primarily affect componentDisplay.vue //////
66
[types.deleteActiveComponent]: ({ state, commit }) => {
7+
if (state.noteModalOpen === true){
8+
return;
9+
}
710
commit(types.DELETE_ACTIVE_COMPONENT);
811
const activeRouteArray = [...state.routes[state.activeRoute]];
912
const newActiveRouteArray = activeRouteArray.filter(
@@ -290,6 +293,7 @@ const actions = {
290293
// Loading ///////////////////////////////////////////////////////
291294

292295
[types.openProject]: ({ commit, state }, payload) => {
296+
commit(types.REMOVE_ALL_STATE_PROPS_ACTIONS)
293297
payload.userProps.forEach((prop)=>{commit(types.CREATE_PROP, prop)})
294298
payload.userActions.forEach((action)=>{commit(types.CREATE_ACTION, action)})
295299
payload.userState.forEach((state)=>{commit(types.CREATE_STATE, state)})

src/store/mutations.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,25 @@ import {
1414
} from "../utils/search.util";
1515
import _ from "lodash";
1616

17+
1718
const cloneDeep = require("lodash.clonedeep");
1819

1920
const mutations = {
2021
// invoked on undo, resetsstate to a cdeep clone of the initial state
2122
[types.EMPTY_STATE]: (state, payload) => {
2223
payload.store.replaceState(cloneDeep(payload.initialState));
2324
},
24-
25+
[types.REMOVE_ALL_STATE_PROPS_ACTIONS]: (state) =>{
26+
const emptyObj = {
27+
userProps: [],
28+
userState: [],
29+
userActions: [],
30+
}
31+
Object.assign(state, emptyObj)
32+
},
2533
[types.TOGGLE_TUTORIAL]: (state) => {
2634
state.showTutorial = !state.showTutorial;
27-
},
35+
},
2836

2937
// *** ROUTES *** //////////////////////////////////////////////
3038
[types.ADD_ROUTE]: (state, payload) => {
@@ -186,8 +194,6 @@ const mutations = {
186194
}
187195
}
188196
state.selectedState = [];
189-
// state.activeComponentObj = null;
190-
// state.activeComponentObj = active;
191197
state.activeComponentObj = { ...active };
192198

193199
state.componentMap = {

src/store/types.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export const TOGGLE_TUTORIAL = 'TOGGLE_TUTORIAL'
6767
export const ADD_ACTIVE_COMPONENT_NOTE = 'ADD_ACTIVE_COMPONENT_NOTE'
6868
export const DELETE_ACTIVE_COMPONENT_NOTE = 'DELETE_ACTIVE_COMPONENT_NOTE'
6969
export const OPEN_NOTE_MODAL = 'OPEN_NOTE_MODAL'
70+
export const REMOVE_ALL_STATE_PROPS_ACTIONS = 'REMOVE_ALL_STATE_PROPS_ACTIONS'
7071

7172
// Actions
7273
export const openNoteModal = 'openNoteModal'

0 commit comments

Comments
 (0)