Add default delete modal usage:

- <%= render 'layouts/delete_modal', delete_options: {title: '', warning: '', cancel: '', submit: '' } %>
 - in default index, just set title, warning, cancel and submit in quick_edit if needed
This commit is contained in:
chris 2013-07-29 14:29:37 +08:00
parent b3cdffb59e
commit d434b878a7
8 changed files with 33 additions and 32 deletions

View File

@ -466,6 +466,15 @@ if($.support.touch) {
}(window.jQuery);
var ini = function() {
api = this
api.modal = function(e) {
$('#dialog a.delete-item').attr("href", e);
$('#dialog').modal('show');
}
}
// Open Slide
function openSlide() {
var $openSlide = $('.open-slide'),
@ -521,6 +530,10 @@ function changeStatusHidden() {
// Document Ready
$(function() {
new ini();
$('.delete').on('click', function() {
api.modal($(this).attr('rel'));
})
initialState();
$('#login').on('shown', function () {
$(document.body).addClass('modalBlur');

View File

@ -289,7 +289,8 @@ module OrbitBackendHelper
end
when 'delete'
if show_delete_link(object)
content_tag :li, link_to(t(quick[:translation] || :delete_), '#', rel: eval("#{quick[:link]}('#{object.id}')"), class: "delete_link #{quick[:class] || 'text-error'}")
@delete_options = {title: quick[:title], warning: quick[:warning], cancel: quick[:cancel], submit: quick[:submit]}
content_tag :li, link_to(t(quick[:translation] || :delete_), '#', rel: eval("#{quick[:link]}('#{object.id}')"), class: "delete #{quick[:class] || 'text-error'}")
end
when 'detail'
content_tag :li, link_to(t(quick[:translation] || :detail), '#', class: (quick[:class] || "detail-row"))

View File

@ -37,20 +37,4 @@
<%= @index_footer %>
<div id="delete_tags" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel"><%= t('tag.delete') %></h3>
</div>
<div class="modal-body tags">
<span class="text-warning text-center"><%= t('tag.warning.delete') %></span>
<hr>
<ul class="tags-groups checkbox-card">
</ul>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<%= link_to t(:delete_), nil, class: "delete-tags btn btn-danger", method: :post, remote: true %>
</div>
</div>
<%= render 'layouts/delete_modal', delete_options: @delete_options %>

View File

@ -4,19 +4,7 @@
<%= render 'node_and_children', node: node %>
</ol>
<div id="dialog" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="Delete item" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3>Delete item</h3>
</div>
<div class="modal-body">
<span class="text-warning text-center">This action can not be restored, are you sure you want to delete?</span>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<%= link_to t(:delete_), nil, class: "delete-item btn btn-danger", method: :delete, remote: true %>
</div>
</div>
<%= render 'layouts/delete_modal' %>
<div id="view-page" class="nano" style="display:none">
<div class="page-info clearfix">

View File

@ -10,7 +10,7 @@
</ul>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn" data-dismiss="modal" aria-hidden="true"><%= t(:close) %></button>
<%= link_to t(:delete_), nil, class: "delete-tags btn btn-danger", method: :post, remote: true %>
</div>
</div>

View File

@ -0,0 +1,13 @@
<div id="dialog" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="delete_modal" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3><%= (delete_options[:title] rescue nil) || t(:delete_) %></h3>
</div>
<div class="modal-body">
<span class="text-warning text-center"><%= (delete_options[:warning] rescue nil) || t(:delete_warning) %></span>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true"><%= (delete_options[:cancel] rescue nil) || t(:close) %></button>
<%= link_to ((delete_options[:submit] rescue nil) || t(:delete_)), nil, class: "delete-item btn btn-danger", method: :delete %>
</div>
</div>

View File

@ -12,6 +12,7 @@ en:
error:
category: Error when creating category
tag: Error when creating tag
delete_warning: This action can not be restored, are you sure you want to delete?
deselect_all: Deselect all
detail: Detail
edit_category: Edit Categorie

View File

@ -5,6 +5,7 @@
quick_edit_link type: 'detail'
quick_edit_link type: 'delete',
link: 'panel_announcement_back_end_bulletin_path'
# can have: title, warning, cancel and submit values
quick_edit_link type: 'approval',
link: 'panel_announcement_back_end_bulletin_approval_preview_path'
quick_edit_link type: 'reject_reason'