mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-17 10:34:50 +08:00
Show private objects for SA [SCI-12090]
This commit is contained in:
parent
1442444ddc
commit
89b196fd4a
3 changed files with 52 additions and 8 deletions
|
@ -28,9 +28,11 @@ module SmartAnnotations
|
|||
if type == 'rep_item'
|
||||
repository_item(value[:name], user, team, type, object, preview_repository)
|
||||
else
|
||||
next unless object && SmartAnnotations::PermissionEval.check(user, type, object)
|
||||
|
||||
SmartAnnotations::HtmlPreview.html(nil, type, object)
|
||||
if object && SmartAnnotations::PermissionEval.check(user, type, object)
|
||||
SmartAnnotations::HtmlPreview.html(nil, type, object)
|
||||
else
|
||||
private_placeholder(object)
|
||||
end
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
next
|
||||
|
@ -40,7 +42,7 @@ module SmartAnnotations
|
|||
|
||||
def repository_item(name, user, team, type, object, preview_repository)
|
||||
if object&.repository
|
||||
return unless SmartAnnotations::PermissionEval.check(user, type, object)
|
||||
return private_placeholder(object) unless SmartAnnotations::PermissionEval.check(user, type, object)
|
||||
|
||||
return SmartAnnotations::HtmlPreview.html(nil, type, object, preview_repository)
|
||||
end
|
||||
|
@ -62,5 +64,22 @@ module SmartAnnotations
|
|||
end
|
||||
klass.find_by(id: id)
|
||||
end
|
||||
|
||||
def private_placeholder(object = nil)
|
||||
label = case object
|
||||
when Project
|
||||
I18n.t('smart_annotations.private.project')
|
||||
when Experiment
|
||||
I18n.t('smart_annotations.private.experiment')
|
||||
when MyModule
|
||||
I18n.t('smart_annotations.private.my_module')
|
||||
when RepositoryRow
|
||||
I18n.t('smart_annotations.private.repository_row')
|
||||
else
|
||||
I18n.t('smart_annotations.private.object')
|
||||
end
|
||||
|
||||
"<span class=\"text-sn-grey\">#{label}</span>"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,9 +29,11 @@ module SmartAnnotations
|
|||
if type == 'rep_item'
|
||||
repository_item(value[:name], user, team, type, object, is_shared_object)
|
||||
else
|
||||
next unless object && (is_shared_object || SmartAnnotations::PermissionEval.check(user, type, object))
|
||||
|
||||
SmartAnnotations::TextPreview.text(nil, type, object)
|
||||
if object && (is_shared_object || SmartAnnotations::PermissionEval.check(user, type, object))
|
||||
SmartAnnotations::TextPreview.text(nil, type, object)
|
||||
else
|
||||
private_placeholder(object)
|
||||
end
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
next
|
||||
|
@ -56,7 +58,7 @@ module SmartAnnotations
|
|||
|
||||
def repository_item(name, user, team, type, object, is_shared_object)
|
||||
if object
|
||||
return unless is_shared_object || SmartAnnotations::PermissionEval.check(user, type, object)
|
||||
return private_placeholder(object) unless is_shared_object || SmartAnnotations::PermissionEval.check(user, type, object)
|
||||
|
||||
return SmartAnnotations::TextPreview.text(nil, type, object)
|
||||
end
|
||||
|
@ -78,5 +80,20 @@ module SmartAnnotations
|
|||
end
|
||||
klass.find_by_id(id)
|
||||
end
|
||||
|
||||
def private_placeholder(object = nil)
|
||||
case object
|
||||
when Project
|
||||
I18n.t('smart_annotations.private.project')
|
||||
when Experiment
|
||||
I18n.t('smart_annotations.private.experiment')
|
||||
when MyModule
|
||||
I18n.t('smart_annotations.private.my_module')
|
||||
when RepositoryRow
|
||||
I18n.t('smart_annotations.private.repository_row')
|
||||
else
|
||||
I18n.t('smart_annotations.private.object')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -428,6 +428,14 @@ en:
|
|||
activities: "Activity"
|
||||
archive: "Archived results"
|
||||
|
||||
smart_annotations:
|
||||
private:
|
||||
project: "#private project"
|
||||
experiment: "#private experiment"
|
||||
my_module: "#private task"
|
||||
repository_row: "#private inventory item"
|
||||
object: "#private object"
|
||||
|
||||
attachments:
|
||||
menu:
|
||||
office_file: "New Microsoft 365 file"
|
||||
|
|
Loading…
Add table
Reference in a new issue