tramway-core 1.9.7 → 1.9.8

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: df6a328c279dd1871957bf8851a856080ba81d2ce9fc8c4721ff05d4e5331611
4
- data.tar.gz: fafad584ace4ddfeadb2865ff695758bf82adcc06a19ca2ef30d1aade5a083ac
3
+ metadata.gz: 430efd71ac7c88ad99e9f694e9a69275eae2547584aab8304398fa1107980a76
4
+ data.tar.gz: da4601abe1d6b27e79908646a9f966430e16b11d4ea720101700d1054efe879f
5
5
  SHA512:
6
- metadata.gz: 842b72abd33c0c7e8bd4024551101ad34df8bea2bb90e8dc3a1abd9ed6afcabb5de8ad2b7408443ee25e32256e71921adbb3f372f2bb245556cb1f0c25b97f73
7
- data.tar.gz: 9694d549f73d6728b7cb599cf882b44bebd1196aa4bea48625a0803148d7fb65edcaebc10034ce3d8ce216159b918ca730b1b8ab6ca81c395f1176c943520fa8
6
+ metadata.gz: 9639e164d342d2a783031a42573985f0f0c9af9877826c8f06c8b60acf7b95482372ea938cde6d2f56d91edef19e3bdf78fbb5cf7ba5eecceb58239bbac9d398
7
+ data.tar.gz: 5eeb8adc7c07a0d8a2f7df339c58be45f63ba74d68b1bc34ed08ccf4e5df2b76508b1403dfae7c1574360e647cc6aeaba215a076aa79bd3cf69a1ccbf4a284b6
@@ -82,13 +82,15 @@ class Tramway::Core::ApplicationDecorator
82
82
  end.compact
83
83
  end
84
84
 
85
+ include Tramway::Core::Concerns::AttributesDecoratorHelper
86
+
85
87
  def attributes
86
88
  object.attributes.reduce({}) do |hash, attribute|
87
89
  value = try(attribute[0]) ? send(attribute[0]) : object.send(attribute[0])
88
90
  if attribute[0].to_s.in? object.class.state_machines.keys.map(&:to_s)
89
- hash.merge! attribute[0] => object.send("human_#{attribute[0]}_name")
91
+ hash.merge! attribute[0] => state_machine_view(object, attribute[0])
90
92
  elsif value.class.in? [ ActiveSupport::TimeWithZone, DateTime, Time ]
91
- hash.merge! attribute[0] => I18n.l(attribute[1])
93
+ hash.merge! attribute[0] => datetime_view(attribute[1])
92
94
  elsif value.class.superclass == ApplicationUploader
93
95
  tags = content_tag(:div) do
94
96
  if value.url.match(/jpg|JPG|png|PNG$/)
@@ -0,0 +1,9 @@
1
+ module Tramway::Core::Concerns::AttributesDecoratorHelper
2
+ def datetime_view(value)
3
+ I18n.l value
4
+ end
5
+
6
+ def state_machine_view(object, attribute_name)
7
+ object.send "human_#{attribute_name}_name"
8
+ end
9
+ end
@@ -33,6 +33,7 @@ module Tramway
33
33
  end
34
34
  end
35
35
  end
36
+
36
37
  # FIXME detect inhertited locales
37
38
  def human_state_name
38
39
  I18n.t "activerecord.state_machines.tramway/core/application_record.state.states.#{state}"
@@ -1,5 +1,5 @@
1
1
  module Tramway
2
2
  module Core
3
- VERSION = '1.9.7'
3
+ VERSION = '1.9.8'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.7
4
+ version: 1.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-29 00:00:00.000000000 Z
11
+ date: 2019-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: reform-rails
@@ -339,6 +339,7 @@ files:
339
339
  - app/controllers/tramway/core/application_controller.rb
340
340
  - app/decorators/tramway/core/application_decorated_collection.rb
341
341
  - app/decorators/tramway/core/application_decorator.rb
342
+ - app/decorators/tramway/core/concerns/attributes_decorator_helper.rb
342
343
  - app/forms/tramway/core/application_form.rb
343
344
  - app/forms/tramway/core/extendable_form.rb
344
345
  - app/forms/tramway/core/form_creator.rb