Merge pull request #3094 from differentreality/2738_history_changes_deleted_models
Fix version history for deleted models
This commit is contained in:
commit
ef8863298e
1 changed files with 40 additions and 26 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue