tramway-core 1.18.3.4 → 1.18.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/assets/javascripts/tramway/core/application.js +2 -0
- data/app/decorators/tramway/core/attributes/view_helper.rb +3 -1
- data/app/decorators/tramway/core/concerns/attributes_decorator_helper.rb +16 -1
- data/app/forms/tramway/core/application_form.rb +9 -5
- data/app/models/tramway/core/application_record.rb +2 -1
- data/lib/tramway/core/generators.rb +4 -2
- data/lib/tramway/core/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28bca828825ed63cfecc857febadda0ba9cc44b43b851009982de2dec760c3ab
|
4
|
+
data.tar.gz: 1c4cb7d7dd804f538b3c0acb4e3c54d2dd42799583fc89c76467ee17c7f68d9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf9ed7162852e76ff1bb5f67a144719da05ba2643a604bb753a3d361863f4ea573e553e9f1ae27f5b7c8be9846940552a26c1e3035d556f345b592f2afc2b346
|
7
|
+
data.tar.gz: b7533a50cd1e1803c05af20ba9433b72bf551b31faf1da0f6eed59300b821f73472af8f3862915f9cce48601412f3d8e2da6c4245eb8e41bcecd33f8a704a65c
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Tramway::Core
|
1
|
+
# Tramway::Core   [](https://badge.fury.io/rb/tramway-core)
|
2
2
|
|
3
3
|
*If you need translation of this Readme, please message us kalashnikov@ulmic.ru. We'll translate for you and post to this page*
|
4
4
|
|
@@ -15,8 +15,10 @@ module Tramway::Core::Attributes::ViewHelper
|
|
15
15
|
def view_by_value(object, value, attribute)
|
16
16
|
if value.class.in? [ActiveSupport::TimeWithZone, DateTime, Time]
|
17
17
|
datetime_view(attribute[1])
|
18
|
-
elsif value.class
|
18
|
+
elsif value.class == PhotoUploader
|
19
19
|
image_view(object.send(attribute[0]))
|
20
|
+
elsif value.class == FileUploader
|
21
|
+
file_view(object.send(attribute[0]))
|
20
22
|
elsif value.is_a? Enumerize::Value
|
21
23
|
enumerize_view(value)
|
22
24
|
else
|
@@ -25,6 +25,17 @@ module Tramway::Core::Concerns::AttributesDecoratorHelper
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
def file_view(original, filename: nil)
|
29
|
+
return unless original.present?
|
30
|
+
|
31
|
+
filename ||= build_filename(original)
|
32
|
+
content_tag(:div) do
|
33
|
+
concat filename
|
34
|
+
concat ' '
|
35
|
+
concat download_button(filename: filename, original: original) if filename
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
28
39
|
def enumerize_view(value)
|
29
40
|
value.text
|
30
41
|
end
|
@@ -65,6 +76,10 @@ module Tramway::Core::Concerns::AttributesDecoratorHelper
|
|
65
76
|
message: e.message, attribute_name: attribute_name
|
66
77
|
)
|
67
78
|
end
|
68
|
-
concat
|
79
|
+
concat download_button(filename: filename, original: original) if filename
|
80
|
+
end
|
81
|
+
|
82
|
+
def download_button(filename:, original:)
|
83
|
+
link_to(fa_icon(:download), src_original(original), class: 'btn btn-success', download: filename)
|
69
84
|
end
|
70
85
|
end
|
@@ -61,12 +61,16 @@ class Tramway::Core::ApplicationForm
|
|
61
61
|
options = @@model_class.reflect_on_all_associations(:belongs_to).select do |a|
|
62
62
|
a.name == association.to_sym
|
63
63
|
end.first&.options
|
64
|
+
add_polymorphic_association hash, association, options
|
65
|
+
end
|
66
|
+
end
|
64
67
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
68
|
+
def add_polymorphic_association(hash, association, options)
|
69
|
+
if options&.dig(:polymorphic)
|
70
|
+
hash.merge association => @@model_class.send("#{association}_type").values
|
71
|
+
elsif options
|
72
|
+
hash.merge(association => (options[:class_name] || association.to_s.camelize).constantize)
|
73
|
+
else
|
70
74
|
hash
|
71
75
|
end
|
72
76
|
end
|
@@ -25,7 +25,8 @@ class Tramway::Core::ApplicationRecord < ActiveRecord::Base
|
|
25
25
|
include ::PgSearch::Model
|
26
26
|
|
27
27
|
def creator
|
28
|
-
audits.where(action: :create).first
|
28
|
+
creation_event = audits.where(action: :create).first
|
29
|
+
creation_event.user if creation_event.user_id.present?
|
29
30
|
end
|
30
31
|
|
31
32
|
# FIXME: detect inhertited locales
|
data/lib/tramway/core/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tramway-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.18.
|
4
|
+
version: 1.18.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Kalashnikov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-10-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: audited
|