diff --git a/web/pgadmin/misc/file_manager/static/js/create_dialogue.js b/web/pgadmin/misc/file_manager/static/js/create_dialogue.js index 41c58f5c..fa08ea56 100644 --- a/web/pgadmin/misc/file_manager/static/js/create_dialogue.js +++ b/web/pgadmin/misc/file_manager/static/js/create_dialogue.js @@ -137,45 +137,51 @@ module.exports = Alertify.dialog('createModeDlg', function() { return permission; }, callback: function(closeEvent) { + closeEvent.cancel = false; if (closeEvent.button.text == gettext('Create')) { - var newFile = $('.storage_dialog #uploader .input-path').val(), - file_data = { - 'path': $('.currentpath').val(), - }, - innerbody, - ext = $('.allowed_file_types select').val(); + var act_variable = document.activeElement.id; + if(act_variable != 'refresh_list') { + var newFile = $('.storage_dialog #uploader .input-path').val(), + file_data = { + 'path': $('.currentpath').val(), + }, + innerbody, + ext = $('.allowed_file_types select').val(); - /* - Add the file extension if necessary, and if the file type selector - isn't set to "All Files". If there's no . at all in the path, or - there is a . already but it's not following the last /, AND the - extension isn't *, then we add the extension. - */ - if ((!newFile.includes('.') || - newFile.split('.').pop() != ext) && - ext != '*') { - newFile = newFile + '.' + ext; - $('.storage_dialog #uploader .input-path').val(newFile); - } + /* + Add the file extension if necessary, and if the file type selector + isn't set to "All Files". If there's no . at all in the path, or + there is a . already but it's not following the last /, AND the + extension isn't *, then we add the extension. + */ + if ((!newFile.includes('.') || + newFile.split('.').pop() != ext) && + ext != '*') { + newFile = newFile + '.' + ext; + $('.storage_dialog #uploader .input-path').val(newFile); + } - if (!this.check_permission(newFile)) { - closeEvent.cancel = true; - return; - } + if (!this.check_permission(newFile)) { + closeEvent.cancel = true; + return; + } - if (!_.isUndefined(newFile) && newFile !== '' && this.is_file_exist()) { - this.replace_file(); - this.$container.find('.replace_file').find('.btn_yes').trigger('focus'); - closeEvent.cancel = true; + if (!_.isUndefined(newFile) && newFile !== '' && this.is_file_exist()) { + this.replace_file(); + this.$container.find('.replace_file').find('.btn_yes').trigger('focus'); + closeEvent.cancel = true; + } else { + pgAdmin.Browser.Events.trigger('pgadmin-storage:finish_btn:create_file', newFile); + innerbody = $(this.elements.body).find('.storage_content'); + $(innerbody).find('*').off(); + innerbody.remove(); + removeTransId(this.trans_id); + } + + set_last_traversed_dir(file_data, this.trans_id); } else { - pgAdmin.Browser.Events.trigger('pgadmin-storage:finish_btn:create_file', newFile); - innerbody = $(this.elements.body).find('.storage_content'); - $(innerbody).find('*').off(); - innerbody.remove(); - removeTransId(this.trans_id); + closeEvent.cancel = true; } - - set_last_traversed_dir(file_data, this.trans_id); } else if (closeEvent.button.text == gettext('Cancel')) { innerbody = $(this.elements.body).find('.storage_content'); $(innerbody).find('*').off(); diff --git a/web/pgadmin/misc/file_manager/static/js/select_dialogue.js b/web/pgadmin/misc/file_manager/static/js/select_dialogue.js index b3123f91..d80f98b4 100644 --- a/web/pgadmin/misc/file_manager/static/js/select_dialogue.js +++ b/web/pgadmin/misc/file_manager/static/js/select_dialogue.js @@ -108,21 +108,26 @@ module.exports = Alertify.dialog('fileSelectionDlg', function() { }, callback: function(closeEvent) { var innerbody; - + closeEvent.cancel = false; if (closeEvent.button.text == gettext('Select')) { - var newFile = $('.storage_dialog #uploader .input-path').val(), - file_data = { - 'path': $('.currentpath').val(), - }; + var act_variable = document.activeElement.id; + if(act_variable !='refresh_list') { + var newFile = $('.storage_dialog #uploader .input-path').val(), + file_data = { + 'path': $('.currentpath').val(), + }; - pgAdmin.Browser.Events.trigger('pgadmin-storage:finish_btn:' + this.dialog_type, newFile); - innerbody = $(this.elements.body).find('.storage_content'); - $(innerbody).find('*').off(); - innerbody.remove(); - removeTransId(this.trans_id); - // Ajax call to store the last directory visited once user press select button + pgAdmin.Browser.Events.trigger('pgadmin-storage:finish_btn:' + this.dialog_type, newFile); + innerbody = $(this.elements.body).find('.storage_content'); + $(innerbody).find('*').off(); + innerbody.remove(); + removeTransId(this.trans_id); + // Ajax call to store the last directory visited once user press select button - set_last_traversed_dir(file_data, this.trans_id); + set_last_traversed_dir(file_data, this.trans_id); + } else { + closeEvent.cancel = true; + } } else if (closeEvent.button.text == gettext('Cancel')) { innerbody = $(this.elements.body).find('.storage_content'); $(innerbody).find('*').off(); diff --git a/web/pgadmin/misc/file_manager/static/js/utility.js b/web/pgadmin/misc/file_manager/static/js/utility.js index 59f67259..7e335ee8 100644 --- a/web/pgadmin/misc/file_manager/static/js/utility.js +++ b/web/pgadmin/misc/file_manager/static/js/utility.js @@ -1584,12 +1584,14 @@ define([ if (config.options.dialog_type == 'create_file') { var status = checkPermission(path); if (status) { - $('.file_manager').trigger('enter-key'); + //$('.file_manager').trigger('enter-key'); + $('.file_manager_ok').trigger('click'); } } else if (config.options.dialog_type == 'select_file') { var file_status = getFileInfo(path); if (file_status) { - $('.file_manager').trigger('enter-key'); + $('.file_manager_ok').trigger('click'); + //$('.file_manager').trigger('enter-key'); } } } diff --git a/web/pgadmin/misc/file_manager/templates/file_manager/index.html b/web/pgadmin/misc/file_manager/templates/file_manager/index.html index b914c444..6ceefa6d 100644 --- a/web/pgadmin/misc/file_manager/templates/file_manager/index.html +++ b/web/pgadmin/misc/file_manager/templates/file_manager/index.html @@ -25,7 +25,7 @@