From: Jan Provaznik <[email protected]>
---
.../image_factory/templates_controller.rb | 7 +++++
src/app/views/image_factory/templates/_list.haml | 25 +++++++++++++------
src/config/routes.rb | 2 +-
3 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/src/app/controllers/image_factory/templates_controller.rb
b/src/app/controllers/image_factory/templates_controller.rb
index 3f18764..0323f62 100644
--- a/src/app/controllers/image_factory/templates_controller.rb
+++ b/src/app/controllers/image_factory/templates_controller.rb
@@ -163,6 +163,13 @@ class ImageFactory::TemplatesController <
ApplicationController
render :action => @tpl.id ? :edit : :new
end
+ def multi_destroy
+ # FIXME: set correct check permission when we will have it
+ require_privilege(Privilege::IMAGE_MODIFY)
+ Template.destroy(params[:selected])
+ redirect_to image_factory_templates_url
+ end
+
protected
def load_images(tpl)
diff --git a/src/app/views/image_factory/templates/_list.haml
b/src/app/views/image_factory/templates/_list.haml
index 4e0d058..3980b06 100644
--- a/src/app/views/image_factory/templates/_list.haml
+++ b/src/app/views/image_factory/templates/_list.haml
@@ -1,12 +1,8 @@
- form_tag do
- /= submit_tag "Edit", :name => "edit", :class => "icon"
- /= submit_tag "Delete", :name => "delete", :class => "icon"
- /= submit_tag "Rename", :name => "rename", :disabled => true, :class =>
"icon"
- /= submit_tag "Copy", :name => "copy", :disabled => true, :class => "icon"
= restful_submit_tag "Create", "new_template",
new_image_factory_template_path, 'GET'
- /= restful_submit_tag "Build", "build", 'GET'
+ = restful_submit_tag "Delete", 'destroy',
multi_destroy_image_factory_templates_path, 'DELETE', :id => 'delete_button'
- %table
+ %table#templates_table
= sortable_table_header @header
%tbody
- if @templates.empty?
@@ -16,11 +12,24 @@
- @templates.each do |template|
%tr
%td
- - selected = @url_params[:select] == 'all'
- = check_box(:template, "selected[#{template.id}]", :checked =>
selected)
+ = check_box_tag 'selected[]', template.id, @url_params[:select]
== 'all'
= image_tag "blnk.png", :alt => template.platform, :class =>
"icon platform #{template.platform}"
= link_to template.name, image_factory_template_path(template)
%td= template.platform
%td= template.platform_version
%td= image_tag 'blnk.png', :alt => 'yes', :class => "icon yes"
%td= template.architecture
+
+:javascript
+ $(document).ready(function () {
+ $('#delete_button').click(function(e) {
+ if ($("#templates_table inp...@type=radio]:checked").length == 0) {
+ alert('Please select any template to be deleted before clicking Delete
button.');
+ e.preventDefault();
+ } else {
+ if (!confirm("Are you sure you want to delete this template?")) {
+ e.preventDefault();
+ }
+ }
+ });
+ });
diff --git a/src/config/routes.rb b/src/config/routes.rb
index 5e6d3c0..31454df 100644
--- a/src/config/routes.rb
+++ b/src/config/routes.rb
@@ -39,7 +39,7 @@ ActionController::Routing::Routes.draw do |map|
map.namespace 'image_factory' do |r|
r.resources :assemblies, :deployables
- r.resources :templates, :collection => {:collections => :get,
:add_selected => :get, :metagroup_packages => :get, :remove_package => :get}
+ r.resources :templates, :collection => {:collections => :get,
:add_selected => :get, :metagroup_packages => :get, :remove_package => :get,
:multi_destroy => :delete}
r.resources :builds
end
--
1.7.2.3
_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel