mensa 0.3.3 → 0.3.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4370665a3982e3464306fd155b455aef8c62d2fda14c474771042a30af3038cb
4
- data.tar.gz: 91c50234915ffeb886a6569575d33fa7b85eb453f1da8991e075ad46fe5101ac
3
+ metadata.gz: 194b34ee31bebddc3962cc66e5c789e5369f828eb6087f67f72b54aba97f65d8
4
+ data.tar.gz: 1ead92c4d986f5e69c3d5745fcee27541f8205bf0106bd25f757b7603cdc117f
5
5
  SHA512:
6
- metadata.gz: 3cbde51c093adcccaad8b2814b6c436a8be160e6fa68bab0cc2463c22560d325017f736577add7ffb2b3e4974e2df1abce81ca3a89e83ea3bb9e77d42d65800a
7
- data.tar.gz: 9691484b7695d915849eebbc204f8ca22c560d38928c5e0d78285b4eb1f7b140f29aad0498d455549e359f97590e9659f5e1d2a049b4b3a17ffc2c10bc9c5397
6
+ metadata.gz: f5c078859d1c6214b8b65ab36fd077a2c36e2f5b50a69efd0dc20621d6373977be10ed543bc68add8b81338b4322903c3c305a15a0bd47c8ea906d77953c2a9d
7
+ data.tar.gz: 6e68ccdd3ffea1ef460876f61a9d624a8d7de198addad7c712bfac67eac1cc08fbe0874221ba76f241ce5d47c8dec0b09c7950f058865ee232ca540868bea95d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mensa (0.3.2)
4
+ mensa (0.3.3)
5
5
  csv
6
6
  importmap-rails
7
7
  pagy (>= 43)
@@ -152,7 +152,7 @@ GEM
152
152
  minitest (6.0.6)
153
153
  drb (~> 2.0)
154
154
  prism (~> 1.5)
155
- net-imap (0.6.4)
155
+ net-imap (0.6.4.1)
156
156
  date
157
157
  net-protocol
158
158
  net-pop (0.1.2)
@@ -183,7 +183,7 @@ GEM
183
183
  overmind (2.5.1-arm-linux)
184
184
  overmind (2.5.1-arm64-darwin)
185
185
  overmind (2.5.1-x86_64-darwin)
186
- pagy (43.5.5)
186
+ pagy (43.5.6)
187
187
  json
188
188
  uri
189
189
  yaml
@@ -352,12 +352,12 @@ GEM
352
352
  unicode-emoji (4.2.0)
353
353
  uri (1.1.1)
354
354
  useragent (0.16.11)
355
- view_component (3.24.0)
355
+ view_component (3.25.0)
356
356
  activesupport (>= 5.2.0, < 8.2)
357
357
  concurrent-ruby (~> 1)
358
358
  method_source (~> 1.0)
359
359
  websocket (1.2.11)
360
- websocket-driver (0.8.0)
360
+ websocket-driver (0.8.1)
361
361
  base64
362
362
  websocket-extensions (>= 0.1.0)
363
363
  websocket-extensions (0.1.5)
data/README.md CHANGED
@@ -65,6 +65,8 @@ class UserTable < ApplicationTable
65
65
  title "Delete row"
66
66
  link { |user| user_path(user) }
67
67
  icon "fa-regular fa-trash"
68
+ # You could also give it a block, which takes the record as an argument, to choose icons dynamically
69
+ # icon { |product| product.inventory? ? "fal fa-shelves" : "fal fa-shelves-empty" }
68
70
  link_attributes data: {"turbo-confirm": "Are you sure you want to delete the user?", "turbo-method": :delete}
69
71
  show ->(user) { true }
70
72
  end
@@ -173,7 +175,14 @@ $ gem install mensa
173
175
  Always use `bundle` to install the gem. Next use the install generator to install migrations, add an initializer and do other setup:
174
176
 
175
177
  ```bash
176
- $ rails g mensa:install
178
+ $ rails g mensa:install
179
+ $ rails mensa:install:migrations
180
+ ```
181
+
182
+ Next you can run the generator to generate a table:
183
+
184
+ ```bash
185
+ $ rails g mensa:table:generate <model_name>
177
186
  ```
178
187
 
179
188
  ### Exports
@@ -1,7 +1,8 @@
1
1
  <% if action.show.call(row.record) %>
2
2
  <%= link_to(action.link ? table.original_view_context.instance_exec(row.record, &action.link) : "", {class: "action", title: action.title}.merge(action.link_attributes || {})) do %>
3
- <% if action.icon %>
4
- <i class="fa <%= action.icon %>"></i>
3
+
4
+ <% if icon = action.icon(row.record) %>
5
+ <i class="fa <%= icon %>"></i>
5
6
  <% else %>
6
7
  <%= name %>
7
8
  <% end %>
@@ -21,10 +21,17 @@ module Mensa
21
21
  @config = config
22
22
  end
23
23
 
24
+ def icon(record)
25
+ if @config[:icon].is_a?(Proc)
26
+ @config[:icon].call(record)
27
+ else
28
+ @config[:icon]
29
+ end
30
+ end
31
+
24
32
  config_reader :title
25
33
  config_reader :link, call: false
26
34
  config_reader :link_attributes
27
- config_reader :icon
28
35
  config_reader :show, call: false
29
36
  end
30
37
  end
@@ -9,7 +9,7 @@ module Mensa
9
9
  source_root File.expand_path("templates", __dir__)
10
10
 
11
11
  def copy_table_file
12
- template "table.rb", "app/tables/#{name}_table.rb"
12
+ template "table.rb", "app/tables/#{name.downcase}_table.rb"
13
13
  end
14
14
  end
15
15
  end
data/lib/mensa/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mensa
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mensa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom de Grunt