OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add time_entry_named_association journal formatter
Mir Bhatia0a57175546ca
diff --git a/app/models/journal.rb b/app/models/journal.rbindex 42acecef486..bb3241f119b 100644--- a/app/models/journal.rb+++ b/app/models/journal.rb@@ -45,7 +45,11 @@ class Journal < ApplicationRecordregister_journal_formatter :visibility, OpenProject::JournalFormatter::Visibilityregister_journal_formatter :subproject_named_association, OpenProject::JournalFormatter::SubprojectNamedAssociationregister_journal_formatter :time_entry_hours, OpenProject::JournalFormatter::TimeEntryHours+<<<<<<< HEADregister_journal_formatter :wiki_diff, OpenProject::JournalFormatter::WikiDiff+=======+ register_journal_formatter :time_entry_named_association, OpenProject::JournalFormatter::TimeEntryNamedAssociation+>>>>>>> 562caed8f8 (Add time_entry_named_association journal formatter)# Make sure each journaled model instance only has unique version idsvalidates :version, uniqueness: { scope: %i[journable_id journable_type] }diff --git a/config/locales/en.yml b/config/locales/en.ymlindex cfbc2472738..c5c168b5f0f 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -1002,6 +1002,7 @@ en:updated: "changed from %{first} hours to %{last} hours"updated_first_single: "changed from %{first} hour to %{last} hours"updated_last_single: "changed from %{first} hours to %{last} hour"+ logged_for: "Logged for"filter:changeset: "Changesets"message: "Forums"diff --git a/lib/open_project/journal_formatter/time_entry_named_association.rb b/lib/open_project/journal_formatter/time_entry_named_association.rbnew file mode 100644index 00000000000..69227640a63--- /dev/null+++ b/lib/open_project/journal_formatter/time_entry_named_association.rb@@ -0,0 +1,64 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2023 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++class OpenProject::JournalFormatter::TimeEntryNamedAssociation < JournalFormatter::NamedAssociation+ private++ def format_details(key, values, cache:)+ # TODO - Confirm wording++ label = if values.first.nil?+ label(key)+ elsif values.last.nil?+ I18n.t("activity.item.time_entry.logged_for")+ # else+ # I18n.t("activity.item.time_entry.logged_for")+ end++ old_value, value = *format_values(values, key, cache:)++ [label, old_value, value]+ end++ # def format_html_details(label, old_value, value)+ # label = content_tag(:strong, label)+ # old_value = content_tag('i', h(old_value)) if old_value.present?+ # value = content_tag('i', h(value)) if value.present?+ # value ||= ''++ # [label, old_value, value]+ # end++ # def render_ternary_detail_text(label, value, old_value, options)+ # binding.pry+ # return I18n.t(:text_journal_deleted_subproject, label:, old: old_value) if value.blank?+ # return I18n.t(:text_journal_of, label:, value:) if old_value.blank?++ # super+ # end+enddiff --git a/modules/costs/app/models/time_entry.rb b/modules/costs/app/models/time_entry.rbindex b18d5b2e62f..ef0b33b9016 100644--- a/modules/costs/app/models/time_entry.rb+++ b/modules/costs/app/models/time_entry.rb@@ -59,7 +59,7 @@ class TimeEntry < ApplicationRecordregister_journal_formatted_fields(:time_entry_hours, 'hours')register_journal_formatted_fields(:named_association, 'work_package_id')- # register_journal_formatted_fields(:named_association, 'user_id')+ register_journal_formatted_fields(:time_entry_named_association, 'user_id')def self.update_all(updates, conditions = nil, options = {})# instead of a update_all, perform an individual update during work_package#move