mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-01 13:13:22 +08:00
refactor smart annotation parser helper
This commit is contained in:
parent
a903772de8
commit
a4aa933151
6 changed files with 92 additions and 22 deletions
|
@ -141,15 +141,21 @@ var SmartAnnotation = (function() {
|
|||
});
|
||||
}
|
||||
|
||||
// initialise dropdown dismiss button
|
||||
function initDismissButton() {
|
||||
$('.atwho-header-res .dismiss').off('click');
|
||||
$('.atwho-header-res .dismiss').on('click', function() {
|
||||
$(field).atwho('destroy');
|
||||
init();
|
||||
});
|
||||
}
|
||||
|
||||
// Initialize filter buttons
|
||||
function initButtons(query, search_filter) {
|
||||
$('.atwho-header-res query_obj button').off();
|
||||
$('.atwho-header-res .dismiss').off('click');
|
||||
|
||||
$('.atwho-header-res .dismiss').on('click', function() {
|
||||
$(field).atwho('destroy');
|
||||
init();
|
||||
});
|
||||
initDismissButton();
|
||||
|
||||
resourcesChecker(query, search_filter);
|
||||
$('.atwho-header-res .title button').on('click', function(e) {
|
||||
|
@ -290,7 +296,7 @@ var SmartAnnotation = (function() {
|
|||
res += map.name;
|
||||
res += '</span>';
|
||||
if(map.archived) {
|
||||
res += '(archived)</span>';
|
||||
res += '<%= I18n.t("atwho.res.archived") %></span>';
|
||||
} else {
|
||||
res += '</span>';
|
||||
}
|
||||
|
@ -308,8 +314,6 @@ var SmartAnnotation = (function() {
|
|||
case 'sam':
|
||||
res += '<span class="res-description">' + map.description + '</span>';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
res += '</li>';
|
||||
|
@ -327,6 +331,7 @@ var SmartAnnotation = (function() {
|
|||
{query: query},
|
||||
function(data) {
|
||||
callback(data.users);
|
||||
initDismissButton();
|
||||
}
|
||||
);
|
||||
},
|
||||
|
@ -385,7 +390,7 @@ var SmartAnnotation = (function() {
|
|||
},
|
||||
headerTpl:
|
||||
'<div class="atwho-header-res">' +
|
||||
'<div class="title"><%= I18n.t("atwho.users.title") %></div>' +
|
||||
'<div class="title title-user"><%= I18n.t("atwho.users.title") %></div>' +
|
||||
'<div class="help">' +
|
||||
'<div>' +
|
||||
'<strong><%= I18n.t("atwho.users.navigate_1") %></strong> ' +
|
||||
|
|
|
@ -1794,6 +1794,10 @@ th.custom-field .modal-tooltiptext {
|
|||
}
|
||||
}
|
||||
|
||||
.title-user {
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
.help {
|
||||
float: right;
|
||||
padding-top: 4px;
|
||||
|
@ -1857,3 +1861,17 @@ th.custom-field .modal-tooltiptext {
|
|||
font-size: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.sa-type {
|
||||
border: 1px solid $color-black;
|
||||
border-radius: 4px;
|
||||
color: $color-black;
|
||||
font-weight: 600;
|
||||
padding: 0 2px;
|
||||
text-decoration: none;
|
||||
text-transform: capitalize;
|
||||
|
||||
&:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,19 +59,55 @@ module ApplicationHelper
|
|||
match = el.match(sa_reg)
|
||||
case match[2]
|
||||
when 'prj'
|
||||
link_to match[1], project_path(match[3].to_i)
|
||||
project = Project.find_by_id(match[3].to_i)
|
||||
next unless project
|
||||
if project.archived?
|
||||
"<span class='sa-type'>#{sanitize(match[2])}</span> " \
|
||||
"#{link_to project.name,
|
||||
projects_archive_path} #{t'atwho.res.archived'}"
|
||||
else
|
||||
"<span class='sa-type'>#{sanitize(match[2])}</span> " \
|
||||
"#{link_to project.name,
|
||||
project_path(project)}"
|
||||
end
|
||||
when 'exp'
|
||||
link_to match[1], canvas_experiment_path(match[3].to_i)
|
||||
experiment = Experiment.find_by_id(match[3].to_i)
|
||||
next unless experiment
|
||||
if experiment.archived?
|
||||
"<span class='sa-type'>#{sanitize(match[2])}</span> " \
|
||||
"#{link_to experiment.name,
|
||||
experiment_archive_project_path(experiment.project)} " \
|
||||
"#{t'atwho.res.archived'}"
|
||||
else
|
||||
"<span class='sa-type'>#{sanitize(match[2])}</span> " \
|
||||
"#{link_to experiment.name,
|
||||
canvas_experiment_path(experiment)}"
|
||||
end
|
||||
when 'tsk'
|
||||
link_to match[1], protocols_my_module_path(match[3].to_i)
|
||||
my_module = MyModule.find_by_id(match[3].to_i)
|
||||
next unless my_module
|
||||
if my_module.archived?
|
||||
"<span class='sa-type'>#{sanitize(match[2])}</span> " \
|
||||
"#{link_to my_module.name,
|
||||
module_archive_experiment_path(my_module.experiment)}" \
|
||||
"#{t'atwho.res.archived'}"
|
||||
else
|
||||
"<span class='sa-type'>#{sanitize(match[2])}</span> " \
|
||||
"#{link_to my_module.name,
|
||||
protocols_my_module_path(my_module)}"
|
||||
end
|
||||
when 'sam'
|
||||
sample = Sample.find_by_id(match[3])
|
||||
if sample
|
||||
link_to match[1],
|
||||
samples_project_path(sample
|
||||
.organization
|
||||
.projects
|
||||
.first)
|
||||
"<span class='glyphicon glyphicon-tint'></span> " \
|
||||
"#{link_to sample.name,
|
||||
samples_project_path(sample
|
||||
.organization
|
||||
.projects
|
||||
.first)}"
|
||||
else
|
||||
"<span class='glyphicon glyphicon-tint'></span> " \
|
||||
"#{match[1]} #{t'atwho.res.deleted'}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -39,7 +39,11 @@
|
|||
</div>
|
||||
<strong><%= comment.user.full_name %>:</strong>
|
||||
<div data-role="comment-message-container">
|
||||
<p data-role="comment-message"><%= auto_link(simple_format(comment.message),
|
||||
link: :urls,
|
||||
html: { target: '_blank' }) %></p>
|
||||
<p data-role="comment-message"><%= auto_link(
|
||||
simple_format(
|
||||
smart_annotation_parser(comment.message)
|
||||
),
|
||||
link: :urls,
|
||||
html: { target: '_blank' }
|
||||
) %></p>
|
||||
</div>
|
||||
|
|
|
@ -67,8 +67,13 @@
|
|||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<%= experiment.description %>
|
||||
</span>
|
||||
<%= auto_link(
|
||||
simple_format(
|
||||
smart_annotation_parser(experiment.description)
|
||||
),
|
||||
link: :urls,
|
||||
html: { target: '_blank' }
|
||||
) %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1460,7 +1460,9 @@ en:
|
|||
confirm_2: "to confirm"
|
||||
dismiss_1: "esc"
|
||||
dismiss_2: "to dismiss"
|
||||
|
||||
res:
|
||||
archived: "(archived)"
|
||||
deleted: "(deleted)"
|
||||
# This section contains general words that can be used in any parts of
|
||||
# application.
|
||||
|
||||
|
|
Loading…
Reference in a new issue