app/views/headmin/table/actions/_action.html.erb in headmin-0.1.2 vs app/views/headmin/table/actions/_action.html.erb in headmin-0.2.0

- old
+ new

@@ -1,10 +1,27 @@ -<%# - name: headmin/table/actions/action - accepts block: no - parameters: - path: (string) url to send request to - method: (string) HTTP method for the request +<% + # headmin/table/actions/action + # + # ==== Options + # * <tt>name</tt> - Name of the bulk action + # * <tt>url</tt> - URL to send the request to + # * <tt>method</tt> - HTTP method for the request (defaults to GET) + # * <tt>confirm</tt> - Message to show in a confirm dialog. Leave blank if no confirm dialog needs to be shown + # + # ==== Examples + # Basic version. + # <%= render "headmin/table/actions/action", name: 'export', url: export_admin_products_path %#> + # + # Use a different HTTP method + # <%= render "headmin/table/actions/action", name: 'export', url: export_admin_products_path, method: :post %#> + # + # Show a confirm dialog before submitting. + # <%= render "headmin/table/actions/action", name: 'delete', url: destroy_admin_products_path, confirm: 'Are you sure you want to delete these products?' %#> + + url = local_assigns.has_key?(:url) ? local_assigns[:url] : request.path + method = local_assigns.has_key?(:method) ? local_assigns[:method] : 'GET' + confirm = local_assigns.has_key?(:confirm) ? local_assigns[:confirm] : nil %> -<% path = local_assigns.has_key?(:url) ? local_assigns[:url] : request.path %> -<% method = local_assigns.has_key?(:method) ? local_assigns[:method] : 'GET' %> -<option value="<%= path %>" data-method="<%= method %>"><%= name %></option> + +<option value="<%= url %>" data-method="<%= method %>" <% if confirm %>data-confirm="<%= confirm %>"<%end %>> + <%= name %> +</option>