Changed rescan of entire project on filemanager action to rescan parent path on filemanager action

This commit is contained in:
xevidos 2019-06-21 09:27:25 -04:00
parent deb686a60c
commit eab18d9f60

View File

@ -364,11 +364,14 @@
node.removeClass( 'open' ); node.removeClass( 'open' );
}); });
} else { } else {
node.addClass( 'loading' ); node.addClass( 'loading' );
$.get( this.controller + '?action=index&path=' + encodeURIComponent( path ), function( data ) { $.get( this.controller + '?action=index&path=' + encodeURIComponent( path ), function( data ) {
node.addClass( 'open' ); node.addClass( 'open' );
var objectsResponse = codiad.jsend.parse( data ); var objectsResponse = codiad.jsend.parse( data );
if( objectsResponse != 'error' ) { if( objectsResponse != 'error' ) {
/* Notify listener */ /* Notify listener */
_this.indexFiles = objectsResponse.index; _this.indexFiles = objectsResponse.index;
amplify.publish( "filemanager.onIndex", { amplify.publish( "filemanager.onIndex", {
@ -377,31 +380,38 @@
}); });
var files = _this.indexFiles; var files = _this.indexFiles;
if( files.length > 0 ) { if( files.length > 0 ) {
if( node.parent().children( 'span' ).hasClass( 'plus' ) ) { if( node.parent().children( 'span' ).hasClass( 'plus' ) ) {
node.parent().children( 'span' ).removeClass( 'plus' ).addClass( 'minus' ); node.parent().children( 'span' ).removeClass( 'plus' ).addClass( 'minus' );
} }
var display = 'display:none;'; var display = 'display:none;';
if( rescan ) { if( rescan ) {
display = ''; display = '';
} }
var appendage = '<ul style="' + display + '">'; var appendage = '<ul style="' + display + '">';
$.each( files, function( index ) { $.each( files, function( index ) {
var ext = ''; var ext = '';
var name = files[index].name.replace( path, '' ); var name = files[index].name.replace( path, '' );
var nodeClass = 'none'; var nodeClass = 'none';
name = name.split( '/' ) name = name.split( '/' )
.join( ' ' ); .join( ' ' );
if( files[index].type == 'file' ) { if( files[index].type == 'file' ) {
var ext = ' ext-' + name.split( '.' ) var ext = ' ext-' + name.split( '.' )
.pop(); .pop();
} }
if( files[index].type == 'directory' && files[index].size > 0 ) { if( files[index].type == 'directory' && files[index].size > 0 ) {
nodeClass = 'plus'; nodeClass = 'plus';
} }
appendage += '<li><span class="' + nodeClass + '"></span><a class="' + files[index].type + ext + '" data-type="' + files[index].type + '" data-path="' + files[index].name + '">' + name + '</a></li>'; appendage += '<li><span class="' + nodeClass + '"></span><a class="' + files[index].type + ext + '" data-type="' + files[index].type + '" data-path="' + files[index].name + '">' + name + '</a></li>';
}); });
appendage += '</ul>'; appendage += '</ul>';
if( rescan ) { if( rescan ) {
node.parent( 'li' ) node.parent( 'li' )
.children( 'ul' ) .children( 'ul' )
.remove(); .remove();
@ -409,6 +419,7 @@
$( appendage ) $( appendage )
.insertAfter( node ); .insertAfter( node );
if( !rescan ) { if( !rescan ) {
node.siblings( 'ul' ) node.siblings( 'ul' )
.slideDown( 300 ); .slideDown( 300 );
} }
@ -416,8 +427,10 @@
} }
node.removeClass( 'loading' ); node.removeClass( 'loading' );
if( rescan && _this.rescanChildren.length > _this.rescanCounter ) { if( rescan && _this.rescanChildren.length > _this.rescanCounter ) {
_this.rescan( _this.rescanChildren[_this.rescanCounter++] ); _this.rescan( _this.rescanChildren[_this.rescanCounter++] );
} else { } else {
_this.rescanChildren = []; _this.rescanChildren = [];
_this.rescanCounter = 0; _this.rescanCounter = 0;
} }
@ -650,7 +663,6 @@
}); });
$( '#modal-content form' ) $( '#modal-content form' )
.live( 'submit', function( e ) { .live( 'submit', function( e ) {
let project = codiad.project.getCurrent();
e.preventDefault(); e.preventDefault();
var shortName = $( '#modal-content form input[name="object_name"]' ) var shortName = $( '#modal-content form input[name="object_name"]' )
.val(); .val();
@ -671,7 +683,7 @@
codiad.filemanager.openFile( createPath, true ); codiad.filemanager.openFile( createPath, true );
} }
codiad.filemanager.rescan( project ); codiad.filemanager.rescan( path );
/* Notify listeners. */ /* Notify listeners. */
amplify.publish( 'filemanager.onCreate', { amplify.publish( 'filemanager.onCreate', {
@ -815,7 +827,10 @@
// Change any active files // Change any active files
codiad.active.rename( path, newPath ); codiad.active.rename( path, newPath );
codiad.modal.unload(); codiad.modal.unload();
codiad.filemanager.rescan( project );
let parent = path.split( '/' );
parent.pop();
codiad.filemanager.rescan( parent.join( '/' ) );
/* Notify listeners. */ /* Notify listeners. */
amplify.publish( 'filemanager.onRename', { amplify.publish( 'filemanager.onRename', {
path: path, path: path,