[Kimchi-devel] [PATCH 4/4] Implement UI Part to Properly Handle Report Name Existence

Wen Wang wenwang at linux.vnet.ibm.com
Thu Jun 12 10:12:30 UTC 2014


I encountered 2 issues:

1) After generating a debug report, the generate button is disabled
2) Act in this order: click generate button -> type in one debug report 
name that exsits
     in the grid -> After the error warning, close the window: generate 
button is disabled

On 06/12/2014 03:09 PM, Hongliang Wang wrote:
> If user provides an existing report name, then tell the error and show
> generate report window to allow the user to enter a new name.
>
> Signed-off-by: Hongliang Wang <hlwang at linux.vnet.ibm.com>
> ---
>   ui/js/src/kimchi.report_add_main.js | 28 ++++++++++++++++++----------
>   1 file changed, 18 insertions(+), 10 deletions(-)
>
> diff --git a/ui/js/src/kimchi.report_add_main.js b/ui/js/src/kimchi.report_add_main.js
> index 28c3e66..bc011ba 100644
> --- a/ui/js/src/kimchi.report_add_main.js
> +++ b/ui/js/src/kimchi.report_add_main.js
> @@ -20,6 +20,14 @@ kimchi.report_add_main = function() {
>       var addReportForm = $('#form-report-add');
>       var submitButton = $('#button-report-add');
>       var nameTextbox = $('input[name="name"]', addReportForm);
> +    kimchi._reportName && nameTextbox.val(kimchi._reportName).select();
> +
> +    var disableToolbarButtons = function() {
> +        $('#' + reportGridID + '-generate-button').prop('disabled',true);
> +        $('#' + reportGridID + '-remove-button').prop('disabled',true);
> +        $('#' + reportGridID + '-download-button').prop('disabled',true);
> +        $('#' + reportGridID + '-rename-button').prop('disabled',true);
> +    };
>       var submitForm = function(event) {
>           if(submitButton.prop('disabled')) {
>               return false;
> @@ -32,15 +40,8 @@ kimchi.report_add_main = function() {
>           }
>           var formData = addReportForm.serializeObject();
>           kimchi.window.close();
> -        $('#' + reportGridID + '-generate-button').prop('disabled',true);
> -        $('#' + reportGridID + '-remove-button').prop('disabled',true);
> -        $('#' + reportGridID + '-download-button').prop('disabled',true);
> -        $('#' + reportGridID + '-rename-button').prop('disabled',true);
> -        $('.grid-body table tr', '#' + reportGridID).click(function() {
> -            $('#' + reportGridID + '-remove-button').prop('disabled',true);
> -            $('#' + reportGridID + '-download-button').prop('disabled',true);
> -            $('#' + reportGridID + '-rename-button').prop('disabled',true);
> -        });
> +        disableToolbarButtons();
> +        $('.grid-body table tr', '#' + reportGridID).on('click', disableToolbarButtons);
>           var textboxValue = $('#report-name-textbox').val();
>           if (textboxValue != "") {
>               $('.grid-body-view table', '#' + reportGridID).prepend(
> @@ -68,10 +69,13 @@ kimchi.report_add_main = function() {
>           }
>           kimchi.createReport(formData, function(result) {
>               $('.grid-body-view table tr:first-child', '#' + reportGridID).remove();
> -            $('#' + reportGridID + '-generate-button').prop('disabled',false);
> +            $('.grid-body table tr', '#' + reportGridID)
> +                .off('click', disableToolbarButtons);
>               kimchi.topic('kimchi/debugReportAdded').publish({
>                   result: result
>               });
> +            kimchi._reportName = null;
> +            delete kimchi._reportName;
>           }, function(result) {
>               // Error message from Async Task status
>               if (result['message']) {
> @@ -83,6 +87,10 @@ kimchi.report_add_main = function() {
>               }
>               result && kimchi.message.error(errText)
>               $('.grid-body-view table tr:first-child', '#' + reportGridID).remove();
> +            $('.grid-body table tr', '#' + reportGridID)
> +                .off('click', disableToolbarButtons);
> +            kimchi._reportName = reportName;
> +            $('#' + reportGridID + '-generate-button').click();
>           });
>
>           event.preventDefault();




More information about the Kimchi-devel mailing list