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: 54fe54f9b32e62f69edd813a0fa7c888da757f3fb35ea99c9ec7b2942c96b85e
4
- data.tar.gz: ca892dda3d5ea422838b0fa2af607ab4159b8e6ea522b61d4c8a3580b014c510
3
+ metadata.gz: e8f0780ee72bc13ea791c529b15bbb6b4ec3318abc7054c9bea275d9e7818682
4
+ data.tar.gz: 505d4f6138f09dee2ceffdda7d68626ab85726bff41346e24e6c14597eb8198c
5
5
  SHA512:
6
- metadata.gz: e11eb6d50799d5664f7b1a7262b06fa4d1cd0e3c8d4763ca5098ebd574887b631a8a1bf8c4e2cc037d79c57318d91b9d21aa651ea3cd7db13e167fe2ab4e9eb4
7
- data.tar.gz: 1db50607d4d1c83cc8d9884dfae24a4ac280904d56336cbff5263cc84def5ae49568509dcceb0e9c1450cb907fbcc2a6beb5c365a2453b3f657fa7942f9c152c
6
+ metadata.gz: 7a81c2270c9c76ded2106b6184bb84d6dccc786a0ce3b6ea8dd5530f62cb120fc7eef4a1b2b4fdd87c2e8ec0bbcd42fe2822429d66ef7ab15432de2300af35be
7
+ data.tar.gz: 3125a9b7090de76a6d7d8c97f0cba7507fbc00b796472f04db59f59fd65b74775cd9eef57f4717428c8f5e26cb29aee0f746a3bb8f7eae5c8a23af8084942500
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.12.0 - 2023-09-11
4
+
5
+ ### Changed
6
+ - Added a record argument to the TableComponent row link lambda
7
+
8
+
3
9
  ## 0.11.4 - 2023-09-07
4
10
 
5
11
  ### Added
@@ -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-#{index}" },
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 link?
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 link?
46
- path = "#{link}#{model.id}"
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
@@ -1,5 +1,5 @@
1
1
  module Anchor
2
2
  module ViewComponents
3
- VERSION = "0.11.4".freeze
3
+ VERSION = "0.12.0".freeze
4
4
  end
5
5
  end
@@ -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.11.4
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-07 00:00:00.000000000 Z
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.19
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