11import * as types from './types'
22
33const actions = {
4- //
4+ // creates a new component in componentMap
55 [ types . registerComponent ] : ( { state, commit } , payload ) => {
66 const { componentName } = payload
77 if ( ! state . componentMap [ componentName ] ) {
@@ -21,7 +21,10 @@ const actions = {
2121 } )
2222
2323 if ( state . parentSelected ) {
24- commit ( types . UPDATE_ACTIVE_COMPONENT_CHILDREN_VALUE , [ ...state . componentMap [ state . activeComponent ] . children , payload . componentName ] )
24+ commit ( types . UPDATE_ACTIVE_COMPONENT_CHILDREN_VALUE , [
25+ ...state . componentMap [ state . activeComponent ] . children ,
26+ payload . componentName
27+ ] )
2528 }
2629
2730 commit ( types . UPDATE_COMPONENT_CHILDREN_VALUE , { component, value } )
@@ -75,6 +78,7 @@ const actions = {
7578 [ types . changeActiveTab ] : ( { commit } , payload ) => {
7679 commit ( types . CHANGE_ACTIVE_TAB , payload )
7780 } ,
81+ // used by OpenProjectComponent.vue
7882 [ types . setComponentMap ] : ( { commit } , payload ) => {
7983 commit ( types . SET_COMPONENT_MAP , payload )
8084 } ,
@@ -91,6 +95,7 @@ const actions = {
9195 [ types . setActiveRoute ] : ( { commit } , payload ) => {
9296 commit ( types . SET_ACTIVE_ROUTE , payload )
9397 } ,
98+ // sets active component when clicked in componentDisplay
9499 [ types . setActiveComponent ] : ( { commit } , payload ) => {
95100 commit ( types . SET_ACTIVE_COMPONENT , payload )
96101 } ,
@@ -123,14 +128,38 @@ const actions = {
123128 console . log ( 'payload in actions:' , payload )
124129 commit ( types . DELETE_COMPONENT , payload )
125130 } ,
131+ [ types . importImage ] : ( { commit } , payload ) => {
132+ commit ( types . IMPORT_IMAGE , payload )
133+ } ,
134+ [ types . clearImage ] : ( { commit } ) => {
135+ commit ( types . CLEAR_IMAGE )
136+ } ,
126137 [ types . deleteUserActions ] : ( { state, commit } , payload ) => {
127138 console . log ( 'invoking deleteUserActions' )
128- if ( state . activeComponent ) commit ( types . REMOVE_ACTION_FROM_COMPONENT , payload )
139+ if ( state . activeComponent ) {
140+ commit ( types . REMOVE_ACTION_FROM_COMPONENT , payload )
141+ }
129142 commit ( types . DELETE_USER_ACTIONS , payload )
130143 } ,
131144 [ types . removeActionFromComponent ] : ( { state, commit } , payload ) => {
132145 console . log ( 'invoking removeActionFromComponent' )
133146 commit ( types . REMOVE_ACTION_FROM_COMPONENT , payload )
147+ } ,
148+ [ types . removeStateFromComponent ] : ( { commit } , payload ) => {
149+ console . log ( 'removeStateFromComponent invoked' )
150+ commit ( types . REMOVE_STATE_FROM_COMPONENT , payload )
151+ } ,
152+ [ types . deleteUserState ] : ( { state, commit } , payload ) => {
153+ console . log ( 'deleteUserState invoked' )
154+ if ( state . activeComponent ) {
155+ commit ( types . REMOVE_STATE_FROM_COMPONENT , payload )
156+ }
157+ // loops through component map and deletes all props
158+ Object . keys ( state . componentMap ) . forEach ( prop => {
159+ commit ( types . SET_ACTIVE_COMPONENT , prop . componentName )
160+ commit ( types . REMOVE_ACTION_FROM_COMPONENT , payload )
161+ } )
162+ commit ( types . DELETE_USER_STATE , payload )
134163 }
135164}
136165
0 commit comments