On 06/10/2011 01:01 PM, jtomasek(a)redhat.com wrote:
From: Jiri Tomasek<jtomasek(a)redhat.com>
Adds method to application.js which validates multi_destroy
---
src/app/views/hardware_profiles/_list.haml | 2 +-
src/app/views/pool_families/_list.haml | 2 +-
src/app/views/provider_accounts/_list.haml | 2 +-
src/app/views/providers/_list.haml | 2 +-
src/app/views/realms/_list.haml | 2 +-
src/app/views/roles/_list.haml | 2 +-
src/app/views/users/_list.haml | 16 +---------------
src/public/javascripts/application.js | 15 +++++++++++++++
8 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/src/app/views/hardware_profiles/_list.haml
b/src/app/views/hardware_profiles/_list.haml
index 1733cef..21fea2f 100644
--- a/src/app/views/hardware_profiles/_list.haml
+++ b/src/app/views/hardware_profiles/_list.haml
@@ -12,7 +12,7 @@
%span> ,
= link_to "None", @url_params.merge(:select => 'none')
- %table#hardware_profiles_table
+ %table#hardware_profiles_table.checkbox_table
%thead
%tr
%th.ignore
diff --git a/src/app/views/pool_families/_list.haml
b/src/app/views/pool_families/_list.haml
index 505dcf0..bda57b3 100644
--- a/src/app/views/pool_families/_list.haml
+++ b/src/app/views/pool_families/_list.haml
@@ -13,7 +13,7 @@
%span> ,
= link_to "None", @url_params.merge(:select => 'none')
- %table#pool_families_table
+ %table#pool_families_table.checkbox_table
%thead
%tr
%th.ignore
diff --git a/src/app/views/provider_accounts/_list.haml
b/src/app/views/provider_accounts/_list.haml
index ec913a0..045bb04 100644
--- a/src/app/views/provider_accounts/_list.haml
+++ b/src/app/views/provider_accounts/_list.haml
@@ -12,7 +12,7 @@
%span> ,
= link_to "None", @url_params.merge(:select => 'none')
- %table#provider_accounts_table
+ %table#provider_accounts_table.checkbox_table
%thead
%tr
%th.ignore
diff --git a/src/app/views/providers/_list.haml b/src/app/views/providers/_list.haml
index 01bea5a..90aafd9 100644
--- a/src/app/views/providers/_list.haml
+++ b/src/app/views/providers/_list.haml
@@ -13,7 +13,7 @@
%span> ,
= link_to "None", @url_params.merge(:select => 'none')
- %table#providers_table
+ %table#providers_table.checkbox_table
%thead
%tr
%th.ignore
diff --git a/src/app/views/realms/_list.haml b/src/app/views/realms/_list.haml
index 5617811..fae6021 100644
--- a/src/app/views/realms/_list.haml
+++ b/src/app/views/realms/_list.haml
@@ -13,7 +13,7 @@
%span> ,
= link_to "None", @url_params.merge(:select => 'none')
- %table#realms_table
+ %table#realms_table.checkbox_table
%thead
%tr
%th.ignore
diff --git a/src/app/views/roles/_list.haml b/src/app/views/roles/_list.haml
index dba11a6..6d08325 100644
--- a/src/app/views/roles/_list.haml
+++ b/src/app/views/roles/_list.haml
@@ -12,7 +12,7 @@
%span> ,
= link_to "None", @url_params.merge(:select => 'none')
- %table#roles_table
+ %table#roles_table.checkbox_table
%thead
%tr
%th.ignore
diff --git a/src/app/views/users/_list.haml b/src/app/views/users/_list.haml
index 81120a5..9f54918 100644
--- a/src/app/views/users/_list.haml
+++ b/src/app/views/users/_list.haml
@@ -7,7 +7,7 @@
- form_tag multi_destroy_users_path do
= submit_tag "Delete", :id => 'delete_button', :class =>
'button danger'
- %table#users_table
+ %table#users_table.checkbox_table
%thead
%tr
%th.ignore
@@ -29,17 +29,3 @@
%td= sprintf("%.2f", user.quota.percentage_used)
%td= Quota.no_limit(user.quota.maximum_running_instances) ?
"Unlimited" : user.quota.maximum_running_instances
%td= user.email
-
-:javascript
- $(document).ready(function () {
- $('#delete_button').click(function(e) {
- if ($("#users_table input[@type=radio]:checked").length == 0) {
- alert('Please select any user to be deleted before clicking Delete
button.');
- e.preventDefault();
- } else {
- if (!confirm("Are you sure you want to delete this user?")) {
- e.preventDefault();
- }
- }
- });
- });
diff --git a/src/public/javascripts/application.js
b/src/public/javascripts/application.js
index 3e5aac0..3ec73b3 100644
--- a/src/public/javascripts/application.js
+++ b/src/public/javascripts/application.js
@@ -109,6 +109,20 @@ var Conductor = {
acceptsSettings.html = "text/javascript, application/javascript,
application/ecmascript, application/x-ecmascript"
$.ajaxSetup({accepts: acceptsSettings, dataType: 'html'})
},
+
+ multiDestroyValidation: function() {
+ $('#delete_button').click(function(e) {
+ if ($(".checkbox_table input[@type=radio]:checked").length == 0) {
+ alert('Please make a selection before clicking Delete button.');
+ e.preventDefault();
+ } else {
+ if (!confirm("Are you sure you want to proceed with deletion?")) {
+ e.preventDefault();
+ }
+ }
+ });
+ }
+
};
/* custom methods */
@@ -200,4 +214,5 @@ $(document).ready(function () {
Conductor.enhanceListView();
Conductor.enhanceDetailsTabs();
Conductor.bind_pretty_toggle();
+ Conductor.multiDestroyValidation();
});
ACK, but i don't have push permissions...