Merge pull request #3094 from differentreality/2738_history_changes_deleted_models

Fix version history for deleted models
This commit is contained in:
Henne Vogelsang 2023-04-19 13:28:17 +02:00 committed by GitHub
commit ef8863298e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -21,6 +21,20 @@
%th Action %th Action
%tbody %tbody
- if version.event != 'destroy' - if version.event != 'destroy'
-# For deleted models we cannot use all of PaperTrail functionalities, so we simplify the output
- if version.item_type == 'Campaign' || version.item_type == 'Target' || version.item_type == 'EventAttachment'
- changeset = version.object_changes.split("\n")
-# object_changes field is now in the format of ["---", "id:", "- ", "- 6", "conference_id:", "- ", "- 2"]
- changeset.shift
- changeset.each_slice(3).each do |attribute_changes|
%tr
-# Remove the dash at the beginning
- attribute_changes.map!{ |x| x.sub(/^- /, '') }
%td= attribute_changes[0]
- if version.event != 'create'
%td= attribute_changes[1]
%td= attribute_changes[2]
- else
- version.changeset.reject{ |_, values| values[0].blank? && values[1].blank? }.each do |attribute, values| - version.changeset.reject{ |_, values| values[0].blank? && values[1].blank? }.each do |attribute, values|
%tr %tr
%td= attribute %td= attribute