katalyst-koi 4.5.9 → 4.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/builds/koi/admin.css +26 -30
- data/app/assets/builds/koi/admin.css.map +1 -1
- data/app/assets/stylesheets/koi/components/_pagy.scss +18 -30
- data/app/components/koi/navigation/editor/errors_component.rb +0 -1
- data/app/components/koi/tables/cells/attachment_component.rb +60 -0
- data/app/components/koi/tables/cells/link_component.rb +43 -0
- data/app/components/koi/tables/table_component.rb +54 -5
- data/app/controllers/admin/admin_users_controller.rb +1 -5
- data/app/controllers/admin/url_rewrites_controller.rb +1 -5
- data/app/controllers/concerns/koi/controller/is_admin_controller.rb +1 -0
- data/app/helpers/koi/index_actions_helper.rb +1 -1
- data/app/views/admin/admin_users/index.html.erb +6 -1
- data/app/views/admin/credentials/_credentials.html.erb +3 -3
- data/app/views/admin/sessions/new.html.erb +1 -0
- data/app/views/admin/url_rewrites/index.html.erb +7 -1
- data/app/views/layouts/koi/application.html.erb +3 -0
- data/config/locales/pagy.en.yml +6 -0
- data/lib/generators/koi/admin_controller/templates/controller.rb.tt +1 -5
- data/lib/generators/koi/admin_views/admin_views_generator.rb +1 -1
- data/lib/generators/koi/admin_views/templates/index.html.erb.tt +16 -1
- metadata +23 -18
- data/app/components/koi/index_table_component.rb +0 -26
- data/app/components/koi/ordinal_table_component.rb +0 -27
- data/app/components/koi/tables/body.rb +0 -228
- data/app/components/koi/tables/body_cell_component.rb +0 -21
- data/app/components/koi/tables/body_row_component.rb +0 -142
- data/app/components/koi/tables/header.rb +0 -63
- data/app/components/koi/tables/header_cell_component.rb +0 -38
- data/app/components/koi/tables/header_row_component.rb +0 -213
- data/app/views/admin/admin_users/_admin.html+row.erb +0 -2
- data/app/views/admin/url_rewrites/_url_rewrite.html+row.erb +0 -3
- data/lib/generators/koi/admin_views/templates/_record.html+row.erb.tt +0 -7
@@ -1,142 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Koi
|
4
|
-
module Tables
|
5
|
-
# Custom body row component, in order to override the default body cell component
|
6
|
-
class BodyRowComponent < Katalyst::Tables::BodyRowComponent
|
7
|
-
# Generates a column from boolean values rendered as "Yes" or "No".
|
8
|
-
#
|
9
|
-
# @param method [Symbol] the method to call on the record
|
10
|
-
# @param attributes [Hash] HTML attributes to be added to the cell
|
11
|
-
# @param block [Proc] optional block to alter the cell content
|
12
|
-
# @return [void]
|
13
|
-
#
|
14
|
-
# @example Render a boolean column indicating whether the record is active
|
15
|
-
# <% row.boolean :active %> # => <td>Yes</td>
|
16
|
-
def boolean(method, **attributes, &block)
|
17
|
-
with_column(Body::BooleanComponent.new(@table, @record, method, **attributes), &block)
|
18
|
-
end
|
19
|
-
|
20
|
-
# Generates a column from date values rendered using I18n.l.
|
21
|
-
# The default format is :admin, but it can be overridden.
|
22
|
-
#
|
23
|
-
# @param method [Symbol] the method to call on the record
|
24
|
-
# @param format [Symbol] the I18n date format to use when rendering
|
25
|
-
# @param attributes [Hash] HTML attributes to be added to the cell tag
|
26
|
-
# @param block [Proc] optional block to alter the cell content
|
27
|
-
# @return [void]
|
28
|
-
#
|
29
|
-
# @example Render a date column describing when the record was created
|
30
|
-
# <% row.date :created_at %> # => <td>29 Feb 2024</td>
|
31
|
-
def date(method, format: :admin, **attributes, &block)
|
32
|
-
with_column(Body::DateComponent.new(@table, @record, method, format:, **attributes), &block)
|
33
|
-
end
|
34
|
-
|
35
|
-
# Generates a column from datetime values rendered using I18n.l.
|
36
|
-
# The default format is :admin, but it can be overridden.
|
37
|
-
#
|
38
|
-
# @param method [Symbol] the method to call on the record
|
39
|
-
# @param format [Symbol] the I18n datetime format to use when rendering
|
40
|
-
# @param attributes [Hash] HTML attributes to be added to the cell tag
|
41
|
-
# @param block [Proc] optional block to alter the cell content
|
42
|
-
# @return [void]
|
43
|
-
#
|
44
|
-
# @example Render a datetime column describing when the record was created
|
45
|
-
# <% row.datetime :created_at %> # => <td>29 Feb 2024, 5:00pm</td>
|
46
|
-
def datetime(method, format: :admin, **attributes, &block)
|
47
|
-
with_column(Body::DatetimeComponent.new(@table, @record, method, format:, **attributes), &block)
|
48
|
-
end
|
49
|
-
|
50
|
-
# Generates a column from numeric values formatted appropriately.
|
51
|
-
#
|
52
|
-
# @param method [Symbol] the method to call on the record
|
53
|
-
# @param attributes [Hash] HTML attributes to be added to the cell tag
|
54
|
-
# @param block [Proc] optional block to alter the cell content
|
55
|
-
# @return [void]
|
56
|
-
#
|
57
|
-
# @example Render the number of comments on a post
|
58
|
-
# <% row.number :comment_count %> # => <td>0</td>
|
59
|
-
def number(method, **attributes, &block)
|
60
|
-
with_column(Body::NumberComponent.new(@table, @record, method, **attributes), &block)
|
61
|
-
end
|
62
|
-
|
63
|
-
# Generates a column from numeric values rendered using `number_to_currency`.
|
64
|
-
#
|
65
|
-
# @param method [Symbol] the method to call on the record
|
66
|
-
# @param options [Hash] options to be passed to `number_to_currency`
|
67
|
-
# @param attributes [Hash] HTML attributes to be added to the cell tag
|
68
|
-
# @param block [Proc] optional block to alter the cell content
|
69
|
-
# @return [void]
|
70
|
-
#
|
71
|
-
# @example Render a currency column for the price of a product
|
72
|
-
# <% row.currency :price %> # => <td>$3.50</td>
|
73
|
-
def currency(method, options: {}, **attributes, &block)
|
74
|
-
with_column(Body::CurrencyComponent.new(@table, @record, method, options:, **attributes), &block)
|
75
|
-
end
|
76
|
-
|
77
|
-
# Generates a column containing HTML markup.
|
78
|
-
#
|
79
|
-
# @param method [Symbol] the method to call on the record
|
80
|
-
# @param attributes [Hash] HTML attributes to be added to the cell tag
|
81
|
-
# @param block [Proc] optional block to alter the cell content
|
82
|
-
# @return [void]
|
83
|
-
#
|
84
|
-
# @note This method assumes that the method returns HTML-safe content.
|
85
|
-
# If the content is not HTML-safe, it will be escaped.
|
86
|
-
#
|
87
|
-
# @example Render a description column containing HTML markup
|
88
|
-
# <% row.rich_text :description %> # => <td><em>Emphasis</em></td>
|
89
|
-
def rich_text(method, **attributes, &block)
|
90
|
-
with_column(Body::RichTextComponent.new(@table, @record, method, **attributes), &block)
|
91
|
-
end
|
92
|
-
|
93
|
-
# Generates a column that links to the record's show page (by default).
|
94
|
-
#
|
95
|
-
# @param method [Symbol] the method to call on the record
|
96
|
-
# @param link [Hash] options to be passed to the link_to helper
|
97
|
-
# @option opts [Hash, Array, String, Symbol] :url ([:admin, object]) options for url_for,
|
98
|
-
# or a symbol to be passed to the route helper
|
99
|
-
# @param attributes [Hash] HTML attributes to be added to the cell tag
|
100
|
-
# @param block [Proc] optional block to alter the cell content
|
101
|
-
# @return [void]
|
102
|
-
#
|
103
|
-
# @example Render a column containing the record's title, linked to its show page
|
104
|
-
# <% row.link :title %> # => <td><a href="/admin/post/15">About us</a></td>
|
105
|
-
# @example Render a column containing the record's title, linked to its edit page
|
106
|
-
# <% row.link :title, url: :edit_admin_post_path do |cell| %>
|
107
|
-
# Edit <%= cell %>
|
108
|
-
# <% end %>
|
109
|
-
# # => <td><a href="/admin/post/15/edit">Edit About us</a></td>
|
110
|
-
def link(method, url: [:admin, @record], link: {}, **attributes, &block)
|
111
|
-
with_column(Body::LinkComponent.new(@table, @record, method, url:, link:, **attributes), &block)
|
112
|
-
end
|
113
|
-
|
114
|
-
# Generates a column that renders the contents as text.
|
115
|
-
#
|
116
|
-
# @param method [Symbol] the method to call on the record
|
117
|
-
# @param attributes [Hash] HTML attributes to be added to the cell tag
|
118
|
-
# @param block [Proc] optional block to alter the cell content
|
119
|
-
# @return [void]
|
120
|
-
#
|
121
|
-
# @example Render a column containing the record's title
|
122
|
-
# <% row.text :title %> # => <td>About us</td>
|
123
|
-
def text(method, **attributes, &block)
|
124
|
-
with_column(BodyCellComponent.new(@table, @record, method, **attributes), &block)
|
125
|
-
end
|
126
|
-
|
127
|
-
# Generates a column that renders an ActiveStorage attachment as a downloadable link.
|
128
|
-
#
|
129
|
-
# @param method [Symbol] the method to call on the record
|
130
|
-
# @param variant [Symbol] the variant to use when rendering the image (default :thumb)
|
131
|
-
# @param attributes [Hash] HTML attributes to be added to the cell tag
|
132
|
-
# @param block [Proc] optional block to alter the cell content
|
133
|
-
# @return [void]
|
134
|
-
#
|
135
|
-
# @example Render a column containing a download link to the record's background image
|
136
|
-
# <% row.attachment :background %> # => <td><a href="...">background.png</a></td>
|
137
|
-
def attachment(method, variant: :thumb, **attributes, &block)
|
138
|
-
with_column(Body::AttachmentComponent.new(@table, @record, method, variant:, **attributes), &block)
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
using Katalyst::HtmlAttributes::HasHtmlAttributes
|
4
|
-
|
5
|
-
module Koi
|
6
|
-
module Tables
|
7
|
-
module Header
|
8
|
-
class NumberComponent < HeaderCellComponent
|
9
|
-
def default_html_attributes
|
10
|
-
super.merge_html(class: "type-number")
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class CurrencyComponent < HeaderCellComponent
|
15
|
-
def default_html_attributes
|
16
|
-
super.merge_html(class: "type-currency")
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class BooleanComponent < HeaderCellComponent
|
21
|
-
def default_html_attributes
|
22
|
-
super.merge_html(class: "type-boolean")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
class DateComponent < HeaderCellComponent
|
27
|
-
def default_html_attributes
|
28
|
-
super.merge_html(class: "type-date")
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
class DateTimeComponent < HeaderCellComponent
|
33
|
-
def default_html_attributes
|
34
|
-
super.merge_html(class: "type-datetime")
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
class LinkComponent < HeaderCellComponent
|
39
|
-
def default_html_attributes
|
40
|
-
super.merge_html(class: "type-link")
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
class TextComponent < HeaderCellComponent
|
45
|
-
def default_html_attributes
|
46
|
-
super.merge_html(class: "type-text")
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
class ImageComponent < HeaderCellComponent
|
51
|
-
def default_html_attributes
|
52
|
-
super.merge_html(class: "type-image")
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
class AttachmentComponent < HeaderCellComponent
|
57
|
-
def default_html_attributes
|
58
|
-
super.merge_html(class: "type-attachment")
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
using Katalyst::HtmlAttributes::HasHtmlAttributes
|
4
|
-
|
5
|
-
module Koi
|
6
|
-
module Tables
|
7
|
-
class HeaderCellComponent < Katalyst::Tables::HeaderCellComponent
|
8
|
-
attr_reader :width
|
9
|
-
|
10
|
-
def initialize(table, attribute, label: nil, link: {}, width: nil, **html_attributes)
|
11
|
-
@width = width
|
12
|
-
|
13
|
-
super(table, attribute, label:, link:, **html_attributes)
|
14
|
-
end
|
15
|
-
|
16
|
-
def default_html_attributes
|
17
|
-
super.merge_html(class: width_class)
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def width_class
|
23
|
-
case width
|
24
|
-
when :xs
|
25
|
-
"width-xs"
|
26
|
-
when :s
|
27
|
-
"width-s"
|
28
|
-
when :m
|
29
|
-
"width-m"
|
30
|
-
when :l
|
31
|
-
"width-l"
|
32
|
-
else
|
33
|
-
""
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,213 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Koi
|
4
|
-
module Tables
|
5
|
-
# Custom header row component, in order to override the default header cell component
|
6
|
-
# for number columns, we add a class to the header cell to allow for custom styling
|
7
|
-
class HeaderRowComponent < Katalyst::Tables::HeaderRowComponent
|
8
|
-
# Renders a boolean column header
|
9
|
-
# @param method [Symbol] the method to call on the record to get the value
|
10
|
-
# @param attributes [Hash] additional arguments are applied as html attributes to the th element
|
11
|
-
# @option attributes [String] :label (nil) The label options to display in the header
|
12
|
-
# @option attributes [Hash] :link ({}) The link options for the sorting link
|
13
|
-
# @option attributes [String] :width (:xs) The width of the column, can be +:xs+, +:s+, +:m+, +:l+ or nil
|
14
|
-
#
|
15
|
-
# @example Render a boolean column header
|
16
|
-
# <% row.boolean :active %> # => <th>Active</th>
|
17
|
-
#
|
18
|
-
# @example Render a boolean column header with a custom label
|
19
|
-
# <% row.boolean :active, label: "Published" %> # => <th>Published</th>
|
20
|
-
#
|
21
|
-
# @example Render a boolean column header with medium width
|
22
|
-
# <% row.boolean :active, width: :m %>
|
23
|
-
# # => <th class="width-s">Active</th>
|
24
|
-
#
|
25
|
-
# @see Koi::Tables::BodyRowComponent#boolean
|
26
|
-
def boolean(method, **attributes, &block)
|
27
|
-
header_cell(method, component: Header::BooleanComponent, **attributes, &block)
|
28
|
-
end
|
29
|
-
|
30
|
-
# Renders a date column header
|
31
|
-
# @param method [Symbol] the method to call on the record to get the value
|
32
|
-
# @param attributes [Hash] additional arguments are applied as html attributes to the th element
|
33
|
-
# @option attributes [String] :label (nil) The label options to display in the header
|
34
|
-
# @option attributes [Hash] :link ({}) The link options for the sorting link
|
35
|
-
# @option attributes [String] :width (:s) The width of the column, can be +:xs+, +:s+, +:m+, +:l+ or nil
|
36
|
-
#
|
37
|
-
# @example Render a date column header
|
38
|
-
# <% row.date :published_on %> # => <th>Published on</th>
|
39
|
-
#
|
40
|
-
# @example Render a date column header with a custom label
|
41
|
-
# <% row.date :published_on, label: "Date" %> # => <th>Date</th>
|
42
|
-
#
|
43
|
-
# @example Render a date column header with small width
|
44
|
-
# <% row.date :published_on, width: :s %>
|
45
|
-
# # => <th class="width-s">Published on</th>
|
46
|
-
#
|
47
|
-
# @see Koi::Tables::BodyRowComponent#date
|
48
|
-
def date(method, **attributes, &block)
|
49
|
-
header_cell(method, component: Header::DateComponent, **attributes, &block)
|
50
|
-
end
|
51
|
-
|
52
|
-
# Renders a datetime column header
|
53
|
-
# @param method [Symbol] the method to call on the record to get the value
|
54
|
-
# @param attributes [Hash] additional arguments are applied as html attributes to the th element
|
55
|
-
# @option attributes [String] :label (nil) The label options to display in the header
|
56
|
-
# @option attributes [Hash] :link ({}) The link options for the sorting link
|
57
|
-
# @option attributes [String] :width (:m) The width of the column, can be +:xs+, +:s+, +:m+, +:l+ or nil
|
58
|
-
#
|
59
|
-
# @example Render a datetime column header
|
60
|
-
# <% row.datetime :created_at %> # => <th>Created at</th>
|
61
|
-
#
|
62
|
-
# @example Render a datetime column header with a custom label
|
63
|
-
# <% row.datetime :created_at, label: "Published at" %> # => <th>Published at</th>
|
64
|
-
#
|
65
|
-
# @example Render a datetime column header with small width
|
66
|
-
# <% row.datetime :created_at, width: :s %>
|
67
|
-
# # => <th class="width-s">Created at</th>
|
68
|
-
#
|
69
|
-
# @see Koi::Tables::BodyRowComponent#datetime
|
70
|
-
def datetime(method, **attributes, &block)
|
71
|
-
header_cell(method, component: Header::DateTimeComponent, **attributes, &block)
|
72
|
-
end
|
73
|
-
|
74
|
-
# Renders a number column header
|
75
|
-
# @param method [Symbol] the method to call on the record to get the value
|
76
|
-
# @param attributes [Hash] additional arguments are applied as html attributes to the th element
|
77
|
-
# @option attributes [String] :label (nil) The label options to display in the header
|
78
|
-
# @option attributes [Hash] :link ({}) The link options for the sorting link
|
79
|
-
# @option attributes [String] :width (:xs) The width of the column, can be +:xs+, +:s+, +:m+, +:l+ or nil
|
80
|
-
#
|
81
|
-
# @example Render a number column header
|
82
|
-
# <% row.number :comment_count %> # => <th>Comments</th>
|
83
|
-
#
|
84
|
-
# @example Render a number column header with a custom label
|
85
|
-
# <% row.number :comment_count, label: "Comments" %> # => <th>Comments</th>
|
86
|
-
#
|
87
|
-
# @example Render a number column header with medium width
|
88
|
-
# <% row.number :comment_count, width: :m %>
|
89
|
-
# # => <th class="width-m">Comment Count</th>
|
90
|
-
#
|
91
|
-
# @see Koi::Tables::BodyRowComponent#number
|
92
|
-
def number(method, **attributes, &block)
|
93
|
-
header_cell(method, component: Header::NumberComponent, **attributes, &block)
|
94
|
-
end
|
95
|
-
|
96
|
-
# Renders a currency column header
|
97
|
-
# @param method [Symbol] the method to call on the record to get the value
|
98
|
-
# @param attributes [Hash] additional arguments are applied as html attributes to the th element
|
99
|
-
# @option attributes [String] :label (nil) The label options to display in the header
|
100
|
-
# @option attributes [Hash] :link ({}) The link options for the sorting link
|
101
|
-
# @option attributes [String] :width (:s) The width of the column, can be +:xs+, +:s+, +:m+, +:l+ or nil
|
102
|
-
#
|
103
|
-
# @example Render a currency column header
|
104
|
-
# <% row.currency :price %> # => <th>Price</th>
|
105
|
-
#
|
106
|
-
# @example Render a currency column header with a custom label
|
107
|
-
# <% row.currency :price, label: "Amount($)" %> # => <th>Amount($)</th>
|
108
|
-
#
|
109
|
-
# @example Render a currency column header with medium width
|
110
|
-
# <% row.currency :price, width: :m %>
|
111
|
-
# # => <th class="width-m">Price</th>
|
112
|
-
#
|
113
|
-
# @see Koi::Tables::BodyRowComponent#currency
|
114
|
-
def currency(method, **attributes, &block)
|
115
|
-
header_cell(method, component: Header::CurrencyComponent, **attributes, &block)
|
116
|
-
end
|
117
|
-
|
118
|
-
# Renders a rich text column header
|
119
|
-
# @param method [Symbol] the method to call on the record to get the value
|
120
|
-
# @param attributes [Hash] additional arguments are applied as html attributes to the th element
|
121
|
-
# @option attributes [String] :label (nil) The label options to display in the header
|
122
|
-
# @option attributes [Hash] :link ({}) The link options for the sorting link
|
123
|
-
# @option attributes [String] :width (nil) The width of the column, can be +:xs+, +:s+, +:m+, +:l+ or nil
|
124
|
-
#
|
125
|
-
# @example Render a rich text column header
|
126
|
-
# <% row.rich_text :content %> # => <th>Content</th>
|
127
|
-
#
|
128
|
-
# @example Render a rich text column header with a custom label
|
129
|
-
# <% row.rich_text :content, label: "Post content" %> # => <th>Post content</th>
|
130
|
-
#
|
131
|
-
# @example Render a rich text column header with large width
|
132
|
-
# <% row.rich_text :content, width: :l %>
|
133
|
-
# # => <th class="width-l">Content</th>
|
134
|
-
#
|
135
|
-
# @see Koi::Tables::BodyRowComponent#rich_text
|
136
|
-
def rich_text(method, **attributes, &block)
|
137
|
-
header_cell(method, component: Header::TextComponent, **attributes, &block)
|
138
|
-
end
|
139
|
-
|
140
|
-
# Renders a link column header
|
141
|
-
# @param method [Symbol] the method to call on the record to get the value
|
142
|
-
# @param attributes [Hash] additional arguments are applied as html attributes to the th element
|
143
|
-
# @option attributes [String] :label (nil) The label options to display in the header
|
144
|
-
# @option attributes [Hash] :link ({}) The link options for the sorting link
|
145
|
-
# @option attributes [String] :width (nil) The width of the column, can be +:xs+, +:s+, +:m+, +:l+ or nil
|
146
|
-
#
|
147
|
-
# @example Render a link column header
|
148
|
-
# <% row.link :link %> # => <th>Link</th>
|
149
|
-
#
|
150
|
-
# @example Render a link column header with a custom label
|
151
|
-
# <% row.link :link, label: "Post" %> # => <th>Post</th>
|
152
|
-
#
|
153
|
-
# @example Render a link column header with small width
|
154
|
-
# <% row.link :content, width: :s %>
|
155
|
-
# # => <th class="width-s">Content</th>
|
156
|
-
#
|
157
|
-
# @see Koi::Tables::BodyRowComponent#link
|
158
|
-
def link(method, **attributes, &block)
|
159
|
-
header_cell(method, component: Header::LinkComponent, **attributes, &block)
|
160
|
-
end
|
161
|
-
|
162
|
-
# Renders a text column header
|
163
|
-
# @param method [Symbol] the method to call on the record to get the value
|
164
|
-
# @param attributes [Hash] additional arguments are applied as html attributes to the th element
|
165
|
-
# @option attributes [String] :label (nil) The label options to display in the header
|
166
|
-
# @option attributes [Hash] :link ({}) The link options for the sorting link
|
167
|
-
# @option attributes [String] :width (nil) The width of the column, can be +:xs+, +:s+, +:m+, +:l+ or nil
|
168
|
-
#
|
169
|
-
# @example Render a text column header
|
170
|
-
# <% row.text :content %> # => <th>Content</th>
|
171
|
-
#
|
172
|
-
# @example Render a text column header with a custom label
|
173
|
-
# <% row.text :content, label: "Description" %> # => <th>Description</th>
|
174
|
-
#
|
175
|
-
# @example Render a text column header with large width
|
176
|
-
# <% row.text :content, width: :l %>
|
177
|
-
# # => <th class="width-l">Content</th>
|
178
|
-
#
|
179
|
-
# @see Koi::Tables::BodyRowComponent#text
|
180
|
-
def text(method, **attributes, &block)
|
181
|
-
header_cell(method, component: Header::TextComponent, **attributes, &block)
|
182
|
-
end
|
183
|
-
|
184
|
-
# Renders a attachment column header
|
185
|
-
# @param method [Symbol] the method to call on the record to get the value
|
186
|
-
# @param attributes [Hash] additional arguments are applied as html attributes to the th element
|
187
|
-
# @option attributes [String] :label (nil) The label options to display in the header
|
188
|
-
# @option attributes [Hash] :link ({}) The link options for the sorting link
|
189
|
-
# @option attributes [String] :width (nil) The width of the column, can be +:xs+, +:s+, +:m+, +:l+ or nil
|
190
|
-
#
|
191
|
-
# @example Render a attachment column header
|
192
|
-
# <% row.attachment :attachment %> # => <th>Attachment</th>
|
193
|
-
#
|
194
|
-
# @example Render a attachment column header with a custom label
|
195
|
-
# <% row.attachment :attachment, label: "Document" %> # => <th>Document</th>
|
196
|
-
#
|
197
|
-
# @example Render a attachment column header with small width
|
198
|
-
# <% row.attachment :attachment, width: :s %>
|
199
|
-
# # => <th class="width-s">Attachment</th>
|
200
|
-
#
|
201
|
-
# @see Koi::Tables::BodyRowComponent#attachment
|
202
|
-
def attachment(method, **attributes, &block)
|
203
|
-
header_cell(method, component: Header::AttachmentComponent, **attributes, &block)
|
204
|
-
end
|
205
|
-
|
206
|
-
private
|
207
|
-
|
208
|
-
def header_cell(method, component: HeaderCellComponent, **attributes, &block)
|
209
|
-
with_column(component.new(@table, method, link: @link_attributes, **attributes), &block)
|
210
|
-
end
|
211
|
-
end
|
212
|
-
end
|
213
|
-
end
|