Skip to content

Commit

Permalink
journal history
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandermeindl committed Dec 11, 2024
1 parent 14ab525 commit 000b310
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
27 changes: 27 additions & 0 deletions app/helpers/additionals_journals_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
33 changes: 33 additions & 0 deletions app/views/additionals_journals/_history.html.slim
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 000b310

Please sign in to comment.