Add archived label to results dropdown and add link to results in shared tasks [SCI-12067]

This commit is contained in:
Anton 2025-08-18 12:11:23 +02:00
parent 6e78a3d1a6
commit 677d438f85
8 changed files with 32 additions and 7 deletions

View file

@ -43,8 +43,6 @@ class MyModuleShareableLinksController < ApplicationController
@results_order = params[:order] || 'new'
@results = @my_module.results.active
@results = @results.page(params[:page]).per(Constants::RESULTS_PER_PAGE_LIMIT)
@results = case @results_order
when 'old' then @results.order(created_at: :asc)
when 'old_updated' then @results.order(updated_at: :asc)
@ -54,6 +52,15 @@ class MyModuleShareableLinksController < ApplicationController
else @results.order(created_at: :desc)
end
if params[:result_id].present?
page = @results.find_page_number(params[:result_id].to_i, Constants::RESULTS_PER_PAGE_LIMIT)
params[:result_id] = nil
else
page = params[:page]
end
@results = @results.page(page).per(Constants::RESULTS_PER_PAGE_LIMIT)
@gallery = @results.left_joins(:assets).pluck('assets.id').compact
@disable_smart_annotation_links = true

View file

@ -105,9 +105,12 @@
:key="result.id"
:title="result.name"
:href="resultUrl(result.id, result.archived)"
class="py-2.5 px-3 hover:bg-sn-super-light-grey cursor-pointer block hover:no-underline text-sn-blue truncate"
class="py-2.5 px-3 hover:bg-sn-super-light-grey cursor-pointer hover:no-underline text-sn-blue truncate flex items-center gap-2"
>
{{ result.name }}
<div v-if="result.archived" class="py-1 px-2 text-xs ml-auto text-white bg-sn-grey rounded-full">
{{ i18n.t('protocols.steps.archived_result') }}
</div>
</a>
</div>
<template v-if="urls.update_url">

View file

@ -66,11 +66,11 @@
:data-object-type="result.attributes.type"
tabindex="0"
></span> <!-- Hidden element to support legacy code -->
<tempplate v-if="result.attributes.steps.length == 0">
<template v-if="result.attributes.steps.length == 0">
<button v-if="urls.update_url" ref="linkButton" :title="i18n.t('my_modules.results.link_steps')" class="btn btn-light icon-btn" @click="this.openLinkStepsModal = true">
{{ i18n.t('my_modules.results.link_to_step') }}
</button>
</tempplate>
</template>
<GeneralDropdown v-else ref="linkedStepsDropdown" position="right">
<template v-slot:field>
<button ref="linkButton" class="btn btn-light icon-btn" :title="i18n.t('my_modules.results.linked_steps')">

View file

@ -179,6 +179,8 @@ export default {
this.nextPageUrl = response.data.links.next;
this.loadingPage = false;
this.infiniteScrollLoad();
if (this.anchorId) {
const result = this.results.find((e) => e.id === this.anchorId);
if (!result) {

View file

@ -79,6 +79,11 @@ class Result < ApplicationRecord
.where_attributes_like_boolean(SEARCHABLE_ATTRIBUTES, query)
end
def self.find_page_number(result_id, per_page = Kaminari.config.default_per_page)
position = pluck(:id).index(result_id)
(position.to_f / per_page).ceil
end
def duplicate(my_module, user, result_name: nil)
ActiveRecord::Base.transaction do
new_result = my_module.results.new(

View file

@ -38,7 +38,14 @@
<ul id="ResultsMenuDropdown<%= step.id %>" class="dropdown-menu dropdown-menu-right px-4 py-2">
<% step.results.each do |result| %>
<li class="dropdown-item">
<%= link_to result.name, shared_protocol_results_path(@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 shared_protocol_results_path(@shareable_link.uuid, result_id: result.id, anchor: "resultContainer#{result.id}"), class: "!py-2.5 !px-3 hover:!bg-sn-super-light-grey !cursor-pointer hover:!no-underline !text-sn-blue !truncate !flex items-center gap-4 #{'disabled' if result.archived?}" do %>
<span class="leading-4"><%= result.name %></span>
<% if result.archived? %>
<div class="py-1 px-2 text-xs ml-auto text-white bg-sn-grey rounded-full ">
<%= I18n.t('protocols.steps.archived_result') %>
</div>
<% end %>
<% end %>
</li>
<% end %>
</ul>

View file

@ -1,4 +1,4 @@
<div class="result-container bg-white p-4 mb-4 rounded">
<div class="result-container bg-white p-4 mb-4 rounded" id="resultContainer<%= result.id %>">
<div class="result-header flex justify-between">
<div class="result-head-left flex items-start flex-grow gap-4">
<a class="result-collapse-link hover:no-underline focus:no-underline text-sn-black" href="#result-panel-<%= result.id %>" data-toggle="collapse">

View file

@ -4064,6 +4064,7 @@ en:
timestamp: "Created on %{date} by %{user}"
timestamp_iso_html: "Created on <span class='iso-formatted-date'>%{date}</span> by %{user}"
manage_links: "Manage links"
archived_result: "Archived"
link_results: "Link results to this step"
linked_results: "Linked results"
status: