diff options
author | Marc Delisle <marc@infomarc.info> | 2014-03-15 15:16:23 +0400 |
---|---|---|
committer | Marc Delisle <marc@infomarc.info> | 2014-03-15 15:16:23 +0400 |
commit | 9b0ec2aaafe7b5e0774dfa4ec46ccabbf6d20103 (patch) | |
tree | 22d0a1f403a1da79d0765ad35d46236da469ae01 /js | |
parent | 889555e38d52f6c58deaa34250b774fbd5fc66bf (diff) | |
parent | 2943a514b9e286daf1ed6aaeb8c9e5454942514e (diff) |
Merge pull request #1066 from ashutoshdhundhara/feature-#1512
Feature request: #1512 Import doesn't do anything with no file name provided.
Diffstat (limited to 'js')
-rw-r--r-- | js/import.js | 51 | ||||
-rw-r--r-- | js/messages.php | 2 |
2 files changed, 53 insertions, 0 deletions
diff --git a/js/import.js b/js/import.js index e97af14c49..5b00f44bf6 100644 --- a/js/import.js +++ b/js/import.js @@ -57,6 +57,57 @@ AJAX.registerTeardown('import.js', function () { }); AJAX.registerOnload('import.js', function () { + // import_file_form validation. + $('#import_file_form').live('submit', function (event) { + var radioLocalImport = $("#radio_local_import_file"); + var radioImport = $("#radio_import_file"); + var fileMsg = '<div class="error"><img src="themes/dot.gif" title="" alt="" class="icon ic_s_error" /> ' + PMA_messages.strImportDialogMessage + '</div>'; + + if (radioLocalImport.length !== 0) { + // remote upload. + // TODO Remove this section when all browsers support HTML5 "required" property + if (! radioLocalImport.is(":checked") && ! radioImport.is(":checked")) { + radioImport.focus(); + var msg = '<div class="error"><img src="themes/dot.gif" title="" alt="" class="icon ic_s_error" /> '; + msg += PMA_messages.strRadioUnchecked; + msg += '</div>'; + PMA_ajaxShowMessage(msg, false); + return false; + } + + if (radioImport.is(":checked") && $("#input_import_file").val() === '') { + $("#input_import_file").focus(); + PMA_ajaxShowMessage(fileMsg, false); + return false; + } + + if (radioLocalImport.is(":checked")) { + if ($("#select_local_import_file").length === 0) { + PMA_ajaxShowMessage('<div class="error"><img src="themes/dot.gif" title="" alt="" class="icon ic_s_error" /> ' + PMA_messages.strNoImportFile + ' </div>', false); + return false; + } + + if ($("#select_local_import_file").val() === '') { + $("#select_local_import_file").focus(); + PMA_ajaxShowMessage(fileMsg, false); + return false; + } + } + } else { + // local upload. + if ($("#input_import_file").val() === '') { + $("#input_import_file").focus(); + PMA_ajaxShowMessage(fileMsg, false); + return false; + } + } + + // show progress bar. + $("#upload_form_status").css("display", "inline"); + $("#upload_form_status_info").css("display", "inline"); + return; + }); + // Initially display the options for the selected plugin changePluginOpts(); diff --git a/js/messages.php b/js/messages.php index 502a64abf9..d210c56e85 100644 --- a/js/messages.php +++ b/js/messages.php @@ -46,6 +46,7 @@ $js_messages['strConfirmDeleteQBESearch'] = __('Do you really want to delete the /* For indexes */ $js_messages['strFormEmpty'] = __('Missing value in the form!'); +$js_messages['strRadioUnchecked'] = __('Select at least one of the options!'); $js_messages['strEnterValidNumber'] = __('Please enter a valid number!'); $js_messages['strEnterValidLength'] = __('Please enter a valid length!'); $js_messages['strAddIndex'] = __('Add Index'); @@ -201,6 +202,7 @@ $js_messages['strFailedBuildingGrid'] = __('Failed building chart grid with impo $js_messages['strImport'] = __('Import'); $js_messages['strImportDialogTitle'] = __('Import monitor configuration'); $js_messages['strImportDialogMessage'] = __('Please select the file you want to import.'); +$js_messages['strNoImportFile'] = __('No files available on server for import!'); $js_messages['strAnalyzeQuery'] = __('Analyse Query'); |