@@ -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 : {
@@ -115,7 +114,7 @@ export const addChild = (state, { title, childType = '', HTMLInfo = {} }) => {
115
114
}
116
115
117
116
let htmlElemPosition ;
118
- if ( childType == 'HTML' ) {
117
+ if ( childType === 'HTML' ) {
119
118
htmlElemPosition = getSize ( htmlElement ) ;
120
119
// if above function doesnt reutn anything, it means html element is not in our database
121
120
if ( ! htmlElemPosition . width ) {
@@ -144,7 +143,7 @@ export const addChild = (state, { title, childType = '', HTMLInfo = {} }) => {
144
143
const newChild = {
145
144
childId : view . nextChildId ,
146
145
childType,
147
- childComponentId : childType == 'COMP' ? parentComponent . id : null , // only relevant fot children of type COMPONENT
146
+ childComponentId : childType === 'COMP' ? parentComponent . id : null , // only relevant fot children of type COMPONENT
148
147
componentName : strippedTitle ,
149
148
position : newPosition ,
150
149
// draggable: true,
@@ -207,19 +206,19 @@ export const deleteChild = (
207
206
return state ;
208
207
}
209
208
// make a DEEP copy of the parent component (the one thats about to loose a child)
210
- const parentComponentCopy = cloneDeep ( state . components . find ( c => c . id == parentId ) ) ;
209
+ const parentComponentCopy = cloneDeep ( state . components . find ( c => c . id === parentId ) ) ;
211
210
212
211
// delete the CHILD from the copied array
213
212
const indexToDelete = parentComponentCopy . childrenArray . findIndex (
214
- elem => elem . childId == childId ,
213
+ elem => elem . childId === childId ,
215
214
) ;
216
215
if ( indexToDelete < 0 ) {
217
216
return window . alert ( 'No such child component found' ) ;
218
217
}
219
218
parentComponentCopy . childrenArray . splice ( indexToDelete , 1 ) ;
220
219
221
220
// if deleted child is selected, reset it
222
- if ( parentComponentCopy . focusChildId == childId ) {
221
+ if ( parentComponentCopy . focusChildId === childId ) {
223
222
parentComponentCopy . focusChildId = 0 ;
224
223
}
225
224
@@ -347,7 +346,7 @@ export const deleteComponent = (state, { componentId }) => {
347
346
// ...state.components.slice(0, index),
348
347
// ...state.components.slice(index + 1)
349
348
// ];
350
- if ( componentId == 1 ) {
349
+ if ( componentId === 1 ) {
351
350
return {
352
351
...state ,
353
352
} ;
@@ -380,7 +379,7 @@ export const changeFocusComponent = (state, { title = state.focusComponent.title
380
379
let newFocusChild ; // check if the components has a child saved as a Focus child
381
380
if ( newFocusComp . focusChildId > 0 ) {
382
381
newFocusChild = newFocusComp . childrenArray . find (
383
- child => child . childId == newFocusComp . focusChildId ,
382
+ child => child . childId === newFocusComp . focusChildId ,
384
383
) ;
385
384
}
386
385
@@ -430,9 +429,9 @@ export const changeFocusChild = (state, { title, childId }) => {
430
429
} ;
431
430
432
431
export const changeComponentFocusChild = ( state , { componentId, childId } ) => {
433
- const component = state . components . find ( comp => comp . id == componentId ) ;
432
+ const component = state . components . find ( comp => comp . id === componentId ) ;
434
433
component . focusChildId = childId ;
435
- const components = state . components . filter ( comp => comp . id != componentId ) ;
434
+ const components = state . components . filter ( comp => comp . id !== componentId ) ;
436
435
return {
437
436
...state ,
438
437
components : [ component , ...components ] ,
@@ -599,7 +598,7 @@ export const addProp = (state, {
599
598
return state ;
600
599
}
601
600
602
- const selectedComponent = state . components . find ( comp => comp . id == state . focusComponent . id ) ;
601
+ const selectedComponent = state . components . find ( comp => comp . id === state . focusComponent . id ) ;
603
602
604
603
const newProp = {
605
604
id : selectedComponent . nextPropId ,
@@ -633,18 +632,18 @@ export const deleteProp = (state, propId) => {
633
632
}
634
633
// make a deep copy of focusCOmponent. we are gonne be modifying that copy
635
634
const modifiedComponent = cloneDeep (
636
- state . components . find ( comp => comp . id == state . focusComponent . id ) ,
635
+ state . components . find ( comp => comp . id === state . focusComponent . id ) ,
637
636
) ;
638
637
639
- const indexToDelete = modifiedComponent . props . findIndex ( prop => prop . id == propId ) ;
638
+ const indexToDelete = modifiedComponent . props . findIndex ( prop => prop . id === propId ) ;
640
639
if ( indexToDelete < 0 ) {
641
640
console . log ( `Delete prop Error. Prop id:${ propId } not found in ${ modifiedComponent . title } ` ) ;
642
641
return state ;
643
642
}
644
643
645
644
modifiedComponent . props . splice ( indexToDelete , 1 ) ;
646
645
647
- const newComponentsArray = state . components . filter ( comp => comp . id != modifiedComponent . id ) ;
646
+ const newComponentsArray = state . components . filter ( comp => comp . id !== modifiedComponent . id ) ;
648
647
newComponentsArray . push ( modifiedComponent ) ;
649
648
650
649
return {
@@ -665,15 +664,15 @@ export const updateHtmlAttr = (state, { attr, value }) => {
665
664
666
665
// make a deep copy of focusCOmponent. we are gonne be modifying that copy
667
666
const modifiedComponent = cloneDeep (
668
- state . components . find ( comp => comp . id == state . focusComponent . id ) ,
667
+ state . components . find ( comp => comp . id === state . focusComponent . id ) ,
669
668
) ;
670
669
671
670
modifiedComponent . childrenArray = modifiedComponent . childrenArray . filter (
672
- child => child . childId != modifiedChild . childId ,
671
+ child => child . childId !== modifiedChild . childId ,
673
672
) ;
674
673
modifiedComponent . childrenArray . push ( modifiedChild ) ;
675
674
676
- const newComponentsArray = state . components . filter ( comp => comp . id != modifiedComponent . id ) ;
675
+ const newComponentsArray = state . components . filter ( comp => comp . id !== modifiedComponent . id ) ;
677
676
newComponentsArray . push ( modifiedComponent ) ;
678
677
679
678
return {
0 commit comments