tramway 1.0.2.1 → 1.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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b58435369bf6245e19fb273f9a7c425ed9306a2f654abba5fe092386e42e91aa
|
|
4
|
+
data.tar.gz: 1ce3dbebd406f6d1f825036540cd787957479d2f5dee1c73fdd457da7a653a12
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 60f84e3914bf8525cd49b78ae85a7a44d037efc69a8de3c16dcfcf8df910885263d109c0e0be6f2504734544540b2330a96dd36b3b749ea4e36277d3c195e340
|
|
7
|
+
data.tar.gz: c34b25d0cec71c3256f3f3d0a3b2449263e14186b6f854729938e40c4636c07307c40c66d29300dda31b8534b1c21efd2a7e525c30595812f13101bc4a7f1c5f
|
|
@@ -23,10 +23,12 @@ module Tramway
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def show
|
|
26
|
-
@
|
|
26
|
+
@record = tramway_decorate(
|
|
27
27
|
model_class.find(params[:id]),
|
|
28
28
|
namespace: entity.namespace
|
|
29
29
|
).with(view_context:)
|
|
30
|
+
|
|
31
|
+
set_associations
|
|
30
32
|
end
|
|
31
33
|
|
|
32
34
|
private
|
|
@@ -42,5 +44,19 @@ module Tramway
|
|
|
42
44
|
def index_scope
|
|
43
45
|
entity.page(:index).scope
|
|
44
46
|
end
|
|
47
|
+
|
|
48
|
+
def set_associations
|
|
49
|
+
@associations = @record.show_associations.map do |association|
|
|
50
|
+
next unless @record.public_send(association).any?
|
|
51
|
+
|
|
52
|
+
records = Kaminari.paginate_array(@record.public_send(association.name)).page(params[:page])
|
|
53
|
+
|
|
54
|
+
{
|
|
55
|
+
name: association,
|
|
56
|
+
decorator: records.first.class,
|
|
57
|
+
records:
|
|
58
|
+
}
|
|
59
|
+
end.compact
|
|
60
|
+
end
|
|
45
61
|
end
|
|
46
62
|
end
|
|
@@ -1,21 +1,46 @@
|
|
|
1
1
|
= tramway_container do
|
|
2
2
|
.flex.justify-between.items-center
|
|
3
3
|
%h1.text-4xl.font-bold.mb-4
|
|
4
|
-
= @
|
|
4
|
+
= @record.title
|
|
5
5
|
|
|
6
6
|
.flex.justify-end.mt-2
|
|
7
|
-
- if @
|
|
8
|
-
= @
|
|
7
|
+
- if @record.show_header_content.present?
|
|
8
|
+
= @record.show_header_content
|
|
9
9
|
|
|
10
|
-
- if @
|
|
10
|
+
- if @record.show_attributes.empty?
|
|
11
11
|
%p.text-center.mt-10
|
|
12
12
|
You should fill object-level method `show_attributes` inside your
|
|
13
|
-
= @
|
|
13
|
+
= @record.class.name
|
|
14
14
|
|
|
15
15
|
= tramway_table class: 'mt-4' do
|
|
16
|
-
- @
|
|
16
|
+
- @record.show_attributes.each do |attribute|
|
|
17
17
|
= tramway_row do
|
|
18
18
|
= tramway_cell do
|
|
19
19
|
= @model_class.human_attribute_name(attribute)
|
|
20
20
|
= tramway_cell do
|
|
21
|
-
= @
|
|
21
|
+
= @record.public_send(attribute)
|
|
22
|
+
|
|
23
|
+
- @associations.each do |association|
|
|
24
|
+
.flex.flex-row.justify-between.mt-8
|
|
25
|
+
%h3.text-2xl.font-bold
|
|
26
|
+
= @model_class.human_attribute_name(association[:name])
|
|
27
|
+
|
|
28
|
+
%div
|
|
29
|
+
= paginate association[:records],
|
|
30
|
+
custom_path_method: "#{@model_class.model_name.to_s.underscore}_path",
|
|
31
|
+
custom_path_arguments: [@record.id]
|
|
32
|
+
|
|
33
|
+
= tramway_table class: 'mt-4' do
|
|
34
|
+
-# FIXME: don't use first object for getting association decorator
|
|
35
|
+
= tramway_header headers: association[:records].first.table_headers
|
|
36
|
+
|
|
37
|
+
- association[:records].each do |record|
|
|
38
|
+
= tramway_row do
|
|
39
|
+
- association[:decorator].index_attributes.each do |column|
|
|
40
|
+
= tramway_cell do
|
|
41
|
+
= record.public_send(column)
|
|
42
|
+
|
|
43
|
+
.mt-4
|
|
44
|
+
= paginate association[:records],
|
|
45
|
+
custom_path_method: "#{@model_class.model_name.to_s.underscore}_path",
|
|
46
|
+
custom_path_arguments: [@record.id]
|
data/lib/kaminari/helpers/tag.rb
CHANGED
|
@@ -6,12 +6,11 @@ module Kaminari
|
|
|
6
6
|
# :reek:InstanceVariableAssumption { enabled: false }
|
|
7
7
|
class Tag
|
|
8
8
|
def page_url_for(page)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if custom_path_method.present?
|
|
9
|
+
if @options[:custom_path_method].present?
|
|
12
10
|
Tramway::Engine.routes.url_helpers.public_send(
|
|
13
|
-
custom_path_method,
|
|
14
|
-
|
|
11
|
+
@options[:custom_path_method],
|
|
12
|
+
*@options[:custom_path_arguments],
|
|
13
|
+
@params.except(:controller, :action).merge(page:)
|
|
15
14
|
)
|
|
16
15
|
else
|
|
17
16
|
params = params_for(page)
|
|
@@ -34,7 +34,6 @@ module Tramway
|
|
|
34
34
|
include Tramway::Helpers::ComponentHelper
|
|
35
35
|
include Tramway::Utils::Render
|
|
36
36
|
|
|
37
|
-
# :reek:NilCheck { enabled: false } because checking for nil is not a type-checking issue but business logic
|
|
38
37
|
def decorate(object_or_array)
|
|
39
38
|
return if object_or_array.nil?
|
|
40
39
|
|
|
@@ -77,11 +76,14 @@ module Tramway
|
|
|
77
76
|
[]
|
|
78
77
|
end
|
|
79
78
|
|
|
79
|
+
def show_associations
|
|
80
|
+
[]
|
|
81
|
+
end
|
|
82
|
+
|
|
80
83
|
def show_header_content
|
|
81
84
|
nil
|
|
82
85
|
end
|
|
83
86
|
|
|
84
|
-
# :reek:ManualDispatch { enabled: false } because there is the idea to manual dispatch
|
|
85
87
|
def method_missing(method_name, *, &)
|
|
86
88
|
url_helpers = Rails.application.routes.url_helpers
|
|
87
89
|
|
|
@@ -95,9 +97,14 @@ module Tramway
|
|
|
95
97
|
super
|
|
96
98
|
end
|
|
97
99
|
|
|
98
|
-
# :reek:BooleanParameter { enabled: false } because it's a part of the duck-typing
|
|
99
100
|
def respond_to_missing?(method_name, include_private = false)
|
|
100
101
|
method_name.to_s.end_with?('_path', '_url') || super
|
|
101
102
|
end
|
|
103
|
+
|
|
104
|
+
def table_headers
|
|
105
|
+
self.class.index_attributes.map do |attribute|
|
|
106
|
+
object.class.human_attribute_name(attribute)
|
|
107
|
+
end
|
|
108
|
+
end
|
|
102
109
|
end
|
|
103
110
|
end
|
data/lib/tramway/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tramway
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: '1.1'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- kalashnikovisme
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2025-11-
|
|
12
|
+
date: 2025-11-24 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: anyway_config
|