lato 0.1.27 → 0.1.28

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: d39edbfb4463841b8aae209b67bde25c3c7a49dd98020185c9ac2e75b2571bc6
4
- data.tar.gz: 594d67d40286bfe453c05b2625f891fa3f8fff78ad44f26b6520a89ad9f1d7b4
3
+ metadata.gz: 5bcb5a6f47f56626a7fd68c8ab3872971d88291b568c8ede302e2307648babd3
4
+ data.tar.gz: d250a7b34e0dcee6cadbd41a4f93b2fccaaa6f78dd0b56b4f96d2a5cd5b3c097
5
5
  SHA512:
6
- metadata.gz: 0cdeaedaf49f9e0efb6d53035fbbdcb4eeed8d0256e34ce54fc36073478f92592dd486e63144b8a4dab534f74953124e53698b01af2a1df93fd35ccfa206e1ce
7
- data.tar.gz: 61e8ed6e0ec07edac2b9b8f115bb579dab182fff4c32ddacb48c24f0bbae78056f4d32fbc997c547850e301755e60688438e029226b05c4fcfd2436858e55527
6
+ metadata.gz: 61591a5033d2c16ca7bfbda32416d41060156298a4f2272daa210bf1203be2ccf4ec16e4f59034e05196a9f23dfc1621fa0b3e15db82421a930386c29b144d12
7
+ data.tar.gz: 73f3a4fdf44043aca72b8276c53a9d73d6285b59a49db1308d2c10e358f715d2c58b77f6c755763124b49072b5c11861f7d1b03f4dc0cbc1511fad4fd51a6d9a
@@ -50,7 +50,8 @@ module Lato
50
50
  columns = options[:columns] || @_lato_index[key][:columns] || collection.column_names || []
51
51
  sortable_columns = @_lato_index[key][:sortable_columns] || []
52
52
  searchable_columns = @_lato_index[key][:searchable_columns] || []
53
- model_name_underscore = options[:model_name] || collection.model.name.underscore.gsub('/', '_')
53
+ model_name = options[:model_name] || collection.model.name
54
+ model_name_underscore = options[:model_name] || model_name.underscore.gsub('/', '_')
54
55
 
55
56
  render(
56
57
  'lato/components/index',
@@ -59,11 +60,20 @@ module Lato
59
60
  columns: columns,
60
61
  sortable_columns: sortable_columns,
61
62
  searchable_columns: searchable_columns,
63
+ model_name: model_name,
62
64
  model_name_underscore: model_name_underscore,
63
65
  custom_actions: options[:custom_actions] || {}
64
66
  )
65
67
  end
66
68
 
69
+ def lato_index_dynamic_label(params = {})
70
+ 'Please override the method lato_index_dynamic_label in your application_helper.rb'
71
+ end
72
+
73
+ def lato_index_dynamic_value(params = {})
74
+ 'Please override the method lato_index_dynamic_value in your application_helper.rb'
75
+ end
76
+
67
77
  # Operation
68
78
  ##
69
79
 
@@ -1,3 +1,9 @@
1
+ <%
2
+
3
+ collection_test_istance = collection.model.new
4
+
5
+ %>
6
+
1
7
  <%= turbo_frame_tag "lato_index_#{key}_#{model_name_underscore}", class: 'lato-index' do %>
2
8
 
3
9
  <%= form_tag request.path, method: :get, data: { turbo_frame: '_self' } do %>
@@ -38,10 +44,19 @@
38
44
  <tbody>
39
45
  <% columns.each do |column| %>
40
46
  <tr>
41
- <th><%= collection.model.human_attribute_name column %></th>
47
+ <th><%= collection_test_istance.respond_to?(column) ? collection.model.human_attribute_name(column) : lato_index_dynamic_label({
48
+ key: key,
49
+ model_name: model_name,
50
+ column: column
51
+ }) %></th>
42
52
  <td class="lato-index-col-<%= column %>">
43
53
  <% viewer_function_name = "#{model_name_underscore}_#{column}" %>
44
- <%= respond_to?(viewer_function_name) ? send(viewer_function_name, member) : member.send(column) %>
54
+ <%= respond_to?(viewer_function_name) ? send(viewer_function_name, member) : (collection_test_istance.respond_to?(column) ? member.send(column) : lato_index_dynamic_value({
55
+ key: key,
56
+ model_name: model_name,
57
+ column: column,
58
+ member: member
59
+ })) %>
45
60
  </td>
46
61
  </tr>
47
62
  <% end %>
@@ -67,7 +82,11 @@
67
82
  <% columns.each do |column| %>
68
83
  <th scope="col" class="lato-index-col-<%= column %>">
69
84
  <div class="d-flex align-items-center">
70
- <span><%= collection.model.human_attribute_name column %></span>
85
+ <span><%= collection_test_istance.respond_to?(column) ? collection.model.human_attribute_name(column) : lato_index_dynamic_label({
86
+ key: key,
87
+ model_name: model_name,
88
+ column: column
89
+ }) %></span>
71
90
  <% if sortable_columns.include?(column) %>
72
91
  <div class="btn-group ms-3">
73
92
  <div class="position-relative btn btn-sm <%= params[:sort_by] == "#{column}|ASC" ? 'btn-primary' : 'btn-outline-primary' %>">
@@ -92,7 +111,12 @@
92
111
  <% columns.each do |column| %>
93
112
  <td class="lato-index-col-<%= column %>">
94
113
  <% viewer_function_name = "#{model_name_underscore}_#{column}" %>
95
- <%= respond_to?(viewer_function_name) ? send(viewer_function_name, member) : member.send(column) %>
114
+ <%= respond_to?(viewer_function_name) ? send(viewer_function_name, member) : (collection_test_istance.respond_to?(column) ? member.send(column) : lato_index_dynamic_value({
115
+ key: key,
116
+ model_name: model_name,
117
+ column: column,
118
+ member: member
119
+ })) %>
96
120
  </td>
97
121
  <% end %>
98
122
  </tr>
data/lib/lato/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lato
2
- VERSION = "0.1.27"
2
+ VERSION = "0.1.28"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lato
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.27
4
+ version: 0.1.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregorio Galante
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-16 00:00:00.000000000 Z
11
+ date: 2023-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails