tramway-core 1.18.3.2 → 1.18.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c4642075ecb6eb14dd53a6c0c34da6089ca1e8ffac92baee5e750c8d3ca215c9
4
- data.tar.gz: 496474d5bdb285a300f1d8877da45d68743b4527c4a1974915395406a798cd6a
3
+ metadata.gz: b879028d7f87c89e93ba14221569147d80640c5d61f3cb1812d8755953f372e9
4
+ data.tar.gz: f0ae36c46f41aa516b7fc3b260e6c62e053f57ea6425eb93e9a69d952c3b3183
5
5
  SHA512:
6
- metadata.gz: 4d0b406d85678d22316cef99327f517c3d9ee709519458a233ae9bacaac22a8a22afdea28a28379bcc37e2e81d2a841f862aff216531d066272e37612dff9365
7
- data.tar.gz: f4fd66bbbecd7bea23b934208fc7b8e721e4bd9054bf5f67946be29eaa17cd854a25d0b303b5f792f388ebd137c70e48e60b5f9a4d00ed24eb9cb1bb5876f81a
6
+ metadata.gz: 98a707a7f0ad29077c30f04ce8d3f70d98ae10ef611fccee07861b3ed9b983e498434cf51397b251599c780635623bf8bfb8054edd26f71049a7bb8d491cebd1
7
+ data.tar.gz: 7fac100f8f52b257923974684b8d9b3a64758104a2f497714e047a070679260a8bfe0ad5dd8e29fae2d749a5deee4f943e1a1b00f56b5a2aac175e3deb0053f7
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Tramway::Core
1
+ # Tramway::Core ![Ruby](https://github.com/Purple-Magic/tramway-core/workflows/Tests/badge.svg) ![Ruby](https://github.com/Purple-Magic/tramway-core/workflows/Rubocop/badge.svg) [![Gem Version](https://badge.fury.io/rb/tramway-core.svg)](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
 
@@ -1,12 +1,14 @@
1
+ // require popper FIXME should be optional requiring
1
2
  //= require jquery
2
3
  //= require jquery_ujs
3
4
  //= require jquery3
4
5
  //= require popper
6
+ // require popper FIXME should be optional requiring
5
7
  //= require bootstrap
6
8
  //= require bootstrap-datepicker-1.8.0
7
9
  //= require bootstrap-datepicker-1.8.0.ru.min
8
10
  //= require font_awesome5
9
- //= require clipboard
11
+ // require clipboard FIXME should be optional requiring
10
12
  //= require_tree .
11
13
 
12
14
  window.i18n_locale = function(locale) {
@@ -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.superclass == ApplicationUploader
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 link_to(fa_icon(:download), src_original(original), class: 'btn btn-success', download: filename) if filename
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
- if options&.dig(:polymorphic)
66
- hash.merge! association => @@model_class.send("#{association}_type").values
67
- elsif options
68
- hash.merge!(association => (options[:class_name] || association.to_s.camelize).constantize)
69
- end
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
@@ -1,6 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Tramway::Core
4
- module Generators
5
- end
3
+ module Tramway::Core::Generators
6
4
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Core
5
- VERSION = '1.18.3.2'
5
+ VERSION = '1.18.5'
6
6
  end
7
7
  end
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.3.2
4
+ version: 1.18.5
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-07-24 00:00:00.000000000 Z
12
+ date: 2020-09-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: audited