mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-28 19:24:10 +08:00
Add assigned tasks block to the item card [SCI-9155]
This commit is contained in:
parent
3b170a0c0d
commit
56a57233df
4 changed files with 118 additions and 8 deletions
|
@ -112,4 +112,65 @@ module MyModulesHelper
|
|||
''
|
||||
end
|
||||
end
|
||||
|
||||
def extract_my_module_metadata(my_module)
|
||||
[
|
||||
team_data(my_module.team),
|
||||
project_data(my_module.project),
|
||||
experiment_data(my_module.experiment),
|
||||
my_module_data(my_module)
|
||||
].each do |item|
|
||||
item[:value] = "(A) #{item[:value]}" if item[:archived]
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def team_data(team)
|
||||
{
|
||||
label: I18n.t('repositories.item_card.assigned.labels.team'),
|
||||
value: team.name,
|
||||
url: projects_path(team: team.id),
|
||||
archived: false
|
||||
}
|
||||
end
|
||||
|
||||
def project_data(project)
|
||||
{
|
||||
label: I18n.t('repositories.item_card.assigned.labels.project'),
|
||||
value: project.name,
|
||||
url: project_path(project, view_mode: view_mode(project.archived?)),
|
||||
archived: project.archived?
|
||||
}
|
||||
end
|
||||
|
||||
def experiment_data(experiment)
|
||||
{
|
||||
label: I18n.t('repositories.item_card.assigned.labels.experiment'),
|
||||
value: experiment.name,
|
||||
url: experiment_url(experiment),
|
||||
archived: experiment.archived_branch?
|
||||
}
|
||||
end
|
||||
|
||||
def my_module_data(my_module)
|
||||
{
|
||||
label: I18n.t('repositories.item_card.assigned.labels.my_module'),
|
||||
value: my_module.name,
|
||||
url: protocols_my_module_path(my_module, view_mode: view_mode(my_module.archived_branch?)),
|
||||
archived: my_module.archived_branch?
|
||||
}
|
||||
end
|
||||
|
||||
def view_mode(archived)
|
||||
archived ? 'archived' : 'active'
|
||||
end
|
||||
|
||||
def experiment_url(experiment)
|
||||
if experiment.archived_branch?
|
||||
module_archive_experiment_path(experiment)
|
||||
else
|
||||
my_modules_experiment_path(experiment)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -60,14 +60,40 @@
|
|||
</div>
|
||||
|
||||
<div id="divider" class="w-500 bg-sn-light-grey flex px-8 items-center self-stretch h-px "></div>
|
||||
|
||||
<div id="assigned-wrapper" class="flex flex-col h-[64px] gap-[6px]">
|
||||
<div id="assigned-label" class="font-inter text-base font-semibold leading-7">Assigned (3)</div>
|
||||
<div id="assigned-value" class="text-sn-dark-grey font-inter text-sm font-normal leading-5">
|
||||
{{ this.assigned }}
|
||||
|
||||
<div class="assigned-wrapper">
|
||||
<div class="text-base font-semibold w-[350px] my-3 leading-7">
|
||||
{{ i18n.t('repositories.item_card.section.assigned', { count: assignedModules.total_assigned_count }) }}
|
||||
</div>
|
||||
|
||||
<div v-if="assignedModules.total_assigned_count > 0">
|
||||
<div v-if="assignedModules.private_count > 0" class="pb-6">
|
||||
{{ i18n.t('repositories.item_card.assigned.private', { count: assignedModules.private_count }) }}
|
||||
|
||||
<hr v-if="assignedModules.viewable_modules.length > 0"
|
||||
class="h-1 w-[350px] m-0 mt-6 border-dashed border-1 border-sn-light-grey"/>
|
||||
</div>
|
||||
|
||||
<div v-for="(assigned, index) in assignedModules.viewable_modules"
|
||||
:key="`assigned_module_${index}`"
|
||||
class="flex flex-col w-[350px] mb-6 h-auto">
|
||||
|
||||
<div class="flex flex-col gap-3">
|
||||
<div v-for="(object, index_assigned) in assigned"
|
||||
:key="`assigned_element_${index_assigned}`">
|
||||
{{ object.label }}
|
||||
<a :href="object.url">{{ object.value }}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr v-if="index < assignedModules.viewable_modules.length - 1"
|
||||
class="h-1 w-[350px] mt-6 mb-0 border-dashed border-1 border-sn-light-grey"/>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="mb-3">
|
||||
{{ i18n.t('repositories.item_card.assigned.empty') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="divider" class="w-500 bg-sn-light-grey flex px-8 items-center self-stretch h-px "></div>
|
||||
|
||||
<div id="QR-wrapper" class="block">
|
||||
|
@ -114,9 +140,9 @@
|
|||
repositoryName: null,
|
||||
defaultColumns: null,
|
||||
customColumns: null,
|
||||
assignedModules: null,
|
||||
isShowing: false,
|
||||
sequenceExpanded: false,
|
||||
assigned: 'Assigned to 3 private tasks that will not be displayed'
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
@ -172,6 +198,7 @@
|
|||
this.repositoryName = result.repository_name;
|
||||
this.defaultColumns = result.default_columns;
|
||||
this.customColumns = result.custom_columns;
|
||||
this.assignedModules = result.assigned_modules;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
|
@ -14,3 +14,13 @@ json.custom_columns do
|
|||
json.merge! serialize_repository_cell_value(repository_cell, @repository.team, @repository)
|
||||
end
|
||||
end
|
||||
|
||||
json.assigned_modules do
|
||||
json.total_assigned_count @assigned_modules.length
|
||||
json.private_count @private_modules.length
|
||||
json.viewable_modules do
|
||||
json.array! @viewable_modules do |my_module|
|
||||
json.merge! extract_my_module_metadata(my_module)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2109,6 +2109,18 @@ en:
|
|||
item_card:
|
||||
title:
|
||||
information: "Information"
|
||||
section:
|
||||
assigned: "Assigned (%{count})"
|
||||
assigned:
|
||||
empty: "This item is not assigned to any task."
|
||||
private:
|
||||
one: "Assigned to %{count} private task"
|
||||
other: "Assigned to %{count} private tasks"
|
||||
labels:
|
||||
team: "Team:"
|
||||
project: "Project:"
|
||||
experiment: "Experiment:"
|
||||
my_module: "Task:"
|
||||
default_columns:
|
||||
repository_name: "Inventory"
|
||||
id: "Item ID"
|
||||
|
|
Loading…
Reference in a new issue