[PATCH conductor] BZ790833 Added confirmation to stopping deployment and stopping and restarting instances

Tomas Sedovic tsedovic at redhat.com
Mon Feb 20 13:10:27 UTC 2012


On 02/20/2012 02:02 PM, jtomasek at redhat.com wrote:
> From: Jiri Tomasek<jtomasek at redhat.com>
>
> ---
>   src/public/javascripts/application.js |   28 ++++++++++++++++++++++++++++
>   1 files changed, 28 insertions(+), 0 deletions(-)
>
> diff --git a/src/public/javascripts/application.js b/src/public/javascripts/application.js
> index 3d76c90..22439bb 100644
> --- a/src/public/javascripts/application.js
> +++ b/src/public/javascripts/application.js
> @@ -143,6 +143,32 @@ $.extend(Conductor, {
>       });
>     },
>
> +  multiStopValidation: function() {
> +    $('#stop_button, #stop_selected_instances').live('click', function(e) {
> +      if ($(".checkbox_table input[@type=radio]:checked").length == 0) {
> +        alert('Please make a selection before clicking Stop button.');
> +        e.preventDefault();
> +      } else {
> +        if (!confirm("Are you sure you want to proceed?")) {
> +          e.preventDefault();
> +        }
> +      }
> +    });
> +  },
> +
> +  multiRebootValidation: function() {
> +    $('#reboot_selected_instances').live('click', function(e) {
> +      if ($(".checkbox_table input[@type=radio]:checked").length == 0) {
> +        alert('Please make a selection before clicking Reboot button.');
> +        e.preventDefault();
> +      } else {
> +        if (!confirm("Are you sure you want to proceed?")) {
> +          e.preventDefault();
> +        }
> +      }
> +    });
> +  },
> +
>     closeNotification: function() {
>       $('.control').click(function(e) {
>         e.preventDefault();
> @@ -378,6 +404,8 @@ $(document).ready(function () {
>     Conductor.bind_pretty_toggle();
>     Conductor.multiDestroyValidation();
>     Conductor.multiRevokeValidation();
> +  Conductor.multiStopValidation();
> +  Conductor.multiRebootValidation();
>     Conductor.closeNotification();
>     Conductor.toggleCollapsible();
>     Conductor.selectAllCheckboxes();

ACK. A small suggestion on the if/else blocks (in both functions):

Instead of nesting a second `if` block inside the `else` block, you can 
use `else if`:

      if ($(".checkbox_table input[@type=radio]:checked").length == 0) {
        alert('Please make a selection before clicking Reboot button.');
        e.preventDefault();
      }
      else if (!confirm("Are you sure you want to proceed?")) {
        e.preventDefault();
      }

I think it would read a bit better.



More information about the aeolus-devel mailing list