@@ -330,7 +330,7 @@ const mutations = {
330
330
}
331
331
}
332
332
}
333
- //
333
+ //update the component name in the htmlList of all components if it is a child component
334
334
for ( const item of Object . values ( state . componentMap ) ) {
335
335
if ( item . htmlList ) {
336
336
const newArray = [ ...item . htmlList ] ;
@@ -357,26 +357,6 @@ const mutations = {
357
357
item . htmlList = newArray
358
358
}
359
359
}
360
- /*
361
- const breadthFirstSearchParent = (array, id) => {
362
- const queue = [...array.filter(el => typeof el === 'object')]
363
- while (queue.length) {
364
- const evaluated = queue.shift()
365
- for (let i = 0; i < evaluated.children.length; i++) {
366
- if (evaluated.children[i].id === id) {
367
- return {
368
- evaluated,
369
- index: i
370
- }
371
- }
372
- if (evaluated.children.length) {
373
- queue.push(...evaluated.children)
374
- }
375
- }
376
- }
377
- }
378
- */
379
-
380
360
381
361
} ,
382
362
@@ -804,6 +784,28 @@ const mutations = {
804
784
// const newMap = { ...state.componentMap };
805
785
// state.componentMap = { ...newMap };
806
786
787
+ //delete the instances of the Child Component in the activeComponent's htmlList
788
+ const componentName = state . activeComponent ;
789
+ const htmlList = state . componentMap [ componentName ] . htmlList . slice ( 0 ) ;
790
+
791
+ // splice out child componenets even if nested
792
+ function deleteChildFromHtmlList ( array , payload ) {
793
+ for ( let i = array . length ; i -- ; ) {
794
+
795
+ if ( array [ i ] . children . length ) {
796
+ deleteChildFromHtmlList ( array [ i ] . children , payload )
797
+ }
798
+ if ( array [ i ] . text === payload ) {
799
+ array . splice ( i , 1 )
800
+ }
801
+
802
+ }
803
+ }
804
+ deleteChildFromHtmlList ( htmlList , payload ) ;
805
+
806
+ //updates the htmlList with the child components deleted
807
+ state . componentMap [ componentName ] . htmlList = htmlList ;
808
+
807
809
//delete the parent because the payload is no longer a child to the acitive component
808
810
delete state . componentMap [ payload ] . parent [ state . activeComponent ] ;
809
811
@@ -819,14 +821,6 @@ const mutations = {
819
821
state . componentMap [ state . activeComponent ] ;
820
822
}
821
823
} ,
822
- // update Parent's icon Grid with Child Component
823
- [ types . UPGRADE_ICON_GRID_WITH_CHILD_COMPONENT ] : ( state , payload ) => {
824
- //Update available Child Components options to be place along side the HTML Elements every time the Child Components are updated
825
- //mutation function with the same payload and using the activeComponent
826
- //if the payload is not and html option added, if it is then delete it
827
-
828
- } ,
829
-
830
824
// invoked when element is double clicked, changing the boolean value
831
825
[ types . UPDATE_OPEN_MODAL ] : ( state , payload ) => {
832
826
state . modalOpen = payload ;
0 commit comments