avo-diff_field 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e31ee26f39ea5c8924d1b2b57a762f469ed63a2a67f1a4d6150c51154bca90f
4
- data.tar.gz: 0f408416ccb652ea23872e50fa5882f894382a8091ad16dafb2baf4b18ca0113
3
+ metadata.gz: 81dd10a1bf80eb260edb069cb2f3980950788d78e9e4c4c70da7f0b684d238a6
4
+ data.tar.gz: 7629f9c59c58d0fd21e22667ab3eea630755e0b87b910859cb6c578cfd47fabb
5
5
  SHA512:
6
- metadata.gz: fe546b8418c5e00e9555cfb6daa9e43e4821aa0cbeeb92517748690b67177203a2e85beb8b5621342c12118db54e2e62d7fc6d423070986b954da49ac62d5280
7
- data.tar.gz: 50c330532a62d9c727fbca0165ea9e75a4d67b956d629186914bc4fb4e33a76ed3fb4f189a466ee17b9ba31339118538c23f5c22542bf1b855141e77d20f87f7
6
+ metadata.gz: 68ae3563cd16900dec9b1952843546cc9685f3474f5cc6c82ad61fca0991f93747567019fd68153dfc55c4824f214763a7175d23dd4629c8160b151dc7b2de67
7
+ data.tar.gz: 8c51c749e6e1bd93699ff2c3cd1ef46ec1cb8ab9cdd86b680cac2ddf6678bd3aa48c2a6d66c9d00e4fd5989a68e371a8a0d3590e6d4cb72f09af7cc04de5a621
@@ -4,17 +4,23 @@ class Avo::DiffField::Fields::DiffField::ShowComponent < Avo::Fields::ShowCompon
4
4
  def initialize **args
5
5
  super(**args)
6
6
  @diffy_value = @field.value&.map do |k, v|
7
- case @field.record.try(:action) || @field.record.try(:event)
8
- when 'update'
7
+ if @field.record.class == "PaperTrail::Version".safe_constantize
9
8
  left_value = v[0]
10
9
  right_value = v[1]
11
- when 'destroy'
12
- left_value = v
13
- right_value = ''
14
- when 'create'
15
- left_value = ''
16
- right_value = v
10
+ elsif @field.record.class == "Audited::Audit".safe_constantize
11
+ case @field.record.action
12
+ when 'update'
13
+ left_value = v[0]
14
+ right_value = v[1]
15
+ when 'destroy'
16
+ left_value = v
17
+ right_value = ''
18
+ when 'create'
19
+ left_value = ''
20
+ right_value = v
21
+ end
17
22
  end
23
+
18
24
  [k, Diffy::Diff.new(left_value.to_s, right_value.to_s, format: :html, include_plus_and_minus_in_html: true)]
19
25
  end
20
26
  end
@@ -1,5 +1,5 @@
1
1
  module Avo
2
2
  module DiffField
3
- VERSION = "0.0.3" unless const_defined?(:VERSION)
3
+ VERSION = "0.0.4" unless const_defined?(:VERSION)
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avo-diff_field
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin