tramway-core 1.18.3.1 → 1.18.4

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: 54caa49641af517f7999adde3d7f7f757b528456b0d1a7e999de0af99419b08a
4
- data.tar.gz: 1ebba7d8790d3dfd465dfd3dbe4f9118bb235f09b3daed23d4914a442f673aa4
3
+ metadata.gz: cd7c92b51cc68200779758562f6b9e2e8749d996344d9b9b4b6352e18e18c468
4
+ data.tar.gz: 07a2755db29397428160c07ccec045c28b5f56bf9dbea3a73fc8c9ebd7655b2f
5
5
  SHA512:
6
- metadata.gz: 9e5e6af1ec6aaed1a8abca8347ccdfcc871e753e520a4b39fbaf24f1b30fa44a723e876c5c3cb25f9426d5411a311fc3e4399f33b3f1aa0a156c3234049bfa31
7
- data.tar.gz: d38c5cdaaedf73eeb3eadbae99405852afd4aecb50e6c4b406b4e8e0ea9903c59644b9b1c558eb66623a49e82e4279b0241ad957fbe2443385ef9199e3db3907
6
+ metadata.gz: d934a4a8c7400a8733ce57c7a6001ba1f09d3ca3cf87656db86e8dfcaf16a7efe4f8309414dac496a11cc0a0887ebb1b97acb431aec68b4210ab889aa7ed79ee
7
+ data.tar.gz: 160d50747704912eba0a31035c3137fe9f48cbb5705d3823404bc97607adf31a8b8ff6c0abd100725b84fd9573811b14ef9d56b7c9a8a68495d7cd69c2955747
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
 
@@ -177,7 +177,23 @@ Something like this:
177
177
  copy_to_clipboard "some_id" # some_id is HTML id of element. Content of this element will be copied to the clipboard after pressing the button
178
178
  ```
179
179
 
180
- ## How to create model that will be an Application Model for the Tramway
180
+ # Every Tramway application need initialized @application object (or if you create Tramway plugin, it should be @application_engine object).
181
+
182
+ You don't need to initialize this object yourself, just configurate application with Tramway. You have **2** options of this:
183
+
184
+ ## Option 1. If you want to change @application object just in the code base.
185
+
186
+ ```shell
187
+ rails g tramway:core:application
188
+ ```
189
+
190
+ *config/initializers/tramway.rb*
191
+
192
+ ```ruby
193
+ Tramway::Core.initialize_application name: :your_application_name
194
+ ```
195
+
196
+ ## Option 2. If you want to change @application object from admin panel. How to create model that will be an Application Model for the Tramway
181
197
 
182
198
  #### 1. Generate model that you to use. We create Organization, for example
183
199
 
@@ -196,7 +212,7 @@ Tramway::Core.initialize_application model_class: Organization
196
212
 
197
213
  ```ruby
198
214
  rails c
199
- Organization.create! public_name: 'Tramway', name: :organization, tagline: 'Tramway is not buggy, LOL!'
215
+ Organization.create! public_name: 'Tramway', name: :organization, tagline: 'Tramway is not buggy, LOL!', main_image: 'https://raw.githubusercontent.com/ulmic/tramway-dev/develop/logo.png'
200
216
  ```
201
217
 
202
218
  #### 4. Add model to singleton to the `tramway-admin` admin panel to be able to change its data
@@ -1,12 +1,12 @@
1
1
  //= require jquery
2
2
  //= require jquery_ujs
3
3
  //= require jquery3
4
- //= require popper
4
+ // require popper FIXME should be optional requiring
5
5
  //= require bootstrap
6
6
  //= require bootstrap-datepicker-1.8.0
7
7
  //= require bootstrap-datepicker-1.8.0.ru.min
8
8
  //= require font_awesome5
9
- //= require clipboard
9
+ // require clipboard FIXME should be optional requiring
10
10
  //= require_tree .
11
11
 
12
12
  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,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Tramway::Core
4
- module Generators
3
+ module Tramway
4
+ module Core
5
+ module Generators
6
+ end
5
7
  end
6
8
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Core
5
- VERSION = '1.18.3.1'
5
+ VERSION = '1.18.4'
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.1
4
+ version: 1.18.4
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-06-02 00:00:00.000000000 Z
12
+ date: 2020-09-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: audited
@@ -119,22 +119,16 @@ dependencies:
119
119
  name: haml-rails
120
120
  requirement: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '1.0'
125
122
  - - ">="
126
123
  - !ruby/object:Gem::Version
127
- version: 1.0.0
124
+ version: '0'
128
125
  type: :runtime
129
126
  prerelease: false
130
127
  version_requirements: !ruby/object:Gem::Requirement
131
128
  requirements:
132
- - - "~>"
133
- - !ruby/object:Gem::Version
134
- version: '1.0'
135
129
  - - ">="
136
130
  - !ruby/object:Gem::Version
137
- version: 1.0.0
131
+ version: '0'
138
132
  - !ruby/object:Gem::Dependency
139
133
  name: kaminari
140
134
  requirement: !ruby/object:Gem::Requirement