ez-resources 0.2.1 → 0.2.3

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: 4e1bb8408ecf50c3f37c711f2dc794539db2100668807bee71a14497599fbdf8
4
- data.tar.gz: c0b7daf6075b77cc36bdfad87a2ead85ea077117c7729e9a1bbb905fab206f12
3
+ metadata.gz: 0a317ea72d6485a3d0e87da7a1eac6e6cf86247e51cbbba211ffff43ef90fac1
4
+ data.tar.gz: 9640c94a71e4928409229f0c1fb719bcb769e46856a972088f8443d5609ad856
5
5
  SHA512:
6
- metadata.gz: fe4c148385baceb68d60985b1a3ed3097a051e57baaf4c7ffc7de1c33e4e0e9d505b612660c008d75d47c8b9faa2bcd39983a73489aa135b50b62038891206e4
7
- data.tar.gz: a79bd3413544b51fe22762faaccc36c5caae456d7584577743d13e4081f0130737acc44c86d6d2286555d679e73ea0f92addfd052256e090d6267762a9e00250
6
+ metadata.gz: b33cca2c20343a57a9462a6378d4469cbd41a0f35e13eb27370786e95c4d254180e49a7afa9a16b898d36b2f9517fb049cd5874ae653bec19b0b8de6e7c7f9ae
7
+ data.tar.gz: 80571b7351f5e7da1e068c816540a06f8599561d9fe5b6ec5378e8a1e8aabaed7120eda4b55f6220fa6b6d54933e961ebb1f80b916f2595b3afe16cca056f04c
@@ -33,7 +33,7 @@
33
33
  = edit_link(record)
34
34
  = remove_link(record)
35
35
  - model.collection_actions.each do |custom_action|
36
- = link_to t("actions.#{custom_action.name}"), custom_action.builder.call(controller, record), custom_action.options.merge(class: css_for('collection-table-td-action-item'))
36
+ = link_to custom_action_label(custom_action), custom_action.builder.call(controller, record), custom_action.options.merge(class: css_for('collection-table-td-action-item'))
37
37
 
38
38
  - if paginator && paginator.count > 20
39
39
  == pagination
@@ -56,6 +56,10 @@ module Ez
56
56
  end
57
57
  end
58
58
 
59
+ def custom_action_label(action)
60
+ action.options[:title] || t("actions.#{action.name}")
61
+ end
62
+
59
63
  def new_link
60
64
  return unless model.actions.include?(:new)
61
65
  return unless Manager::Hooks.can?(:can_create?, model)
@@ -7,12 +7,21 @@
7
7
  - model.collection_columns.each do |field|
8
8
  - if field.searchable && SEARCHABLE_FIELDS.include?(field.type)
9
9
  = div_for 'collection-search-panel-field'
10
- = f.input field_input_name(field),
11
- label: field_label(field),
12
- required: false,
13
- as: cast_field_type(field.type),
14
- collection: field.collection,
15
- include_blank: true
10
+ - if field.type == :checkboxes
11
+ = label_tag field.search_label
12
+ .checkboxes
13
+ - field.collection.each do |item|
14
+ .ui.checkbox
15
+ - checked = params.dig(:q, field.search_suffix) || []
16
+ = check_box_tag("q[#{field.search_suffix}][]", item.id, checked.include?(item.id.to_s), id: "checkbox-#{item.id}")
17
+ = label_tag item.id, item.name
18
+ - else
19
+ = f.input field_input_name(field),
20
+ label: field_label(field),
21
+ required: false,
22
+ as: cast_field_type(field.type),
23
+ collection: field.collection,
24
+ include_blank: true
16
25
 
17
26
  = f.submit t('actions.apply'), class: css_for('collection-search-panel-submit-button')
18
27
 
@@ -3,7 +3,7 @@
3
3
  module Ez
4
4
  module Resources
5
5
  class SearchCell < ApplicationCell
6
- SEARCHABLE_FIELDS = %i[string association select link boolean].freeze
6
+ SEARCHABLE_FIELDS = %i[string association select link boolean checkboxes].freeze
7
7
 
8
8
  form
9
9
 
@@ -26,7 +26,7 @@ module Ez
26
26
  end
27
27
 
28
28
  def field_label(field)
29
- "#{field.title} (#{t "search.suffix.#{field.search_suffix}"})"
29
+ field.search_label || "#{field.title} (#{t "search.suffix.#{field.search_suffix}"})"
30
30
  end
31
31
 
32
32
  private
@@ -38,6 +38,10 @@ module Ez
38
38
  def association?(field)
39
39
  field.type == :association && field.options[:association].present?
40
40
  end
41
+
42
+ def checked_checkbox
43
+ params.dig(:q, field.search_suffix) || []
44
+ end
41
45
  end
42
46
  end
43
47
  end
@@ -20,6 +20,7 @@ module Ez
20
20
  :searchable,
21
21
  :sortable,
22
22
  :search_suffix,
23
+ :search_label,
23
24
  :options
24
25
 
25
26
  def initialize(options = {})
@@ -38,6 +39,7 @@ module Ez
38
39
  @searchable = options.delete(:searchable) != false
39
40
  @sortable = options.delete(:sortable) || false
40
41
  @search_suffix = options.delete(:search_suffix) || :cont
42
+ @search_label = options.delete(:search_label)
41
43
  @options = options # use for all other custom options
42
44
  end
43
45
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ez
4
4
  module Resources
5
- VERSION = '0.2.1'
5
+ VERSION = '0.2.3'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ez-resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Volodya Sveredyuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-30 00:00:00.000000000 Z
11
+ date: 2023-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cells-rails