From eab18d9f607f382ffe2e4ac5ccd32efed9a5b664 Mon Sep 17 00:00:00 2001 From: xevidos Date: Fri, 21 Jun 2019 09:27:25 -0400 Subject: [PATCH] Changed rescan of entire project on filemanager action to rescan parent path on filemanager action --- components/filemanager/init.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/components/filemanager/init.js b/components/filemanager/init.js index 42471b6..ef867a6 100755 --- a/components/filemanager/init.js +++ b/components/filemanager/init.js @@ -364,11 +364,14 @@ node.removeClass( 'open' ); }); } else { + node.addClass( 'loading' ); $.get( this.controller + '?action=index&path=' + encodeURIComponent( path ), function( data ) { + node.addClass( 'open' ); var objectsResponse = codiad.jsend.parse( data ); if( objectsResponse != 'error' ) { + /* Notify listener */ _this.indexFiles = objectsResponse.index; amplify.publish( "filemanager.onIndex", { @@ -377,31 +380,38 @@ }); var files = _this.indexFiles; if( files.length > 0 ) { + if( node.parent().children( 'span' ).hasClass( 'plus' ) ) { + node.parent().children( 'span' ).removeClass( 'plus' ).addClass( 'minus' ); } var display = 'display:none;'; if( rescan ) { + display = ''; } var appendage = ''; if( rescan ) { + node.parent( 'li' ) .children( 'ul' ) .remove(); @@ -409,6 +419,7 @@ $( appendage ) .insertAfter( node ); if( !rescan ) { + node.siblings( 'ul' ) .slideDown( 300 ); } @@ -416,8 +427,10 @@ } node.removeClass( 'loading' ); if( rescan && _this.rescanChildren.length > _this.rescanCounter ) { + _this.rescan( _this.rescanChildren[_this.rescanCounter++] ); } else { + _this.rescanChildren = []; _this.rescanCounter = 0; } @@ -650,7 +663,6 @@ }); $( '#modal-content form' ) .live( 'submit', function( e ) { - let project = codiad.project.getCurrent(); e.preventDefault(); var shortName = $( '#modal-content form input[name="object_name"]' ) .val(); @@ -671,7 +683,7 @@ codiad.filemanager.openFile( createPath, true ); } - codiad.filemanager.rescan( project ); + codiad.filemanager.rescan( path ); /* Notify listeners. */ amplify.publish( 'filemanager.onCreate', { @@ -815,7 +827,10 @@ // Change any active files codiad.active.rename( path, newPath ); codiad.modal.unload(); - codiad.filemanager.rescan( project ); + + let parent = path.split( '/' ); + parent.pop(); + codiad.filemanager.rescan( parent.join( '/' ) ); /* Notify listeners. */ amplify.publish( 'filemanager.onRename', { path: path,