tramway-core 1.18.1.2 → 1.18.3.3

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: 2eca2bd589fed76d9385bbed1319fbd061e418521966d81561bf8ffeaa3648c9
4
- data.tar.gz: 67488c6b5304f9941220b9bcb97d6ca5271e414e323d7c64806805e5aea5deb5
3
+ metadata.gz: 5cf506df0d33b4bb514fb338de95dfce0296dd921c5156fee49b427896516a67
4
+ data.tar.gz: e13a9a940fc2f2fa54d0e9a450003f469cb357e99b0f86549f0e8f34df8a694c
5
5
  SHA512:
6
- metadata.gz: 3f8da95bb6038a4e3bb956fcf0a7851cb2e81a82392a92fd00a1d1337eaad0a13f5a852a2a8701bcead04eb1250ac17335d5bf44deb18c4dbcf3df980026e275
7
- data.tar.gz: be00745caa58c4703b5dca9eb53ef6dc8d16917d39c510f0d95efac655c165fa5eec00e6813424eba5edd0f78377c60bbdb77688a3f7895b4ab8d9910f051617
6
+ metadata.gz: 400e256729e362e04970979425fa31650a4741034671d7ecf37e11770e76698423d166c220ffd852d2bd43238e7584c10e3bfd62e81f9d1f138c03aa62094c2f
7
+ data.tar.gz: a6946fbee6c8a47b8f3098c2c96e21b75e389c511b68c36ce846ed8914ddd9d8a0dc7d0d8a2cc1632391e4d4efb370d37bc8deda8185abee27b30ddda2043e7c
data/README.md CHANGED
@@ -46,6 +46,7 @@ Interface: `uploader(attribute_name, uploader_name, **options)`
46
46
  * uploader_name - **short** uploader name. You need to connect uploaders which are compatible with Tramway. Available uploaders:
47
47
  * :photo - you can see it [here](https://github.com/Purple-Magic/tramway-core/blob/develop/app/uploaders/photo_uploader.rb)
48
48
  * :file - you can see it [here](https://github.com/Purple-Magic/tramway-core/blob/develop/app/uploaders/file_uploader.rb)
49
+ * :ico - you can see [here](https://github.com/Purple-Magic/tramway-core/blob/develop/app/uploaders/ico_uploader.rb)
49
50
  * options - you are available to set options for uploaders exactly for this model. Available options:
50
51
  * versions - **only for :photo**. Set needed versions for file to be cropped. If empty - 0 zero versions will be used. All versions you can see [here](https://github.com/Purple-Magic/tramway-core/blob/develop/app/uploaders/photo_uploader.rb)
51
52
  * extensions - whitelist of file extensions. If empty will be used default whitelist from the uploaders (links above)
@@ -176,12 +177,28 @@ Something like this:
176
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
177
178
  ```
178
179
 
179
- ## 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
180
197
 
181
198
  #### 1. Generate model that you to use. We create Organization, for example
182
199
 
183
200
  ```shell
184
- rails g model organization name:text public_name:text tagline:text address:text phone:text coordinates:point state: text favicon:text # remember! State field is required, if you use tramway-admin
201
+ rails g tramway:core:application
185
202
  rails db:migrate
186
203
  ```
187
204
 
@@ -195,7 +212,7 @@ Tramway::Core.initialize_application model_class: Organization
195
212
 
196
213
  ```ruby
197
214
  rails c
198
- 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'
199
216
  ```
200
217
 
201
218
  #### 4. Add model to singleton to the `tramway-admin` admin panel to be able to change its data
@@ -1,7 +1,7 @@
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
@@ -68,6 +68,10 @@ class Tramway::Core::ApplicationDecorator
68
68
  def model_name
69
69
  model_class.try(:model_name)
70
70
  end
71
+
72
+ def list_filters
73
+ {}
74
+ end
71
75
  end
72
76
 
73
77
  def link
@@ -29,14 +29,17 @@ module Tramway::Core::Associations::ClassHelper
29
29
  def define_main_association_method(association_name, decorator)
30
30
  define_method association_name do
31
31
  association = object.class.reflect_on_association(association_name)
32
- return if association_type(association) == :has_one && object.send(association_name) == nil
32
+ type = association_type(association)
33
+ return if association_has_one_without_object(object, association_name, type)
33
34
 
34
35
  check_association object, association_name, association
35
36
  decorator_class_name = decorator || decorator_class_name(class_name(association))
36
- if association_type(association).in? %i[has_many has_and_belongs_to_many]
37
- return associations_collection(object, association_name, decorator_class_name)
37
+ case type
38
+ when :has_many, :has_and_belongs_to_many
39
+ associations_collection(object, association_name, decorator_class_name)
40
+ when :belongs_to, :has_one
41
+ decorator_class_name.decorate(association_object(object, association_name))
38
42
  end
39
- return decorator_class_name.decorate object.send association_name if association_type(association).in? [ :belongs_to, :has_one ]
40
43
  end
41
44
  end
42
45
  end
@@ -40,11 +40,19 @@ module Tramway::Core::Associations::ObjectHelper
40
40
 
41
41
  begin
42
42
  form_class.constantize
43
- rescue
43
+ rescue StandardError
44
44
  Tramway::Error.raise_error(
45
45
  :tramway, :core, :associations, :object_helper, :habtm_add_class_not_defined,
46
46
  class: form_class, association_name: association_name
47
47
  )
48
48
  end
49
49
  end
50
+
51
+ def association_has_one_without_object(object, association_name, association_type)
52
+ association_type == :has_one && object.send(association_name).nil?
53
+ end
54
+
55
+ def association_object(object, association_name)
56
+ object.send association_name
57
+ end
50
58
  end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class IcoUploader < ApplicationUploader
4
+ def extension_whitelist
5
+ model.class.file_extensions || %w[ico]
6
+ end
7
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Core
5
- VERSION = '1.18.1.2'
5
+ VERSION = '1.18.3.3'
6
6
  end
7
7
  end
@@ -22,6 +22,7 @@ class Tramway::Error < RuntimeError
22
22
  @errors ||= YAML.load_file("#{Tramway::Core.root}/yaml/errors.yml").with_indifferent_access
23
23
  error = @errors.dig(*coordinates)
24
24
  raise 'Error is not defined in YAML' unless error
25
+
25
26
  options.each do |pair|
26
27
  error.gsub!("%{#{pair[0]}}", pair[1].to_s)
27
28
  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.1.2
4
+ version: 1.18.3.3
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-05-01 00:00:00.000000000 Z
12
+ date: 2020-08-10 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
@@ -361,6 +355,7 @@ files:
361
355
  - app/models/tramway/core/application_record.rb
362
356
  - app/uploaders/application_uploader.rb
363
357
  - app/uploaders/file_uploader.rb
358
+ - app/uploaders/ico_uploader.rb
364
359
  - app/uploaders/image_defaults.rb
365
360
  - app/uploaders/photo_uploader.rb
366
361
  - app/views/tramway/core/404.haml