mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-27 10:08:11 +08:00
Add archive lables and fix bright colors in RTE fields (#1923)
This commit is contained in:
parent
c6152ccddb
commit
5ca822a7d8
3 changed files with 21 additions and 1 deletions
|
@ -12,6 +12,10 @@ module DrawExperiment
|
|||
@docx.p do
|
||||
text I18n.t('projects.reports.elements.experiment.user_time',
|
||||
timestamp: I18n.l(experiment.created_at, format: :full)), color: color[:gray]
|
||||
if experiment.archived?
|
||||
text ' | '
|
||||
text I18n.t('search.index.archived'), color: color[:gray]
|
||||
end
|
||||
text ' | '
|
||||
link I18n.t('projects.reports.elements.all.scinote_link'),
|
||||
scinote_url + Rails.application.routes.url_helpers.canvas_experiment_path(experiment),
|
||||
|
|
|
@ -23,6 +23,10 @@ module DrawMyModule
|
|||
text " #{I18n.t('my_modules.states.completed')} #{I18n.l(my_module.completed_on, format: :full)}",
|
||||
color: color[:gray]
|
||||
end
|
||||
if my_module.archived?
|
||||
text ' | '
|
||||
text I18n.t('search.index.archived'), color: color[:gray]
|
||||
end
|
||||
text ' | '
|
||||
link I18n.t('projects.reports.elements.all.scinote_link'),
|
||||
scinote_url + Rails.application.routes.url_helpers.protocols_my_module_path(my_module),
|
||||
|
|
|
@ -142,7 +142,7 @@ module PrivateMethods
|
|||
value = style_el.split(':')[1].strip if style_el
|
||||
if key == 'text-align'
|
||||
result[:align] = value.to_sym
|
||||
elsif key == 'color'
|
||||
elsif key == 'color' && calculate_color_hsp(value) < 190
|
||||
result[:color] = value.delete('#')
|
||||
end
|
||||
end
|
||||
|
@ -276,4 +276,16 @@ module PrivateMethods
|
|||
image.open.path
|
||||
end
|
||||
end
|
||||
|
||||
def calculate_color_hsp(color)
|
||||
return 255 if color.length != 7
|
||||
|
||||
color = color.delete('#').scan(/.{1,2}/)
|
||||
rgb = color.map(&:hex)
|
||||
Math.sqrt(
|
||||
0.299 * (rgb[0]**2) +
|
||||
0.587 * (rgb[1]**2) +
|
||||
0.114 * (rgb[2]**2)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue