tramway 1.0.1.2 → 1.0.2
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 +11 -0
- data/app/views/tramway/entities/show.html.haml +14 -3
- data/config/routes.rb +9 -4
- data/lib/tramway/base_decorator.rb +4 -0
- data/lib/tramway/configs/entity.rb +4 -3
- data/lib/tramway/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f347c8016c4bf4a0098ad6075235e573194ad4a1f06c99646d82686187d47524
|
|
4
|
+
data.tar.gz: 9cde483c80bdba5a855780d93c169b9b6c9b74739b029f476a0356243e1396fd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2acee51cfa114f2324809a506d276d482e166e520d40a68d7ca3f5b49cad17a6441f04e097ab20ead0bf1c4e42c2e042cf335aa6fc3889c8f265fe52e11c7ea8
|
|
7
|
+
data.tar.gz: 443e3cc99f4e3777f9090e6c23a4b575086d58237a948e7d2b19e6cfff602941c0c9f1fa0907ceb33251d7732c8050450ff2cb1f016e42534ccffae3379eff41
|
data/README.md
CHANGED
|
@@ -299,6 +299,13 @@ end
|
|
|
299
299
|
With this configuration in place, the index page will render the `Create`
|
|
300
300
|
button component above the table of projects.
|
|
301
301
|
|
|
302
|
+
#### Add header content to show pages
|
|
303
|
+
|
|
304
|
+
To inject custom content above a record's details, define an
|
|
305
|
+
object-level `show_header_content` method on its decorator. The method
|
|
306
|
+
can return any rendered content and has full access to the decorated
|
|
307
|
+
object's helpers and attributes.
|
|
308
|
+
|
|
302
309
|
#### Decorate a single object
|
|
303
310
|
|
|
304
311
|
You can use the same method to decorate a single object either
|
|
@@ -567,6 +574,10 @@ Read [behave_as_ar](https://github.com/Purple-Magic/tramway#behave_as_ar) sectio
|
|
|
567
574
|
|
|
568
575
|
### Tramway Navbar
|
|
569
576
|
|
|
577
|
+
#### Running tramway_navbar without arguments
|
|
578
|
+
|
|
579
|
+
When you call `tramway_navbar` without passing any arguments, it renders a navbar that lists buttons linking to all entities configured with a page index in `config/initializers/tramway.rb`.
|
|
580
|
+
|
|
570
581
|
Tramway provides DSL for rendering Tailwind Navgiation bar.
|
|
571
582
|
|
|
572
583
|
```ruby
|
|
@@ -1,12 +1,23 @@
|
|
|
1
|
+
- @show_header_content = @entity.show_header_content
|
|
2
|
+
|
|
1
3
|
= tramway_container do
|
|
2
|
-
|
|
3
|
-
|
|
4
|
+
|
|
5
|
+
.flex.justify-between.items-center
|
|
6
|
+
%h1.text-4xl.font-bold.mb-4
|
|
7
|
+
= @entity.title
|
|
8
|
+
|
|
9
|
+
.flex.justify-end.mt-2
|
|
10
|
+
- if @show_header_content.present?
|
|
11
|
+
- if @show_header_content.respond_to?(:call)
|
|
12
|
+
= @show_header_content.call(@entity)
|
|
13
|
+
- else
|
|
14
|
+
= @show_header_content
|
|
4
15
|
|
|
5
16
|
- if @entity.show_attributes.empty?
|
|
6
17
|
%p.text-center.mt-10
|
|
7
18
|
You should fill object-level method `show_attributes` inside your
|
|
8
19
|
= @entity.class.name
|
|
9
|
-
= tramway_table do
|
|
20
|
+
= tramway_table class: 'mt-4' do
|
|
10
21
|
- @entity.show_attributes.each do |attribute|
|
|
11
22
|
= tramway_row do
|
|
12
23
|
= tramway_cell do
|
data/config/routes.rb
CHANGED
|
@@ -12,10 +12,15 @@ Tramway::Engine.routes.draw do
|
|
|
12
12
|
resource_name = segments.pop
|
|
13
13
|
|
|
14
14
|
define_resource = proc do
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
entity.pages.each do |page|
|
|
16
|
+
case page.action
|
|
17
|
+
when 'index'
|
|
18
|
+
get resource_name.pluralize, to: '/tramway/entities#index', defaults: { entity: }, as: resource_name.pluralize
|
|
19
|
+
when 'show'
|
|
20
|
+
get "#{resource_name.pluralize}/:id", to: '/tramway/entities#show', defaults: { entity: },
|
|
21
|
+
as: resource_name.singularize
|
|
22
|
+
end
|
|
23
|
+
end
|
|
19
24
|
end
|
|
20
25
|
|
|
21
26
|
if segments.empty?
|
|
@@ -71,6 +71,10 @@ module Tramway
|
|
|
71
71
|
[]
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
+
def show_header_content
|
|
75
|
+
nil
|
|
76
|
+
end
|
|
77
|
+
|
|
74
78
|
# :reek:ManualDispatch { enabled: false } because there is the idea to manual dispatch
|
|
75
79
|
def method_missing(method_name, *, &)
|
|
76
80
|
url_helpers = Rails.application.routes.url_helpers
|
|
@@ -13,7 +13,8 @@ module Tramway
|
|
|
13
13
|
attribute? :namespace, Types::Coercible::String
|
|
14
14
|
|
|
15
15
|
# Route Struct contains implemented in Tramway CRUD and helpful routes for the entity
|
|
16
|
-
|
|
16
|
+
ACTIONS = %i[index show].freeze
|
|
17
|
+
RouteStruct = Struct.new(*ACTIONS)
|
|
17
18
|
|
|
18
19
|
# HumanName Struct contains human names forms for the entity
|
|
19
20
|
HumanNameStruct = Struct.new(:single, :plural)
|
|
@@ -53,9 +54,9 @@ module Tramway
|
|
|
53
54
|
end
|
|
54
55
|
|
|
55
56
|
def route_helper_methods
|
|
56
|
-
|
|
57
|
+
ACTIONS.map do |action|
|
|
57
58
|
page(action).present? ? send("#{action}_helper_method") : nil
|
|
58
|
-
end
|
|
59
|
+
end
|
|
59
60
|
end
|
|
60
61
|
|
|
61
62
|
def build_helper_method(base_name, route: nil, namespace: nil, plural: false)
|
data/lib/tramway/version.rb
CHANGED