@@ -13,7 +13,6 @@ const initialComponentState = {
13
13
//draggable: true,
14
14
childrenIds : [ ] ,
15
15
selectableParents : [ ] ,
16
- expanded : true ,
17
16
props : [ ] ,
18
17
nextPropId : 1 ,
19
18
position : {
@@ -111,7 +110,7 @@ export const addChild = (state, { title, childType = '', HTMLInfo = {} }) => {
111
110
}
112
111
113
112
let htmlElemPosition ;
114
- if ( childType == 'HTML' ) {
113
+ if ( childType === 'HTML' ) {
115
114
htmlElemPosition = getSize ( htmlElement ) ;
116
115
// if above function doesnt reutn anything, it means html element is not in our database
117
116
if ( ! htmlElemPosition . width ) {
@@ -139,7 +138,7 @@ export const addChild = (state, { title, childType = '', HTMLInfo = {} }) => {
139
138
const newChild = {
140
139
childId : view . nextChildId ,
141
140
childType,
142
- childComponentId : childType == 'COMP' ? parentComponent . id : null , // only relevant fot children of type COMPONENT
141
+ childComponentId : childType === 'COMP' ? parentComponent . id : null , // only relevant fot children of type COMPONENT
143
142
componentName : strippedTitle ,
144
143
position : newPosition ,
145
144
// draggable: true,
@@ -198,17 +197,17 @@ export const deleteChild = (
198
197
return state ;
199
198
}
200
199
// make a DEEP copy of the parent component (the one thats about to loose a child)
201
- const parentComponentCopy = cloneDeep ( state . components . find ( c => c . id == parentId ) ) ;
200
+ const parentComponentCopy = cloneDeep ( state . components . find ( c => c . id === parentId ) ) ;
202
201
203
202
// delete the CHILD from the copied array
204
- const indexToDelete = parentComponentCopy . childrenArray . findIndex ( elem => elem . childId == childId ) ;
203
+ const indexToDelete = parentComponentCopy . childrenArray . findIndex ( elem => elem . childId === childId ) ;
205
204
if ( indexToDelete < 0 ) {
206
205
return window . alert ( 'No such child component found' ) ;
207
206
}
208
207
parentComponentCopy . childrenArray . splice ( indexToDelete , 1 ) ;
209
208
210
209
// if deleted child is selected, reset it
211
- if ( parentComponentCopy . focusChildId == childId ) {
210
+ if ( parentComponentCopy . focusChildId === childId ) {
212
211
parentComponentCopy . focusChildId = 0 ;
213
212
}
214
213
@@ -336,7 +335,7 @@ export const deleteComponent = (state, { componentId }) => {
336
335
// ...state.components.slice(0, index),
337
336
// ...state.components.slice(index + 1)
338
337
// ];
339
- if ( componentId == 1 ) {
338
+ if ( componentId === 1 ) {
340
339
return {
341
340
...state ,
342
341
} ;
@@ -368,7 +367,7 @@ export const changeFocusComponent = (state, { title = state.focusComponent.title
368
367
369
368
let newFocusChild ; // check if the components has a child saved as a Focus child
370
369
if ( newFocusComp . focusChildId > 0 ) {
371
- newFocusChild = newFocusComp . childrenArray . find ( child => child . childId == newFocusComp . focusChildId ) ;
370
+ newFocusChild = newFocusComp . childrenArray . find ( child => child . childId === newFocusComp . focusChildId ) ;
372
371
}
373
372
374
373
// if no docus child found .. reset
@@ -417,9 +416,9 @@ export const changeFocusChild = (state, { title, childId }) => {
417
416
} ;
418
417
419
418
export const changeComponentFocusChild = ( state , { componentId, childId } ) => {
420
- const component = state . components . find ( comp => comp . id == componentId ) ;
419
+ const component = state . components . find ( comp => comp . id === componentId ) ;
421
420
component . focusChildId = childId ;
422
- const components = state . components . filter ( comp => comp . id != componentId ) ;
421
+ const components = state . components . filter ( comp => comp . id !== componentId ) ;
423
422
return {
424
423
...state ,
425
424
components : [ component , ...components ] ,
@@ -584,7 +583,7 @@ export const addProp = (state, { key, value = null, required, type }) => {
584
583
return state ;
585
584
}
586
585
587
- const selectedComponent = state . components . find ( comp => comp . id == state . focusComponent . id ) ;
586
+ const selectedComponent = state . components . find ( comp => comp . id === state . focusComponent . id ) ;
588
587
589
588
const newProp = {
590
589
id : selectedComponent . nextPropId ,
@@ -617,17 +616,17 @@ export const deleteProp = (state, propId) => {
617
616
return state ;
618
617
}
619
618
// make a deep copy of focusCOmponent. we are gonne be modifying that copy
620
- const modifiedComponent = cloneDeep ( state . components . find ( comp => comp . id == state . focusComponent . id ) ) ;
619
+ const modifiedComponent = cloneDeep ( state . components . find ( comp => comp . id === state . focusComponent . id ) ) ;
621
620
622
- const indexToDelete = modifiedComponent . props . findIndex ( prop => prop . id == propId ) ;
621
+ const indexToDelete = modifiedComponent . props . findIndex ( prop => prop . id === propId ) ;
623
622
if ( indexToDelete < 0 ) {
624
623
console . log ( `Delete prop Error. Prop id:${ propId } not found in ${ modifiedComponent . title } ` ) ;
625
624
return state ;
626
625
}
627
626
628
627
modifiedComponent . props . splice ( indexToDelete , 1 ) ;
629
628
630
- const newComponentsArray = state . components . filter ( comp => comp . id != modifiedComponent . id ) ;
629
+ const newComponentsArray = state . components . filter ( comp => comp . id !== modifiedComponent . id ) ;
631
630
newComponentsArray . push ( modifiedComponent ) ;
632
631
633
632
return {
@@ -647,14 +646,14 @@ export const updateHtmlAttr = (state, { attr, value }) => {
647
646
modifiedChild . HTMLInfo [ attr ] = value ;
648
647
649
648
// make a deep copy of focusCOmponent. we are gonne be modifying that copy
650
- const modifiedComponent = cloneDeep ( state . components . find ( comp => comp . id == state . focusComponent . id ) ) ;
649
+ const modifiedComponent = cloneDeep ( state . components . find ( comp => comp . id === state . focusComponent . id ) ) ;
651
650
652
651
modifiedComponent . childrenArray = modifiedComponent . childrenArray . filter (
653
- child => child . childId != modifiedChild . childId ,
652
+ child => child . childId !== modifiedChild . childId ,
654
653
) ;
655
654
modifiedComponent . childrenArray . push ( modifiedChild ) ;
656
655
657
- const newComponentsArray = state . components . filter ( comp => comp . id != modifiedComponent . id ) ;
656
+ const newComponentsArray = state . components . filter ( comp => comp . id !== modifiedComponent . id ) ;
658
657
newComponentsArray . push ( modifiedComponent ) ;
659
658
660
659
return {
0 commit comments