From 000b3104593fc7375bbec739cad5838c5fcecb6d Mon Sep 17 00:00:00 2001 From: Alexander Meindl Date: Wed, 11 Dec 2024 16:07:21 +0100 Subject: [PATCH] journal history --- app/helpers/additionals_journals_helper.rb | 27 +++++++++++++++ .../additionals_journals/_history.html.slim | 33 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 app/views/additionals_journals/_history.html.slim diff --git a/app/helpers/additionals_journals_helper.rb b/app/helpers/additionals_journals_helper.rb index b23aa8ab..23e92585 100644 --- a/app/helpers/additionals_journals_helper.rb +++ b/app/helpers/additionals_journals_helper.rb @@ -3,6 +3,33 @@ module AdditionalsJournalsHelper MultipleValuesDetail = Struct.new :property, :prop_key, :custom_field, :old_value, :value + def entity_history_tabs(entity, journals, template_dir: nil) + tabs = [] + has_notes = false + + template_dir ||= entity.class.name.underscore.pluralize + + if journals.present? + tabs << { name: 'history', + partial: "#{template_dir}/tabs/history", + onclick: 'showIssueHistory("history", this.href)', + locals: { tab_name: 'history' }, + label: :label_history } + + has_notes = journals.any? { |value| value.notes.present? } + end + + return tabs unless has_notes + + tabs << { name: 'notes', + partial: "#{template_dir}/tabs/history", + onclick: 'showIssueHistory("notes", this.href)', + locals: { tab_name: 'notes' }, + label: :label_issue_history_notes } + + tabs + end + # Returns the textual representation of a journal details # as an array of strings def entity_details_to_strings(entity, details, **options) diff --git a/app/views/additionals_journals/_history.html.slim b/app/views/additionals_journals/_history.html.slim new file mode 100644 index 00000000..b09cf1d0 --- /dev/null +++ b/app/views/additionals_journals/_history.html.slim @@ -0,0 +1,33 @@ +- edit_mode = false +- journals.each do |journal| + - next if tab[:name] == 'notes' && journal.notes.blank? + - edit_mode = true if !edit_mode && journal.editable_by?(User.current) + + div id="change-#{journal.id}" class="#{journal.css_classes}" + div id="note-#{journal.indice}" + .contextual + span.journal-actions + = render_entity_journal_actions entry, journal + a.journal-link href="#note-#{journal.indice}" + |# + = journal.indice + h4.note-header + = avatar journal.user, size: 24 + = authoring journal.created_on, journal.user, label: :label_updated_time_by + = render_author_indicator entry, journal + ' + = render_journal_update_info journal + + - if journal.details.any? + ul.details + - entity_details_to_strings(entry, journal.visible_details).each do |string| + li = string + - if Setting.thumbnails_enabled? && (thumbnail_attachments = journal_thumbnail_attachments journal).any? + .thumbnails + - thumbnail_attachments.each do |attachment| + div = thumbnail_tag attachment + + = render_notes nil, journal if journal.notes.present? + +- if edit_mode + - heads_for_wiki_formatter