Skip to content

Commit

Permalink
refactor: put methods in the same order as in case statement
Browse files Browse the repository at this point in the history
  • Loading branch information
cbliard committed Apr 9, 2024
1 parent b3166f4 commit a32c41b
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions lib/open_project/journal_formatter/cause.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,6 @@ def system_update_message(cause)
I18n.t("journals.cause_descriptions.system_update.#{cause['feature']}")
end

def related_work_package_changed_message(cause, html)
related_work_package = WorkPackage.includes(:project).visible(User.current).find_by(id: cause["work_package_id"])

if related_work_package
I18n.t(
"journals.cause_descriptions.#{cause['type']}",
link: html ? link_to_work_package(related_work_package, all_link: true) : "##{related_work_package.id}"
)

else
I18n.t("journals.cause_descriptions.unaccessable_work_package_changed")
end
end

def working_days_changed_message(changed_dates)
day_changes_messages = changed_dates["working_days"].collect do |day, working|
working_day_change_message(day.to_i, working)
Expand All @@ -108,6 +94,20 @@ def working_date_change_message(date, working)
date: I18n.l(Date.parse(date)))
end

def related_work_package_changed_message(cause, html)
related_work_package = WorkPackage.includes(:project).visible(User.current).find_by(id: cause["work_package_id"])

if related_work_package
I18n.t(
"journals.cause_descriptions.#{cause['type']}",
link: html ? link_to_work_package(related_work_package, all_link: true) : "##{related_work_package.id}"
)

else
I18n.t("journals.cause_descriptions.unaccessable_work_package_changed")
end
end

# we need to tell the url_helper that there is not controller to get url_options
# so that we can later call link_to
def controller
Expand Down

0 comments on commit a32c41b

Please sign in to comment.