anchor_view_components 0.11.4 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8f0780ee72bc13ea791c529b15bbb6b4ec3318abc7054c9bea275d9e7818682
|
4
|
+
data.tar.gz: 505d4f6138f09dee2ceffdda7d68626ab85726bff41346e24e6c14597eb8198c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a81c2270c9c76ded2106b6184bb84d6dccc786a0ce3b6ea8dd5530f62cb120fc7eef4a1b2b4fdd87c2e8ec0bbcd42fe2822429d66ef7ab15432de2300af35be
|
7
|
+
data.tar.gz: 3125a9b7090de76a6d7d8c97f0cba7507fbc00b796472f04db59f59fd65b74775cd9eef57f4717428c8f5e26cb29aee0f746a3bb8f7eae5c8a23af8084942500
|
data/CHANGELOG.md
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
"pl-8 py-3 pr-2 bg-[url('assets/icons/menu.svg')] bg-[length:16px_16px] bg-[8px_center] bg-no-repeat": sortable? && index.zero?,
|
34
34
|
"px-2 py-3": !sortable? || index.positive?,
|
35
35
|
),
|
36
|
-
data: { testid: "tr-#{model.id}-td-#{
|
36
|
+
data: { testid: "tr-#{model.id}-td-#{column.header.to_s.parameterize}" },
|
37
37
|
) %>
|
38
38
|
<% end
|
39
39
|
end
|
@@ -41,11 +41,11 @@
|
|
41
41
|
end %>
|
42
42
|
</table>
|
43
43
|
|
44
|
-
<% if show_total %>
|
44
|
+
<% if show_total && data.any? %>
|
45
45
|
<%= tag.div total, class: "mt-3 text-base font-semibold" %>
|
46
46
|
<% end %>
|
47
47
|
|
48
48
|
<% if data.empty? %>
|
49
|
-
<%= tag.p empty_message, class: "text-base text-center mt-6" %>
|
49
|
+
<%= tag.p empty_message, class: "text-base text-center mt-6", data: { testid: "empty-table-state" } %>
|
50
50
|
<% end %>
|
51
51
|
</div>
|
@@ -1,20 +1,21 @@
|
|
1
1
|
module Anchor
|
2
2
|
class TableComponent < Component
|
3
3
|
renders_many :columns, "ColumnComponent"
|
4
|
-
renders_one :link
|
5
4
|
|
6
|
-
attr_reader :data, :sortable, :caption, :show_total
|
5
|
+
attr_reader :data, :sortable, :caption, :rows_link_to, :show_total
|
7
6
|
|
8
7
|
def initialize(
|
9
8
|
data:,
|
10
9
|
caption: nil,
|
11
10
|
empty_message: nil,
|
11
|
+
rows_link_to: nil,
|
12
12
|
sort_url: nil,
|
13
13
|
sortable: false,
|
14
14
|
show_total: false
|
15
15
|
)
|
16
16
|
@data = data
|
17
17
|
@empty_message = empty_message
|
18
|
+
@rows_link_to = rows_link_to
|
18
19
|
@sortable = sortable
|
19
20
|
@sort_url = sort_url
|
20
21
|
@caption = caption
|
@@ -31,7 +32,7 @@ module Anchor
|
|
31
32
|
|
32
33
|
def row_classes
|
33
34
|
row_classes = %w(border-b focus-within:bg-grey-10)
|
34
|
-
if
|
35
|
+
if rows_link_to.present?
|
35
36
|
row_classes += %w(hover:bg-grey-10 hover:cursor-pointer)
|
36
37
|
end
|
37
38
|
if sortable?
|
@@ -42,8 +43,8 @@ module Anchor
|
|
42
43
|
|
43
44
|
def maybe_link(model, column, index, view_context)
|
44
45
|
value = value_for(model, column)
|
45
|
-
if
|
46
|
-
path =
|
46
|
+
if rows_link_to.present?
|
47
|
+
path = rows_link_to.call(model)
|
47
48
|
if index.zero?
|
48
49
|
text = view_context.link_to(value, path)
|
49
50
|
else
|
@@ -44,7 +44,7 @@ module Anchor
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def empty
|
47
|
-
render Anchor::TableComponent.new(data: []) do |table|
|
47
|
+
render Anchor::TableComponent.new(data: [], show_total: true) do |table|
|
48
48
|
table.with_column(header: "Id", value: :id)
|
49
49
|
table.with_column(header: "Name", value: -> { _1.name.capitalize })
|
50
50
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: anchor_view_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Buoy Software
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -162,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
162
|
- !ruby/object:Gem::Version
|
163
163
|
version: '0'
|
164
164
|
requirements: []
|
165
|
-
rubygems_version: 3.4.
|
165
|
+
rubygems_version: 3.4.10
|
166
166
|
signing_key:
|
167
167
|
specification_version: 4
|
168
168
|
summary: ViewComponents for Buoy’s design system, Anchor
|