tramway-core 1.17.6.1 → 1.17.9
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/helpers/tramway/core/inputs_helper.rb +24 -14
- data/app/models/tramway/core/application_record.rb +9 -0
- data/app/uploaders/application_uploader.rb +2 -1
- data/app/uploaders/photo_uploader.rb +14 -17
- data/app/views/tramway/core/shared/_input.html.haml +3 -2
- data/lib/tramway/core/application.rb +2 -1
- data/lib/tramway/core/version.rb +1 -1
- data/lib/yaml/errors.yml +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: 444dff1263e8b8edbbdf21db2c4a07dd4bf3d1b5daa92b9bfce797e109a1c386
|
4
|
+
data.tar.gz: 77a4af707f2feb4e25b5d337752210fbde734f4415203c3fbcac66c716f466b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 866c0a022d0583b30fee275c587f54a1890f21200a0369c38e29dd06b7539b9414ed04bc40dc367c0db9c6c889e34b9ddca19158ced7bbaa921e41c92e7160b2
|
7
|
+
data.tar.gz: 68701c75520dca9e137a81c6b8f926bbf5b7955eef9ef4d08ebb51b9fda10e92be6f87089024d55bb60a540dec9d522d3ab25b0b28441a92577fffddb60d3d50
|
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
|
22
|
+
value_method: lambda { |obj|
|
23
23
|
"#{obj.class.to_s.underscore.sub(/_decorator$/, '')}_#{obj.id}"
|
24
|
-
|
24
|
+
}
|
25
25
|
)
|
26
26
|
end
|
27
27
|
|
@@ -62,19 +62,29 @@ module Tramway::Core::InputsHelper
|
|
62
62
|
}.merge options
|
63
63
|
end
|
64
64
|
|
65
|
-
def
|
66
|
-
{
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
65
|
+
def simple_params(**options)
|
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)
|
75
81
|
end
|
76
82
|
|
77
|
-
def
|
78
|
-
|
83
|
+
def merge_with_user_options(builded_options, options)
|
84
|
+
if options[:options].present?
|
85
|
+
options[:options].dig(:input_html)&.delete(:value)
|
86
|
+
builded_options.merge!(options) || {}
|
87
|
+
end
|
88
|
+
builded_options
|
79
89
|
end
|
80
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
|
-
|
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
|
@@ -6,7 +6,8 @@
|
|
6
6
|
- type = type[:type]
|
7
7
|
- if type.class.in?([ Symbol, String ]) || type&.dig(:input_options)
|
8
8
|
- type = type.to_sym
|
9
|
-
|
9
|
+
- unless type == :hidden
|
10
|
+
= form.label form_object.model.class.human_attribute_name property
|
10
11
|
- case type
|
11
12
|
- when :default
|
12
13
|
= form.input property, **default_params(**input_params)
|
@@ -15,7 +16,7 @@
|
|
15
16
|
- when :polymorphic_association
|
16
17
|
= form.input property, **polymorphic_association_params(**input_params.merge(value: value))
|
17
18
|
- else
|
18
|
-
= form.input property, **
|
19
|
+
= form.input property, **simple_params(**input_params.merge(type: type))
|
19
20
|
- else
|
20
21
|
- property_value = form_object.model.values.present? && form_object.model.values[property.to_s]
|
21
22
|
= render 'tramway/core/shared/input_extended', field: type[:extended_form_property], class_name: :record, value: property_value, f: form
|
@@ -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
|
data/lib/tramway/core/version.rb
CHANGED
data/lib/yaml/errors.yml
CHANGED
@@ -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.
|
4
|
+
version: 1.17.9
|
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-
|
12
|
+
date: 2020-04-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: audited
|