mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-10 22:06:46 +08:00
Amend step labeling for step-result links [SCI-12093]
This commit is contained in:
parent
54f347d4c8
commit
d5e2acdbb6
9 changed files with 12 additions and 17 deletions
|
@ -34,7 +34,7 @@ class StepResultsController < ApplicationController
|
||||||
StepResult.create!(step: step, result: @results.first, created_by: current_user)
|
StepResult.create!(step: step, result: @results.first, created_by: current_user)
|
||||||
log_activity(:step_and_result_linked, @results.first.my_module, step, @results.first)
|
log_activity(:step_and_result_linked, @results.first.my_module, step, @results.first)
|
||||||
end
|
end
|
||||||
render json: { steps: @results.first.steps.map { |s| { id: s.id, name: s.name } } }, status: :created
|
render json: { steps: @results.first.steps.map { |s| { id: s.id, name: s.label } } }, status: :created
|
||||||
rescue ActiveRecord::RecordInvalid => e
|
rescue ActiveRecord::RecordInvalid => e
|
||||||
Rails.logger.error e.message
|
Rails.logger.error e.message
|
||||||
render json: { message: :error }, status: :unprocessable_entity
|
render json: { message: :error }, status: :unprocessable_entity
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
:value="selectedSteps"
|
:value="selectedSteps"
|
||||||
:searchable="true"
|
:searchable="true"
|
||||||
@change="changeSteps"
|
@change="changeSteps"
|
||||||
:option-renderer="stepRenderer"
|
|
||||||
:multiple="true"
|
:multiple="true"
|
||||||
:withCheckboxes="true"
|
:withCheckboxes="true"
|
||||||
:placeholder="i18n.t('my_modules.results.modals.link_steps.placeholder')" />
|
:placeholder="i18n.t('my_modules.results.modals.link_steps.placeholder')" />
|
||||||
|
@ -147,9 +146,6 @@ export default {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
stepRenderer(option) {
|
|
||||||
return `${option[2].position + 1}. ${option[1]}`;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -179,6 +179,10 @@ class Step < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def label
|
||||||
|
I18n.t('protocols.steps.label', name: name, position: position + 1)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def duplicate_table(new_step, user, table)
|
def duplicate_table(new_step, user, table)
|
||||||
|
|
|
@ -19,7 +19,7 @@ class ResultSerializer < ActiveModel::Serializer
|
||||||
|
|
||||||
def steps
|
def steps
|
||||||
object.steps.map do |step|
|
object.steps.map do |step|
|
||||||
{ id: step.id, name: step.name }
|
{ id: step.id, name: step.label }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ module Reports::Docx::DrawResults
|
||||||
text ' | '
|
text ' | '
|
||||||
text I18n.t('projects.reports.elements.result.linked_steps'), color: color[:gray]
|
text I18n.t('projects.reports.elements.result.linked_steps'), color: color[:gray]
|
||||||
text ' '
|
text ' '
|
||||||
text result.steps.pluck(:name).join('; '), color: color[:gray]
|
text result.steps.map(&:label).join('; '), color: color[:gray]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
draw_result_asset(result, @settings) if @settings.dig('task', 'file_results')
|
draw_result_asset(result, @settings) if @settings.dig('task', 'file_results')
|
||||||
|
|
|
@ -91,7 +91,7 @@
|
||||||
<%= t('projects.reports.elements.result.user_time', user: result.user.full_name, timestamp: l(result.created_at, format: :full)) %>
|
<%= t('projects.reports.elements.result.user_time', user: result.user.full_name, timestamp: l(result.created_at, format: :full)) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if !@settings['exclude_task_metadata'] && result.steps.size.positive? %>
|
<% if !@settings['exclude_task_metadata'] && result.steps.size.positive? %>
|
||||||
| <%= t("projects.reports.elements.result.linked_steps") %> <%= result.steps.pluck(:name).join('; ') %>
|
| <%= t("projects.reports.elements.result.linked_steps") %> <%= result.steps.map(&:label).join('; ') %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<ul id="StepsMenuDropdown<%= result.id %>" class="dropdown-menu dropdown-menu-right px-4 py-2">
|
<ul id="StepsMenuDropdown<%= result.id %>" class="dropdown-menu dropdown-menu-right px-4 py-2">
|
||||||
<% result.steps.each do |step| %>
|
<% result.steps.each do |step| %>
|
||||||
<li class="dropdown-item">
|
<li class="dropdown-item">
|
||||||
<%= link_to step.name, shared_protocol_url(@shareable_link.uuid), class: "!py-2.5 !px-3 hover:!bg-sn-super-light-grey !cursor-pointer !block hover:!no-underline !text-sn-blue !truncate" %>
|
<%= link_to step.label, shared_protocol_url(@shareable_link.uuid), class: "!py-2.5 !px-3 hover:!bg-sn-super-light-grey !cursor-pointer !block hover:!no-underline !text-sn-blue !truncate" %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
json.array! @steps do |r|
|
json.array! @steps do |s|
|
||||||
json.array! [
|
json.array! [s.id, s.label]
|
||||||
r.id,
|
|
||||||
r.name,
|
|
||||||
{
|
|
||||||
position: r.position
|
|
||||||
}
|
|
||||||
]
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -4027,6 +4027,7 @@ en:
|
||||||
ztoa_html: "<i class=\"fas fa-sort-alpha-up\"></i> Name Z to A"
|
ztoa_html: "<i class=\"fas fa-sort-alpha-up\"></i> Name Z to A"
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
label: "Step %{position} - %{name}"
|
||||||
placeholder: 'Step name'
|
placeholder: 'Step name'
|
||||||
default_name: 'Untitled step'
|
default_name: 'Untitled step'
|
||||||
completed: 'Completed'
|
completed: 'Completed'
|
||||||
|
|
Loading…
Add table
Reference in a new issue