mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-21 23:46:21 +08:00
Merge pull request #2013 from biosistemika/SCI-3806-shared-status-dropdown
SCI-3806 Add an icon indicating shared status to dropdown
This commit is contained in:
commit
f2a9a4b505
|
@ -16,10 +16,15 @@
|
|||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
text-transform: initial;
|
||||
width: 300px;
|
||||
|
||||
li:not(:first-child) {
|
||||
border-top: 1px solid $color-gainsboro;
|
||||
}
|
||||
|
||||
.fas-custom{
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
|
||||
.repository-share-status {
|
||||
|
|
21
app/helpers/inventories_helper.rb
Normal file
21
app/helpers/inventories_helper.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module InventoriesHelper
|
||||
def inventory_shared_status_icon(inventory, team)
|
||||
if inventory.shared_with?(team)
|
||||
if can_manage_repository_rows?(inventory)
|
||||
draw_custom_icon('shared-edit')
|
||||
else
|
||||
draw_custom_icon('shared-read')
|
||||
end
|
||||
else
|
||||
# The icon should be hiden if repo is not shared (we're updating it dinamically)
|
||||
css_classes = ["repository-share-status"]
|
||||
css_classes.push("hidden") unless inventory.i_shared?(current_team)
|
||||
|
||||
content_tag :span, class: css_classes.join(" ") do
|
||||
draw_custom_icon('i-shared')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -38,6 +38,12 @@ class Repository < ApplicationRecord
|
|||
.distinct
|
||||
}
|
||||
|
||||
scope :used_on_task_but_unshared, lambda { |task, team|
|
||||
where(id: task.repository_rows
|
||||
.select(:repository_id))
|
||||
.where.not(id: accessible_by_teams(team.id).select(:id)).distinct
|
||||
}
|
||||
|
||||
def self.search(
|
||||
user,
|
||||
query = nil,
|
||||
|
@ -77,7 +83,11 @@ class Repository < ApplicationRecord
|
|||
end
|
||||
|
||||
def i_shared?(team)
|
||||
(shared? || team_repositories.any?) && self.team == team
|
||||
shared_with_anybody? && self.team == team
|
||||
end
|
||||
|
||||
def shared_with_anybody?
|
||||
(shared? || team_repositories.any?)
|
||||
end
|
||||
|
||||
def shared_with?(team)
|
||||
|
|
|
@ -13,6 +13,26 @@
|
|||
<% else %>
|
||||
<%= truncate(repository.name) %>
|
||||
<span class="assigned-items-counter"><i class="fas fa-spinner fa-spin"></i></span>
|
||||
<% end %>
|
||||
<%= inventory_shared_status_icon(repository, current_team) %>
|
||||
</a>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
|
||||
<% Repository.used_on_task_but_unshared(@my_module, current_team).each do |repository| %>
|
||||
<li>
|
||||
<a class="disabled dropdown-item help_tooltips"
|
||||
data-tooltipcontent="<%= I18n.t('tooltips.text.protocol.unshared_inventory') + repository.team.name %>"
|
||||
title="<%= repository.name %>">
|
||||
<% if enable_counters %>
|
||||
<% cache [repository, @my_module] do %>
|
||||
<%= truncate(repository.name) %>
|
||||
<span class="assigned-items-counter"><%= "(#{@my_module.repository_rows_count(repository)})" %></span>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= truncate(repository.name) %>
|
||||
<span class="assigned-items-counter"><i class="fas fa-spinner fa-spin"></i></span>
|
||||
<% end %>
|
||||
</a>
|
||||
</li>
|
||||
|
|
|
@ -23,18 +23,7 @@
|
|||
repository_path(repository),
|
||||
data: { 'no-turbolink' => 'true' } %>
|
||||
<% end %>
|
||||
|
||||
<% if repository.shared_with?(current_team) %>
|
||||
<% if can_manage_repository_rows?(repository) %>
|
||||
<%= draw_custom_icon('shared-edit') %>
|
||||
<% else %>
|
||||
<%= draw_custom_icon('shared-read') %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<span class="repository-share-status <%= "hidden" unless repository.i_shared?(current_team) %>" >
|
||||
<%= draw_custom_icon('i-shared') %>
|
||||
</span>
|
||||
<% end %>
|
||||
<%= inventory_shared_status_icon(repository, current_team) %>
|
||||
</span>
|
||||
</li>
|
||||
<% end %>
|
||||
|
|
|
@ -12,17 +12,7 @@
|
|||
<div class="content-pane repository-show">
|
||||
<div id="repository-toolbar">
|
||||
<span class="repository-share-icon">
|
||||
<% if @repository.shared_with?(current_team) %>
|
||||
<% if can_manage_repository_rows?(@repository) %>
|
||||
<%= draw_custom_icon('shared-edit') %>
|
||||
<% else %>
|
||||
<%= draw_custom_icon('shared-read') %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<span class="repository-share-status <%= "hidden" unless @repository.i_shared?(current_team) %>" >
|
||||
<%= draw_custom_icon('i-shared') %>
|
||||
</span>
|
||||
<% end %>
|
||||
<%= inventory_shared_status_icon(@repository, current_team) %>
|
||||
</span>
|
||||
<div class="repository-title">
|
||||
<% if @inline_editable_title_config.present? %>
|
||||
|
@ -102,7 +92,7 @@
|
|||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="btn-group inline" id="saveCancel" data-toggle="buttons" style="display:none">
|
||||
<button type="button" class="btn btn-success" id="saveRecord" onclick="onClickSave()">
|
||||
<span class="fas fa-save"></span>
|
||||
|
|
|
@ -2161,6 +2161,7 @@ en:
|
|||
complete: "You can complete the task if you are done working on it."
|
||||
inventories: "You can assign inventory items to your task."
|
||||
num_linked: "This number represents how many tasks are linked to the selected protocol."
|
||||
unshared_inventory: "This Inventory has been unshared with your Team by "
|
||||
inventory:
|
||||
new: "Inventories in SciNote enable you to manage all your resources, from samples, reagents, lab equipment, plasmids, etc."
|
||||
visibility: "You can make inventory columns visible or hidden."
|
||||
|
|
Loading…
Reference in a new issue