add edit button to protocol preview modal

This commit is contained in:
Mojca Lorber 2017-01-03 10:04:14 +01:00
parent 40e3240a99
commit e555535dfb
5 changed files with 12 additions and 4 deletions

View file

@ -201,8 +201,10 @@ function initProtocolPreviewModal() {
var modal = $("#protocol-preview-modal"); var modal = $("#protocol-preview-modal");
var modalTitle = modal.find(".modal-title"); var modalTitle = modal.find(".modal-title");
var modalBody = modal.find(".modal-body"); var modalBody = modal.find(".modal-body");
var modalFooter = modal.find(".modal-footer");
modalTitle.html(data.title); modalTitle.html(data.title);
modalBody.html(data.html); modalBody.html(data.html);
modalFooter.html(data.footer);
modal.modal("show"); modal.modal("show");
initHandsOnTable($(document)); initHandsOnTable($(document));
}, },

View file

@ -91,6 +91,10 @@ class ProtocolsController < ApplicationController
html: render_to_string( html: render_to_string(
partial: 'protocols/index/protocol_preview_modal_body.html.erb', partial: 'protocols/index/protocol_preview_modal_body.html.erb',
locals: { protocol: @protocol } locals: { protocol: @protocol }
),
footer: render_to_string(
partial: 'protocols/index/protocol_preview_modal_footer.html.erb',
locals: { protocol: @protocol }
) )
} }
end end

View file

@ -95,7 +95,7 @@ class ProtocolsDatatable < AjaxDatatablesRails::Base
"DT_CanArchive": can_archive_protocol(protocol), "DT_CanArchive": can_archive_protocol(protocol),
"DT_CanRestore": can_restore_protocol(protocol), "DT_CanRestore": can_restore_protocol(protocol),
"DT_CanExport": can_export_protocol(protocol), "DT_CanExport": can_export_protocol(protocol),
"1": name_html(record), "1": protocol.in_repository_archived? ? record.name : name_html(record),
"2": keywords_html(record), "2": keywords_html(record),
"3": modules_html(record), "3": modules_html(record),
"4": record.full_username_str, "4": record.full_username_str,

View file

@ -7,9 +7,7 @@
</h2> </h2>
</div> </div>
<div class="modal-body"></div> <div class="modal-body"></div>
<div class="modal-footer"> <div class="modal-footer"></div>
<button type="button" class="btn btn-default" data-dismiss="modal"><%=t "general.close" %></button>
</div>
</div> </div>
</div> </div>
</div> </div>

View file

@ -0,0 +1,4 @@
<button type="button" class="btn btn-default" data-dismiss="modal"><%=t "general.close" %></button>
<% if can_edit_protocol(@protocol) %>
<%= link_to t("general.edit"), edit_protocol_path(@protocol), :class => "btn btn-primary" %>
<% end %>