@@ -116,6 +116,7 @@ async function refreshNodeContents(node: NodeContentAdminModel, refreshParentPat
116116 existing . displayOrder = child . displayOrder ;
117117 existing . name = child . name ;
118118 existing . nodePathDisplayVersionId = child . nodePathDisplayVersionId ;
119+ existing . resourceReferenceDisplayVersionId = child . resourceReferenceDisplayVersionId ;
119120 existing . nodePaths = child . nodePaths ;
120121 existing . isResource = child . nodeTypeId === NodeType . Resource ;
121122 if ( child . nodePaths ) {
@@ -164,20 +165,22 @@ async function refreshNodeContents(node: NodeContentAdminModel, refreshParentPat
164165 state . lastErrorMessage = `Error refreshing Node contents of ${ node . name } ` ;
165166 } ) ;
166167}
167-
168- async function refreshNodeIfMatchingNodeId ( node : NodeContentAdminModel , nodeId : number , hierarchyEditDetailId : number ) {
168+ async function refreshNodeIfMatchingNodeId ( node : NodeContentAdminModel , nodeId : number , hierarchyEditDetailId : number , removeChildren ?: boolean ) {
169169 if ( node . nodeId === nodeId && node . hierarchyEditDetailId != hierarchyEditDetailId ) {
170+ if ( removeChildren && node . parent ) {
171+ node . parent . children = [ ] ;
172+ node . parent . childrenLoaded = false ;
173+ }
170174 await refreshNodeContents ( node . parent , false ) ;
171175 }
172176 if ( node . childrenLoaded ) {
173177 if ( node . children . filter ( c => c . hierarchyEditDetailId === hierarchyEditDetailId ) . length == 0 ) {
174178 for ( const child of node . children ) {
175- await refreshNodeIfMatchingNodeId ( child , nodeId , hierarchyEditDetailId ) ;
179+ await refreshNodeIfMatchingNodeId ( child , nodeId , hierarchyEditDetailId , removeChildren ) ;
176180 }
177181 }
178182 }
179183}
180-
181184async function processChildNodeContents ( child : NodeContentAdminModel , parent : NodeContentAdminModel ) {
182185 child . parent = parent ;
183186 child . inEdit = child . parent . inEdit ;
@@ -413,13 +416,34 @@ const actions = <ActionTree<State, any>>{
413416 state . lastErrorMessage = "Error deleting folder." ;
414417 } ) ;
415418 } ,
416- deleteFolderReference ( context : ActionContext < State , State > ) {
419+ deleteFolderReferenceDetails ( context : ActionContext < State , State > ) {
420+ state . inError = false ;
421+ state . updatedNode = null ;
422+ contentStructureData . deleteFolderReferenceDetails ( state . editingTreeNode . hierarchyEditDetailId ) . then ( async response => {
423+ if ( response . isValid ) {
424+ var parent = state . editingTreeNode . parent ;
425+ await refreshNodeContents ( parent , false ) ;
426+ await refreshNodeIfMatchingNodeId ( state . rootNode , state . editingTreeNode . nodeId , state . editingTreeNode . hierarchyEditDetailId , true ) ;
427+ state . updatedNode = parent ;
428+ context . commit ( "setEditMode" , EditModeEnum . Structure ) ;
429+ }
430+ else {
431+ state . inError = true ;
432+ state . lastErrorMessage = "Error: " + response . details . join ( "," ) ;
433+ }
434+ } ) . catch ( e => {
435+ state . inError = true ;
436+ state . lastErrorMessage = "Error deleting folder reference details." ;
437+ } ) ;
438+ } ,
439+ deleteResourceReferenceDetails ( context : ActionContext < State , State > ) {
417440 state . inError = false ;
418441 state . updatedNode = null ;
419- contentStructureData . deleteFolderReference ( state . editingTreeNode . hierarchyEditDetailId ) . then ( async response => {
442+ contentStructureData . deleteResourceReferenceDetails ( state . editingTreeNode . hierarchyEditDetailId ) . then ( async response => {
420443 if ( response . isValid ) {
421444 var parent = state . editingTreeNode . parent ;
422445 await refreshNodeContents ( parent , false ) ;
446+ await refreshNodeIfMatchingNodeId ( state . rootNode , state . editingTreeNode . nodeId , state . editingTreeNode . hierarchyEditDetailId , true ) ;
423447 state . updatedNode = parent ;
424448 context . commit ( "setEditMode" , EditModeEnum . Structure ) ;
425449 }
@@ -429,7 +453,7 @@ const actions = <ActionTree<State, any>>{
429453 }
430454 } ) . catch ( e => {
431455 state . inError = true ;
432- state . lastErrorMessage = "Error deleting folder reference." ;
456+ state . lastErrorMessage = "Error deleting resource reference details ." ;
433457 } ) ;
434458 } ,
435459 async moveNodeUp ( context : ActionContext < State , State > , payload : { node : NodeContentAdminModel } ) {
@@ -457,6 +481,7 @@ const actions = <ActionTree<State, any>>{
457481 await refreshNodeContents ( payload . destinationNode , true ) . then ( async x => {
458482 await refreshNodeContents ( state . editingTreeNode . parent , true ) . then ( y => {
459483 } ) ;
484+ refreshHierarchyEdit ( state ) ;
460485 state . rootNode . children . forEach ( async ( child ) => {
461486 if ( child . nodeId != null ) {
462487 await refreshNodeContents ( child , false ) ;
@@ -514,6 +539,7 @@ const actions = <ActionTree<State, any>>{
514539 state . inError = false ;
515540 contentStructureData . removeReferenceNode ( payload . node . hierarchyEditDetailId ) . then ( async response => {
516541 await refreshNodeContents ( payload . node . parent , false ) ;
542+ await refreshNodeIfMatchingNodeId ( state . rootNode , payload . node . nodeId , payload . node . hierarchyEditDetailId , true ) ;
517543 if ( payload . node . parent . parent != null ) {
518544 await refreshNodeContents ( payload . node . parent . parent , false ) ;
519545 }
@@ -527,7 +553,8 @@ const actions = <ActionTree<State, any>>{
527553 await refreshNodeContents ( state . referencingResource . parent , true ) . then ( async x => {
528554 await refreshNodeContents ( payload . destinationNode , true ) ;
529555 } ) ;
530-
556+ state . editingTreeNode . parent . childrenLoaded = false ;
557+ await refreshNodeContents ( state . editingTreeNode . parent , true ) ;
531558 context . commit ( "setEditMode" , EditModeEnum . Structure ) ;
532559 } ) . catch ( e => {
533560 state . inError = true ;
@@ -562,6 +589,7 @@ const actions = <ActionTree<State, any>>{
562589 contentStructureData . updateNodePathDisplayVersion ( state . editingFolderNodeReference ) . then ( async response => {
563590 state . editingFolderNodeReference . nodePathDisplayVersionId = response . createdId ;
564591 await refreshNodeContents ( state . editingTreeNode . parent , false ) ;
592+ await refreshNodeIfMatchingNodeId ( state . rootNode , state . editingTreeNode . nodeId , state . editingTreeNode . hierarchyEditDetailId , true ) ;
565593 } ) . catch ( e => {
566594 state . inError = true ;
567595 state . lastErrorMessage = "Error creating folder reference." ;
@@ -572,9 +600,10 @@ const actions = <ActionTree<State, any>>{
572600 contentStructureData . updateResourceReferenceDisplayVersion ( state . editingResourceNodeReference ) . then ( async response => {
573601 state . editingResourceNodeReference . resourceReferenceDisplayVersionId = response . createdId ;
574602 await refreshNodeContents ( state . editingTreeNode . parent , false ) ;
603+ await refreshNodeIfMatchingNodeId ( state . rootNode , state . editingTreeNode . nodeId , state . editingTreeNode . hierarchyEditDetailId , true ) ;
575604 } ) . catch ( e => {
576605 state . inError = true ;
577- state . lastErrorMessage = "Error creating folder reference." ;
606+ state . lastErrorMessage = "Error creating resource reference." ;
578607 } ) ;
579608 context . commit ( "setEditMode" , EditModeEnum . Structure ) ;
580609 } ,
0 commit comments