Link step/results fixes [SCI-12034][SCI-12015][SCI-12035][SCI-12036]

This commit is contained in:
Anton 2025-06-19 13:17:08 +02:00
parent 7638a5fe25
commit ce6524f46e
4 changed files with 48 additions and 33 deletions

View file

@ -83,12 +83,14 @@
:data-object-type="step.attributes.type"
tabindex="0"
></span> <!-- Hidden element to support legacy code -->
<button v-if="step.attributes.results.length == 0" :title="i18n.t('protocols.steps.link_results')" class="btn btn-light icon-btn" @click="this.openLinkResultsModal = true">
<i class="sn-icon sn-icon-results"></i>
</button>
<template v-if="step.attributes.results.length == 0">
<button v-if="urls.update_url" :title="i18n.t('protocols.steps.link_results')" class="btn btn-light icon-btn" @click="this.openLinkResultsModal = true">
<i class="sn-icon sn-icon-results"></i>
</button>
</template>
<GeneralDropdown v-else ref="linkedResultsDropdown" position="right">
<template v-slot:field>
<button class="btn btn-light icon-btn" :title="i18n.t('protocols.steps.link_results')">
<button class="btn btn-light icon-btn" :title="i18n.t('protocols.steps.linked_results')">
<i class="sn-icon sn-icon-results"></i>
<span class="absolute top-1 right-1 h-4 min-w-4 bg-sn-science-blue text-white flex items-center justify-center rounded-full text-[10px]">
{{ step.attributes.results.length }}
@ -96,19 +98,23 @@
</button>
</template>
<template v-slot:flyout>
<a v-for="result in step.attributes.results"
: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"
>
{{ result.name }}
</a>
<hr class="my-0">
<div class="py-2.5 px-3 hover:bg-sn-super-light-grey cursor-pointer text-sn-blue"
@click="this.openLinkResultsModal = true; $refs.linkedResultsDropdown.closeMenu()">
{{ i18n.t('protocols.steps.manage_links') }}
<div class="overflow-y-auto max-h-[calc(50vh_-_6rem)]">
<a v-for="result in step.attributes.results"
: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"
>
{{ result.name }}
</a>
</div>
<template v-if="urls.update_url">
<hr class="my-0">
<div class="py-2.5 px-3 hover:bg-sn-super-light-grey cursor-pointer text-sn-blue"
@click="this.openLinkResultsModal = true; $refs.linkedResultsDropdown.closeMenu()">
{{ i18n.t('protocols.steps.manage_links') }}
</div>
</template>
</template>
</GeneralDropdown>
<a href=" #"

View file

@ -65,12 +65,14 @@
:data-object-type="result.attributes.type"
tabindex="0"
></span> <!-- Hidden element to support legacy code -->
<button v-if="result.attributes.steps.length == 0" class="btn btn-light icon-btn" @click="this.openLinkStepsModal = true">
{{ i18n.t('my_modules.results.link_to_step') }}
</button>
<tempplate v-if="result.attributes.steps.length == 0">
<button v-if="urls.update_url" :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>
<GeneralDropdown v-else ref="linkedStepsDropdown" position="right">
<template v-slot:field>
<button class="btn btn-light icon-btn">
<button class="btn btn-light icon-btn" :title="i18n.t('my_modules.results.linked_steps')">
<i class="sn-icon sn-icon-steps"></i>
<span class="absolute top-1 -right-1 h-4 min-w-4 bg-sn-science-blue text-white flex items-center justify-center rounded-full text-[10px]">
{{ result.attributes.steps.length }}
@ -78,19 +80,23 @@
</button>
</template>
<template v-slot:flyout>
<a v-for="step in result.attributes.steps"
:key="step.id"
:title="step.name"
:href="protocolUrl(step.id)"
class="py-2.5 px-3 hover:bg-sn-super-light-grey cursor-pointer block hover:no-underline text-sn-blue truncate"
>
{{ step.name }}
</a>
<hr class="my-0">
<div class="py-2.5 px-3 hover:bg-sn-super-light-grey cursor-pointer text-sn-blue"
@click="this.openLinkStepsModal = true; $refs.linkedStepsDropdown.closeMenu()">
{{ i18n.t('protocols.steps.manage_links') }}
<div class="overflow-y-auto max-h-[calc(50vh_-_6rem)]">
<a v-for="step in result.attributes.steps"
:key="step.id"
:title="step.name"
:href="protocolUrl(step.id)"
class="py-2.5 px-3 hover:bg-sn-super-light-grey cursor-pointer block hover:no-underline text-sn-blue truncate"
>
{{ step.name }}
</a>
</div>
<template v-if="urls.update_url">
<hr class="my-0">
<div class="py-2.5 px-3 hover:bg-sn-super-light-grey cursor-pointer text-sn-blue"
@click="this.openLinkStepsModal = true; $refs.linkedStepsDropdown.closeMenu()">
{{ i18n.t('protocols.steps.manage_links') }}
</div>
</template>
</template>
</GeneralDropdown>
<a href="#"

View file

@ -4,7 +4,7 @@
<span class="<%=result_icon_class(subject)%>"></span>
<% if subject&.navigable? %>
<% path = subject.archived? ? archive_my_module_path(subject.my_module) : my_module_results_path(subject.my_module) %>
<% path = subject.archived? ? my_module_results_path(subject.my_module, result_id: subject.id, view_mode: :archived) : my_module_results_path(subject.my_module, result_id: subject.id) %>
<%= route_to_other_team(path,
team,
subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH),

View file

@ -1644,6 +1644,8 @@ en:
comments_tab: "Comments"
comment_title: "%{user} at %{time}:"
link_to_step: "Link to step"
link_steps: "Link steps to this result"
linked_steps: "Linked steps"
modals:
link_steps:
title: 'Link result to protocol steps'
@ -4055,6 +4057,7 @@ en:
timestamp_iso_html: "Created on <span class='iso-formatted-date'>%{date}</span> by %{user}"
manage_links: "Manage links"
link_results: "Link results to this step"
linked_results: "Linked results"
status:
complete: "Mark as done"
uncomplete: "Unmark as done"