scinote-web/app/views/steps/_step.html.erb

195 lines
9 KiB
Text
Raw Normal View History

2016-07-21 19:11:15 +08:00
<div class ="step <%= step.completed? ? "completed" : "not-completed" %>">
<div class="badge-num">
<span class="badge bg-primary size-digit-<%= (step.position + 1).to_s.length %>"><%= step.position + 1 %></span>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<div class="panel-options pull-right">
<% if can_reorder_step_in_protocol(@protocol) %>
<a data-action="move-step"
class="btn btn-link"
href="<%= move_up_step_path(step, format: :json) %>"
title="<%= t("protocols.steps.options.up_arrow_title") %>"
data-remote="true">
2016-07-21 19:11:15 +08:00
<span class="glyphicon glyphicon-arrow-up"></span></a>
<a data-action="move-step"
class="btn btn-link"
href="<%= move_down_step_path(step, format: :json) %>"
title="<%= t("protocols.steps.options.down_arrow_title") %>"
data-remote="true">
2016-07-21 19:11:15 +08:00
<span class="glyphicon glyphicon-arrow-down"></a>
<% end %>
<% if can_edit_step_in_protocol(@protocol) %>
<a data-action="edit-step"
class="btn btn-link"
title="<%= t("protocols.steps.options.edit_title") %>"
href="<%= edit_step_path(step, format: :json) %>"
data-remote="true">
2016-07-21 19:11:15 +08:00
<span class="glyphicon glyphicon-edit">
</a>
<% end %>
<% if can_delete_step_in_protocol(@protocol) && step.can_destroy? %>
2016-07-21 19:11:15 +08:00
<%= link_to(step_path(step), title: t("protocols.steps.options.delete_title"), method: "delete", class: "btn btn-link",
data: {action: "delete-step", confirm: t("protocols.steps.destroy.confirm", step: step.name)}) do %>
<span class="glyphicon glyphicon-trash">
<% end %>
<% end %>
</div>
<a class="step-panel-collapse-link"
href="#step-panel-<%= step.id %>"
data-toggle="collapse"
data-remote="true">
2016-07-21 19:11:15 +08:00
<span class="glyphicon glyphicon-collapse-down collapse-step-icon"></span>
<strong><%= step.name %></strong> |
<span><%= sanitize_input t('protocols.steps.published_on',
timestamp: l(step.created_at, format: :full),
user: h(step.user.full_name)) %></span>
2016-07-21 19:11:15 +08:00
</a>
</div>
<div class="panel-collapse collapse" id="step-panel-<%= step.id %>" role="tabpanel">
2016-09-16 15:04:21 +08:00
<div class="panel-body">
2016-07-21 19:11:15 +08:00
<div class="row">
<div class="col-xs-12">
<% if strip_tags(step.description).blank? %>
<em><%= t('protocols.steps.no_description') %></em>
<% else %>
<div class="ql-editor">
2017-04-21 22:09:04 +08:00
<%= custom_auto_link(generate_image_tag_from_token(step.description),
simple_format: false,
tags: %w(img)) %>
</div>
<% end %>
</div>
</div>
<div class="row">
<hr>
2016-07-21 19:11:15 +08:00
<% unless step.tables.blank? then %>
<div class="col-xs-12">
2017-01-17 00:11:08 +08:00
<% step.tables.each do |table| %>
<strong>
2017-01-25 18:01:35 +08:00
<%= auto_link(simple_format(table.name),
2017-01-17 00:11:08 +08:00
link: :urls,
html: { target: '_blank' }) %>
</strong>
<div data-role="hot-table" class="hot-table">
<%= hidden_field(table, :contents, value: table.contents_utf_8, class: "hot-contents") %>
<div data-role="step-hot-table" class="step-result-hot-table"></div>
</div>
<% end %>
2016-07-21 19:11:15 +08:00
</div>
<% end %>
2016-07-21 19:11:15 +08:00
<% assets = ordered_assets(step) %>
<% unless assets.blank? then %>
<div class="col-xs-12">
<strong><%= t("protocols.steps.files") %></strong>
<ul>
<% assets.each do |asset| %>
<li>
<% if can_view_or_download_step_assets(@protocol) %>
<% if asset.file_present %>
<% if asset.file.processing? %>
<span data-status='asset-loading'
data-present-url='<%= file_present_asset_path(asset) %>'>
<%= image_tag 'medium/processing.gif' %>
</span>
<% else %>
<% if asset.is_image? %>
<%= link_to download_asset_path(asset),
class: 'image-preview-link',
id: "modal_link#{asset.id}",
data: {no_turbolink: true, id: true, status: "asset-present",
description: "#{step.position + 1}. #{truncate(step.name, length: Constants::FILENAME_TRUNCATION_LENGTH)}"} do %>
<%= image_tag asset.url(:medium), data: {'preview-url': large_image_url_asset_path(asset)} %>
<p><%= truncate(asset.file_file_name,
length: Constants::FILENAME_TRUNCATION_LENGTH) %></p>
<% end %>
2016-10-04 18:34:43 +08:00
<% else %>
2017-03-13 20:20:49 +08:00
<%= render partial: 'steps/wopi_controlls.html.erb', locals: { asset: asset } %>
2016-10-04 18:34:43 +08:00
<% end %>
2016-07-21 19:11:15 +08:00
<% end %>
<% else %>
<span data-status='asset-loading'
data-present-url='<%= file_present_asset_path(asset) %>'>
<%= image_tag 'medium/processing.gif' %>
</span>
<% end %>
2016-07-21 19:11:15 +08:00
<% else %>
<% if asset.file.processing? %>
<span data-status='asset-loading'
data-present-url='<%= file_present_asset_path(asset) %>'>
<%= image_tag 'medium/processing.gif' %>
</span>
<% else %>
<%= image_tag asset.url(:medium) if asset.is_image? %>
<% end %>
<p><%= truncate(asset.file_file_name,
length: Constants::FILENAME_TRUNCATION_LENGTH) %></p>
2016-07-21 19:11:15 +08:00
<% end %>
</li>
<% end %>
</ul>
</div>
<% end %>
<% unless step.checklists.blank? then %>
<div class="col-xs-12">
<% step.checklists.asc.each do |checklist| %>
<strong><%= custom_auto_link(checklist.name) %></strong>
2016-07-21 19:11:15 +08:00
<% if checklist.checklist_items.empty? %>
</br>
<%= t("protocols.steps.empty_checklist") %>
</br>
<% else %>
<% ordered_checklist_items(checklist).each do |checklist_item| %>
<div class="checkbox" <%= @protocol.in_module? ? "data-action=check-item" : "" %>>
<label>
<% if @protocol.in_module? %>
<input type="checkbox"
value=""
data-link-url="<%=checklistitem_state_step_path(step) %>"
data-id="<%= checklist_item.id %>" <%= "checked" if checklist_item.checked? %> />
2016-07-21 19:11:15 +08:00
<% else %>
<input type="checkbox"
value=""
disabled="disabled" />
2016-07-21 19:11:15 +08:00
<% end %>
<%= custom_auto_link(checklist_item.text) %>
2016-07-21 19:11:15 +08:00
</label>
</div>
<% end %>
<% end %>
<% end %>
</div>
<% end %>
<% if @protocol.in_module? %>
<% if !step.completed? and can_complete_step_in_protocol(@protocol) %>
<div data-action="complete-step"
class="pull-right"
data-link-url="<%= toggle_step_state_step_path(step)%>">
<button class="btn btn-primary"><%= t("protocols.steps.options.complete_title") %></button>
</div>
<% elsif step.completed? and can_uncomplete_step_in_protocol(@protocol) %>
<div data-action="uncomplete-step"
class="pull-right"
data-link-url="<%= toggle_step_state_step_path(step)%>">
<button class="btn btn-default"><%= t("protocols.steps.options.uncomplete_title") %></button>
</div>
<% end %>
2016-07-21 19:11:15 +08:00
<% end %>
</div>
<% if can_view_step_comments(@protocol) %>
2016-09-16 15:04:21 +08:00
<div class="row">
<div class="step-comment"
id="step-comments-<%= step.id %>"
data-href="<%= url_for step_step_comments_path(step_id: step.id, format: :json) %>">
2016-09-16 15:04:21 +08:00
</div>
</div>
<% end %>
2016-07-21 19:11:15 +08:00
</div>
</div>
</div>
</div>