tramway-core 1.17.7 → 1.17.9.1

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: 9eefb734f64738208d5ebff801e31274167b6a7332001243b24e0612435e2b16
4
- data.tar.gz: 2d26b33208ea81fb18c347d96e7dc7aecf95e4786121dbc9c834dc4e4f17309f
3
+ metadata.gz: 0d8a307c16b02463c022b9f145452524200abc08aec25f72a0abf57d389c2495
4
+ data.tar.gz: 886e56668981f2f0623ab5b84d4219e88e8c762cd4e7ef426d8782b1a579cfef
5
5
  SHA512:
6
- metadata.gz: bac5a81a3324c4ce8de46df25a375aceaf7b80acbc1a3cc6f56752db1c8d8fb6c464c268b3c7160e13a24eb116d9ca4a93f1a0ae38f71de344e95152ca69131a
7
- data.tar.gz: 8c1b83417ffdcbcd7c3ed79d5d2312d00357d5d48fe26ef4a351168ac0577f9dd3989df440c15707dad688c67204fd6bc7f5f9bac029fe1d96d04ad5da4a6a19
6
+ metadata.gz: 252e6926182c9f443a75cc9075804f4075ba7224ef888d2399ac910b1d00435cd92209bb367607da4a60cb7ff8d740388accdb02de45d878b44a8a9ef2ac5769
7
+ data.tar.gz: d01a72a18c43dfdcd3cf53d710a8f8e4a87db3d5a24d9480c4009993b58cfdb9a5ad36a740f521c8558b00e397597a7bf4fbee052deabe10ce6b6c5f1fe4f2a2
data/README.md CHANGED
@@ -157,7 +157,7 @@ copy_to_clipboard "some_id" # some_id is HTML id of element. Content of this ele
157
157
  #### 1. Generate model that you to use. We create Organization, for example
158
158
 
159
159
  ```shell
160
- rails g model organization name:text public_name:text tagline:text address:text phone:text coordinates:point, state: text # remember! State field is required, if you use tramway-admin
160
+ 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
161
161
  rails db:migrate
162
162
  ```
163
163
 
@@ -19,9 +19,9 @@ module Tramway::Core::InputsHelper
19
19
  options: options.merge(
20
20
  as: :select,
21
21
  label_method: ->(obj) { "#{obj.class.model_name.human} | #{obj.name}" },
22
- value_method: lambda do |obj|
22
+ value_method: lambda { |obj|
23
23
  "#{obj.class.to_s.underscore.sub(/_decorator$/, '')}_#{obj.id}"
24
- end
24
+ }
25
25
  )
26
26
  end
27
27
 
@@ -63,27 +63,28 @@ module Tramway::Core::InputsHelper
63
63
  end
64
64
 
65
65
  def simple_params(**options)
66
- builded_options = {
67
- as: options[:type],
68
- label: false,
69
- input_html: {
70
- name: "#{options[:object]}[#{options[:property]}]",
71
- id: "#{options[:object]}_#{options[:property]}",
72
- value: build_simple_value(
73
- *options.values_at(:form_object, :property, :value),
74
- options.dig(:options, :input_html, :value)
75
- )
76
- }
77
- }
66
+ builded_options = { as: options[:type], label: false,
67
+ input_html: {
68
+ name: "#{options[:object]}[#{options[:property]}]",
69
+ id: "#{options[:object]}_#{options[:property]}",
70
+ value: build_simple_value(
71
+ *options.values_at(:form_object, :property, :value),
72
+ options.dig(:options, :input_html, :value)
73
+ )
74
+ } }
75
+ merge_with_user_options builded_options, options
76
+ end
77
+
78
+ def build_simple_value(form_object, property, value, input_html_value)
79
+ value_to_add = input_html_value || value
80
+ value_to_add || form_object.send(property)
81
+ end
82
+
83
+ def merge_with_user_options(builded_options, options)
78
84
  if options[:options].present?
79
85
  options[:options].dig(:input_html)&.delete(:value)
80
86
  builded_options.merge!(options) || {}
81
87
  end
82
88
  builded_options
83
89
  end
84
-
85
- def build_simple_value(form_object, property, value, input_html_value)
86
- value_to_add = input_html_value ? input_html_value : value
87
- value_to_add || form_object.send(property)
88
- end
89
90
  end
@@ -42,6 +42,15 @@ class Tramway::Core::ApplicationRecord < ActiveRecord::Base
42
42
  def search_by(*attributes, **associations)
43
43
  pg_search_scope :full_text_search, against: attributes, associated_against: associations
44
44
  end
45
+
46
+ def uploader(attribute_name, uploader_name, **options)
47
+ mount_uploader attribute_name, "#{uploader_name.to_s.camelize}Uploader".constantize
48
+ @versions = options[:versions] if uploader_name == :photo
49
+ end
50
+
51
+ def photo_versions
52
+ @versions
53
+ end
45
54
  end
46
55
 
47
56
  # FIXME: detect inhertited locales
@@ -6,6 +6,7 @@ class ApplicationUploader < CarrierWave::Uploader::Base
6
6
  storage :file
7
7
 
8
8
  def store_dir
9
- "system/uploads/#{model.class.model_name.to_s.underscore}/#{mounted_as}/#{model.id}"
9
+ directory_id = (model.reload && model.try(:uuid)) || model.id
10
+ "system/uploads/#{model.class.model_name.to_s.underscore}/#{mounted_as}/#{directory_id}"
10
11
  end
11
12
  end
@@ -20,29 +20,14 @@ class PhotoUploader < ApplicationUploader
20
20
  super && width.present? && height.present?
21
21
  end
22
22
 
23
- version :medium do
23
+ version :medium, if: :medium_version_is_needed? do
24
24
  process resize_to_fill: [400, 400]
25
25
  end
26
26
 
27
- version :small do
27
+ version :small, if: :small_version_is_needed? do
28
28
  process resize_to_fill: [100, 100]
29
29
  end
30
30
 
31
- # FIXME: move to tramway-landing uploader
32
- version :card do
33
- process resize_to_fill: [400, 400, 'North']
34
- end
35
-
36
- # FIXME: move to tramway-landing uploader
37
- version :horizontal do
38
- process resize_to_fill: [800, 350, 'North']
39
- end
40
-
41
- # FIXME: move to tramway-landing uploader
42
- version :mini do
43
- process resize_to_limit: [300, nil]
44
- end
45
-
46
31
  attr_reader :width, :height
47
32
 
48
33
  before :cache, :capture_size
@@ -58,4 +43,16 @@ class PhotoUploader < ApplicationUploader
58
43
  @width, @height = `identify -format "%wx %h" #{file.path}`.split(/x/).map(&:to_i)
59
44
  end
60
45
  end
46
+
47
+ def medium_version_is_needed?(_new_file)
48
+ version_is_needed? :medium
49
+ end
50
+
51
+ def small_version_is_needed?(_new_file)
52
+ version_is_needed? :small
53
+ end
54
+
55
+ def version_is_needed?(version)
56
+ model.class.photo_versions&.include? version
57
+ end
61
58
  end
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Tramway::Core::Application
4
- attr_accessor :name, :url, :model_class, :title, :tagline, :found_date, :phone, :email, :main_image, :favicon
4
+ attr_accessor :name, :url, :model_class, :title, :tagline, :found_date, :phone, :email, :main_image, :favicon,
5
+ :short_description
5
6
 
6
7
  def public_name
7
8
  name.to_s.gsub('_', ' ').camelize
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Core
5
- VERSION = '1.17.7'
5
+ VERSION = '1.17.9.1'
6
6
  end
7
7
  end
@@ -35,6 +35,6 @@ tramway:
35
35
  attributes:
36
36
  method_is_reserved_word: "Method `%{attribute_name}` is reserved word. Please, create or delegate method in %{class_name} with another name."
37
37
  title:
38
- please_implement_title: "Please, implement `title` method in a %{class_name} or %{object_class}"
38
+ please_implement_title: "Please, implement `title` method in a %{class_name} or delegate it from %{object_class}"
39
39
  link:
40
40
  method_link_uses_file_attribute: "Method `link` uses `file` attribute of the decorated object. If decorated object doesn't contain `file`, you shouldn't use `link` method."
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.17.7
4
+ version: 1.17.9.1
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-04-08 00:00:00.000000000 Z
12
+ date: 2020-04-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: audited