mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-06 03:46:39 +08:00
Code cleanup
This commit is contained in:
parent
58013e215d
commit
431b9161b6
2 changed files with 26 additions and 21 deletions
|
@ -3,7 +3,7 @@
|
|||
module Dashboard
|
||||
class CurrentTasksController < ApplicationController
|
||||
include InputSanitizeHelper
|
||||
helper_method :prepare_due_date
|
||||
helper_method :current_task_date
|
||||
|
||||
before_action :load_project, only: %i(show experiment_filter)
|
||||
before_action :load_experiment, only: :show
|
||||
|
@ -86,24 +86,27 @@ module Dashboard
|
|||
|
||||
private
|
||||
|
||||
def prepare_due_date(task)
|
||||
if task.completed?
|
||||
return { state: '', text: I18n.t('dashboard.current_tasks.completed_on_html',
|
||||
date: I18n.l(task.completed_on, format: :full_date)).html_safe }
|
||||
end
|
||||
if task.due_date.present?
|
||||
due_date_formatted = I18n.l(task.due_date, format: :full_date)
|
||||
if task.is_overdue?
|
||||
return { state: 'overdue', text: I18n.t('dashboard.current_tasks.due_date_overdue_html',
|
||||
date: due_date_formatted).html_safe }
|
||||
elsif task.is_one_day_prior?
|
||||
return { state: 'day-prior', text: I18n.t('dashboard.current_tasks.due_date_html',
|
||||
date: due_date_formatted).html_safe }
|
||||
end
|
||||
def current_task_date(task)
|
||||
span_class, translation_key, date = nil
|
||||
|
||||
return { state: '', text: I18n.t('dashboard.current_tasks.due_date_html', date: due_date_formatted).html_safe }
|
||||
if task.completed?
|
||||
translation_key = 'completed_on_html'
|
||||
date = task.completed_on
|
||||
elsif task.due_date.present?
|
||||
date = task.due_date
|
||||
|
||||
if task.is_overdue?
|
||||
span_class = 'overdue'
|
||||
translation_key = 'due_date_overdue_html'
|
||||
elsif task.is_one_day_prior?
|
||||
span_class = 'day-prior'
|
||||
translation_key = 'due_date_html'
|
||||
else
|
||||
span_class = ''
|
||||
translation_key = 'due_date_html'
|
||||
end
|
||||
end
|
||||
{ state: nil, text: nil }
|
||||
{ span_class: span_class, translation_key: translation_key, date: date }
|
||||
end
|
||||
|
||||
def task_filters
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
<% task_date = current_task_date(task) %>
|
||||
<a class="current-task-item" href="<%= protocols_my_module_path(task.id) %>">
|
||||
<div class="current-task-breadcrumbs"><%= task.experiment.project.name %>
|
||||
<span class="slash">/</span><%= task.experiment.name %></div>
|
||||
<div class="task-name row-border">
|
||||
<%= task.name %>
|
||||
</div>
|
||||
<div class="task-due-date row-border <%= prepare_due_date(task)[:state ]%>">
|
||||
<span class="<%= prepare_due_date(task)[:text] ? '' : 'hidden' %>">
|
||||
<i class="fas fa-calendar-day"></i> <%= prepare_due_date(task)[:text] %>
|
||||
</span>
|
||||
<div class="task-due-date row-border <%= task_date[:span_class]%>">
|
||||
<% if task_date[:date] %>
|
||||
<i class="fas fa-calendar-day"></i>
|
||||
<%= t("dashboard.current_tasks.#{task_date[:translation_key]}", date: l(task_date[:date], format: :full_date)) %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="task-status-container row-border">
|
||||
<span class="task-status" style="background:<%= task.status_color %>"><%= task.status_name %></span>
|
||||
|
|
Loading…
Add table
Reference in a new issue