tramway-core 2.0.2.2 → 3.0.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 +4 -4
- data/app/decorators/tramway/core/associations/object_helper.rb +1 -1
- data/app/forms/tramway/core/application_forms/submit_helper.rb +1 -1
- data/app/helpers/tramway/core/inputs/associations_helper.rb +1 -1
- data/app/helpers/tramway/core/inputs/polymorphic_associations_helper.rb +1 -1
- data/app/helpers/tramway/core/inputs_helper.rb +7 -0
- data/app/models/tramway/core/application_record.rb +7 -11
- data/lib/tramway/core/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c17a0e36bdb5090350f421917e739f044af1f07f3b6a527da8656cdc0175569
|
4
|
+
data.tar.gz: 4067d380e669a837e960eadd8003798ca30c6cb13ee2867dd1201225ca783ca3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 626efa3f64700a7b18dce52974e7c9cf860c26e8f4dd7355024504c4e43f8adb6a2975b1a4b98495e2608d3abc50e00367dad14d9029c81023c58caeff9f182d
|
7
|
+
data.tar.gz: e59aeaaefa0cc3bb453a20535b3b205bf5e041166bc2ddc306389b5d0d0c4708aee7eed14dce948e5b9b667321ca25e21d58e72181d814165796f377788131c7
|
@@ -30,7 +30,7 @@ module Tramway::Core::Associations::ObjectHelper
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def associations_collection(object, association_name, decorator_class_name)
|
33
|
-
object.send(association_name).
|
33
|
+
object.send(association_name).map do |association_object|
|
34
34
|
decorator_class_name.decorate association_object
|
35
35
|
end
|
36
36
|
end
|
@@ -20,7 +20,7 @@ module Tramway::Core::ApplicationForms::SubmitHelper
|
|
20
20
|
rescue StandardError => e
|
21
21
|
if e.try :name
|
22
22
|
Tramway::Error.raise_error :tramway, :core, :application_form, :save, :looks_like_you_have_method,
|
23
|
-
method_name: e.name.to_s.gsub('=', ''), model_class:
|
23
|
+
method_name: e.name.to_s.gsub('=', ''), model_class: model.class, class_name: self.class
|
24
24
|
else
|
25
25
|
raise e
|
26
26
|
end
|
@@ -5,7 +5,7 @@ module Tramway::Core::Inputs::AssociationsHelper
|
|
5
5
|
user = defined?(current_user) ? current_user : current_admin
|
6
6
|
full_class_name_association = form_object.class.full_class_name_association(property)
|
7
7
|
check_valid_association full_class_name_association
|
8
|
-
full_class_name_association.
|
8
|
+
full_class_name_association.send("#{user.role}_scope", user.id).map do |obj|
|
9
9
|
decorator_class(full_class_name_association).decorate obj
|
10
10
|
end.sort_by(&:name)
|
11
11
|
end
|
@@ -4,7 +4,7 @@ module Tramway::Core::Inputs::PolymorphicAssociationsHelper
|
|
4
4
|
def build_collection_for_polymorphic_association(form_object, property)
|
5
5
|
user = defined?(current_user) ? current_user : current_admin
|
6
6
|
object_names = full_class_names(form_object, property).map do |class_name|
|
7
|
-
class_name.
|
7
|
+
class_name.send("#{user.role}_scope", user.id).map do |obj|
|
8
8
|
decorator_class(class_name).decorate obj
|
9
9
|
end
|
10
10
|
end.flatten
|
@@ -5,6 +5,13 @@ module Tramway::Core::InputsHelper
|
|
5
5
|
include Tramway::Core::Inputs::PolymorphicAssociationsHelper
|
6
6
|
|
7
7
|
def association_params(form_object:, property:, value:, object:, options: {})
|
8
|
+
full_class_name_association = form_object.class.full_class_name_association(property)
|
9
|
+
|
10
|
+
if full_class_name_association.to_s == 'Tramway::User::User'
|
11
|
+
user = defined?(current_user) ? current_user : current_admin
|
12
|
+
value = user.id
|
13
|
+
end
|
14
|
+
|
8
15
|
build_input_attributes(object: object, property: property, options: options,
|
9
16
|
value: build_value_for_association(form_object, property, value),
|
10
17
|
collection: build_collection_for_association(form_object, property),
|
@@ -8,6 +8,12 @@ class Tramway::Core::ApplicationRecord < ActiveRecord::Base
|
|
8
8
|
extend ::Enumerize
|
9
9
|
include ::AASM
|
10
10
|
|
11
|
+
scope :created_by_user, lambda { |user_id|
|
12
|
+
joins(:audits).where('audits.action = \'create\' AND audits.user_id = ?', user_id)
|
13
|
+
}
|
14
|
+
scope :admin_scope, -> (_arg) { all }
|
15
|
+
|
16
|
+
# FIXME remove this after testing soft-deletion
|
11
17
|
aasm column: :state do
|
12
18
|
state :active, initial: true
|
13
19
|
state :removed
|
@@ -17,11 +23,6 @@ class Tramway::Core::ApplicationRecord < ActiveRecord::Base
|
|
17
23
|
end
|
18
24
|
end
|
19
25
|
|
20
|
-
scope :active, -> { where state: :active }
|
21
|
-
scope :created_by_user, lambda { |user_id|
|
22
|
-
joins(:audits).where('audits.action = \'create\' AND audits.user_id = ?', user_id)
|
23
|
-
}
|
24
|
-
scope :admin_scope, -> (_arg) { all }
|
25
26
|
|
26
27
|
include ::PgSearch::Model
|
27
28
|
|
@@ -33,7 +34,7 @@ class Tramway::Core::ApplicationRecord < ActiveRecord::Base
|
|
33
34
|
# FIXME: detect inhertited locales
|
34
35
|
class << self
|
35
36
|
def human_attribute_name(attribute_name, *_args)
|
36
|
-
excepted_attributes = %w[created_at updated_at
|
37
|
+
excepted_attributes = %w[created_at updated_at]
|
37
38
|
if attribute_name.to_s.in? excepted_attributes
|
38
39
|
I18n.t "activerecord.attributes.tramway/core/application_record.#{attribute_name}"
|
39
40
|
else
|
@@ -63,9 +64,4 @@ class Tramway::Core::ApplicationRecord < ActiveRecord::Base
|
|
63
64
|
AASM::StateMachineStore.fetch(self).machine_names
|
64
65
|
end
|
65
66
|
end
|
66
|
-
|
67
|
-
# FIXME: detect inhertited locales
|
68
|
-
def human_state_name
|
69
|
-
I18n.t "activerecord.state_machines.tramway/core/application_record.state.states.#{state}"
|
70
|
-
end
|
71
67
|
end
|
data/lib/tramway/core/version.rb
CHANGED
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:
|
4
|
+
version: 3.0.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:
|
12
|
+
date: 2022-01-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: audited
|
@@ -161,22 +161,22 @@ dependencies:
|
|
161
161
|
name: mini_magick
|
162
162
|
requirement: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- - "~>"
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: '4.8'
|
167
164
|
- - ">="
|
168
165
|
- !ruby/object:Gem::Version
|
169
166
|
version: 4.8.0
|
167
|
+
- - "~>"
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '4.8'
|
170
170
|
type: :runtime
|
171
171
|
prerelease: false
|
172
172
|
version_requirements: !ruby/object:Gem::Requirement
|
173
173
|
requirements:
|
174
|
-
- - "~>"
|
175
|
-
- !ruby/object:Gem::Version
|
176
|
-
version: '4.8'
|
177
174
|
- - ">="
|
178
175
|
- !ruby/object:Gem::Version
|
179
176
|
version: 4.8.0
|
177
|
+
- - "~>"
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '4.8'
|
180
180
|
- !ruby/object:Gem::Dependency
|
181
181
|
name: pg_search
|
182
182
|
requirement: !ruby/object:Gem::Requirement
|
@@ -412,7 +412,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
412
412
|
- !ruby/object:Gem::Version
|
413
413
|
version: '0'
|
414
414
|
requirements: []
|
415
|
-
rubygems_version: 3.1
|
415
|
+
rubygems_version: 3.0.3.1
|
416
416
|
signing_key:
|
417
417
|
specification_version: 4
|
418
418
|
summary: Core for all Tramway Rails Engines
|