hot-glue 0.6.3 → 0.6.3.1

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: 54b2a13a1fb9740be4ca14f108d98b72d8f1250b6131389c5e1d2130f07578cb
4
- data.tar.gz: 15010c5e7fb34e35503b5a43aa563159d52f19c0b36f690ff03d67b7f1468060
3
+ metadata.gz: a7f159816e4a57c69d46d17fc9de3a1d01cfc5119f9a3533ad4b0b41889dd721
4
+ data.tar.gz: 6acd304e907a2b1518b9e243a04e5d937ab14a1bb4697b455480c2697eb5c031
5
5
  SHA512:
6
- metadata.gz: 7b4c9a3e48ea19199f95314a4f0bbff28ca7dfd5635c8ee34e3e2304944ad227d31cb359db1d7c4200f75336ebdb20133cfdb3c762cbe034590630e6d3051a0a
7
- data.tar.gz: c6c26412000d4bfa3ee27571aa430a8cf7b1c6dc454c55254a618bd312a14f754088ddb2dd77cf485dd69f433d06fe985a6ba34242f3df47607f4a3955703653
6
+ metadata.gz: d44841aef402fa110552d2418a3a266bde9ff5e4ad161c8974cf16c192300aa335db9bd7471a8d2dafe166ead5254f7914c20f0a26d4e125122f2d10e12fd547
7
+ data.tar.gz: b072b894e68efcd0dd88beeab4b09048fae8cd2f5591bf99e8ec4f94006b36ece8117344b20b371942c5dcf7c6aa17e26aea1991a4b3243f9fe0633b648cc195
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hot-glue (0.6.2)
4
+ hot-glue (0.6.3)
5
5
  ffaker (~> 2.16)
6
6
  kaminari (~> 1.2)
7
7
  rails (> 5.1)
@@ -139,14 +139,14 @@ GEM
139
139
  mini_mime (1.1.2)
140
140
  mini_portile2 (2.8.4)
141
141
  minitest (5.16.3)
142
- net-imap (0.4.7)
142
+ net-imap (0.4.9.1)
143
143
  date
144
144
  net-protocol
145
145
  net-pop (0.1.2)
146
146
  net-protocol
147
147
  net-protocol (0.2.2)
148
148
  timeout
149
- net-smtp (0.4.0)
149
+ net-smtp (0.4.0.1)
150
150
  net-protocol
151
151
  nio4r (2.5.8)
152
152
  nokogiri (1.13.9)
data/README.md CHANGED
@@ -1606,7 +1606,11 @@ These automatic pickups for partials are detected at buildtime. This means that
1606
1606
 
1607
1607
  # VERSION HISTORY
1608
1608
 
1609
- #### D2024-01-15 - v0.6.3
1609
+ #### 2024-01-16 - v0.6.3.1
1610
+ Adds support for boolean modified datetime search; now, when using a modify= to turn a datetime into a boolean, the search box behaves appropriately and shows a 3-way radio picker: all, falsy, truthy.
1611
+ (Only implemented for datetime)
1612
+
1613
+ #### 2024-01-15 - v0.6.3
1610
1614
 
1611
1615
  ## Set Searching
1612
1616
 
@@ -208,6 +208,14 @@ module HotGlue
208
208
  end
209
209
  end
210
210
 
211
+ def boolean_modified_datetime_constructor(field,search)
212
+ unless search == '-1'
213
+ ["#{field} #{search == '0' ? 'IS NULL' : 'IS NOT NULL'}"]
214
+ else
215
+ nil
216
+ end
217
+ end
218
+
211
219
  private
212
220
 
213
221
  def server_timezone_offset # returns integer of hours to add/subtract from UTC
@@ -83,16 +83,12 @@ class BooleanField < Field
83
83
 
84
84
  def search_field_output
85
85
  " <%= f.radio_button('q[0][#{name}_match]', '-1', checked: @q[\'0\']['#{name}_match']==-1 ? '' : 'checked', class: '#{@layout_strategy.form_checkbox_input_class}') %>\n" +
86
- " <%= f.label('q[0][#{name}_match]', value: '-1', for: 'q[0][#{name}_match]_-1' ) %>\n" +
87
-
86
+ " <%= f.label('All', value: '-1', for: 'q[0][#{name}_match]_-1' ) %>\n" +
88
87
  " <%= f.radio_button('q[0][#{name}_match]', '0', checked: @q[\'0\']['#{name}_match']==0 ? '' : 'checked', class: '#{@layout_strategy.form_checkbox_input_class}') %>\n" +
89
- " <%= f.label('q[0][#{name}_match]_0', value: '#{modify_binary? && modify_as[:binary][:falsy] || 'No'}', for: 'q[0][#{name}_match]_0') %>\n" +
88
+ " <%= f.label('No', value: '0'}', for: 'q[0][#{name}_match]_0') %>\n" +
90
89
  " <br /> <%= f.radio_button('q[0][#{name}_match]', '1', checked: @q[\'0\']['#{name}_match']==1 ? 'checked' : '' , class: '#{@layout_strategy.form_checkbox_input_class}') %>\n" +
91
- " <%= f.label('q[0][#{name}_match]_1', value: '#{modify_binary? && modify_as[:binary][:truthy] || 'Yes'}', for: 'q[0][#{name}_match]_1') %>\n"
92
-
90
+ " <%= f.label('Yes', value: '1'}', for: 'q[0][#{name}_match]_1') %>\n"
93
91
 
94
- # "<%= f.select 'q[0][#{name}_match]', options_for_select([['', ''], ['contains', 'contains'], ['is exactly', 'is_exactly'], ['starts with', 'starts_with'], ['ends with', 'ends_with']], @q[\'0\']['#{name}_match'] ), {} , { class: 'form-control match' } %>"+
95
- # "<%= f.text_field 'q[0][#{name}_search]', value: @q[\'0\'][:#{name}_search], autocomplete: 'off', size: 40, class: 'form-control', type: 'text' %>"
96
92
  end
97
93
 
98
94
 
@@ -50,7 +50,9 @@ class DateTimeField < Field
50
50
  end
51
51
 
52
52
  def search_field_output
53
- " <div data-controller='date-range-picker' >"+
53
+ if !modify_binary?
54
+
55
+ " <div data-controller='date-range-picker' >"+
54
56
  "\n <%= f.select 'q[0][#{name}_match]', options_for_select([['', ''], ['is on', 'is_on'], " +
55
57
  "\n ['is between', 'is_between'], ['is on or after', 'is_on_or_after'], " +
56
58
  "\n ['is before or on', 'is_before_or_on'], ['not on', 'not_on']], @q[\'0\']['#{name}_match'] ), {} ," +
@@ -58,14 +60,27 @@ class DateTimeField < Field
58
60
  "\n <%= datetime_local_field 'q[0]', '#{name}_search_start', {value: @q[\'0\'][:#{name}_search_start], autocomplete: 'off', size: 40, class: 'form-control', placeholder: 'start', 'data-date-range-picker-target': 'start' } %>" +
59
61
  "\n <%= datetime_local_field 'q[0]', '#{name}_search_end', {value: @q[\'0\'][:#{name}_search_end], autocomplete: 'off', size: 40, class: 'form-control', placeholder: 'end' , 'data-date-range-picker-target': 'end' } %>" +
60
62
  "\n </div>"
63
+ else
64
+ " <%= f.radio_button('q[0][#{name}_match]', '-1', checked: @q[\'0\']['#{name}_match']=='-1' ? 'checked' : '', class: '#{@layout_strategy.form_checkbox_input_class}') %>\n" +
65
+ " <%= f.label('All', value: '-1', for: 'q[0][#{name}_match]_-1' ) %>\n" +
66
+ " <%= f.radio_button('q[0][#{name}_match]', '0', checked: @q[\'0\']['#{name}_match']=='0' ? 'checked' : '', class: '#{@layout_strategy.form_checkbox_input_class}') %>\n" +
67
+ " <%= f.label('No', value: '0', for: 'q[0][#{name}_match]_0') %>\n" +
68
+ " <%= f.radio_button('q[0][#{name}_match]', '1', checked: @q[\'0\']['#{name}_match']=='1' ? 'checked' : '' , class: '#{@layout_strategy.form_checkbox_input_class}') %>\n" +
69
+ " <%= f.label('Yes', value: '1', for: 'q[0][#{name}_match]_1') %>\n" +
70
+ "<br />"
71
+ end
61
72
  end
62
73
 
63
74
 
64
75
  def where_query_statement
65
- ".where(*#{name}_query)"
76
+ ".where(#{name}_query)"
66
77
  end
67
78
 
68
79
  def load_all_query_statement
69
- "#{name}_query = date_query_constructor(:#{name}, @q['0'][:#{name}_match], @q['0'][:#{name}_search_start], @q['0'][:#{name}_search_end])"
80
+ if !modify_binary?
81
+ "#{name}_query = date_query_constructor(:#{name}, @q['0'][:#{name}_match], @q['0'][:#{name}_search_start], @q['0'][:#{name}_search_end])"
82
+ else
83
+ "#{name}_query = boolean_modified_datetime_constructor(:#{name}, @q['0'][:#{name}_match])"
84
+ end
70
85
  end
71
86
  end
@@ -92,25 +92,28 @@ module HotGlue
92
92
  columns = layout_object[:columns][:container]
93
93
  column_classes = layout_strategy.column_classes_for_form_fields
94
94
 
95
-
96
95
  res =+ "<\%= form_with url: #{form_path}, method: :get, html: {'data-turbo-action': 'advance', 'data-controller': 'search-form'} do |f| %>"
97
96
  res << "<div class=\"#{@layout_strategy.row_classes} search--#{@plural}\">"
98
97
 
99
98
  res << columns.map{ |column|
100
- " <div class='#{column_classes} search-cell--#{singular}--#{column.join("-")}' >" +
101
-
99
+ if (column & @search_fields.collect(&:to_sym )).size > 0
100
+ " <div class='#{column_classes} search-cell--#{singular}--#{column.join("-")}' >" +
102
101
  column.map { |col|
103
- label_class = columns_map[col].label_class
104
- label_for = columns_map[col].label_for
105
- the_label = "\n<label class='#{label_class}' for='search-#{label_for}'>#{col.to_s.humanize}</label>"
106
- search_field_result = columns_map[col].search_field_output
107
-
108
- add_spaces_each_line( "\n <span class='' >\n" +
109
- add_spaces_each_line( (form_labels_position == 'before' ? the_label || "" : "") +
110
- + " <br />\n" + search_field_result +
111
- (form_labels_position == 'after' ? the_label : "") , 4) +
112
- "\n </span>\n <br /></div>", 2)
102
+ if @search_fields.collect(&:to_sym).include?(col)
103
+ label_class = columns_map[col].label_class
104
+ label_for = columns_map[col].label_for
105
+ the_label = "\n<label class='#{label_class}' for='search-#{label_for}'>#{col.to_s.humanize}</label>"
106
+ search_field_result = columns_map[col].search_field_output
107
+
108
+ add_spaces_each_line( "\n <span class='' >\n" +
109
+ add_spaces_each_line( (form_labels_position == 'before' ? the_label || "" : "") +
110
+ + " <br />\n" + search_field_result +
111
+ (form_labels_position == 'after' ? the_label : "") , 4) +
112
+ "\n </span>\n <br /></div>", 2)
113
+ end
114
+
113
115
  }.join("\n")
116
+ end
114
117
  }.join("\n")
115
118
  res << "<div class='#{column_classes}'>"
116
119
  if @search_clear_button
@@ -513,6 +513,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
513
513
  @search = options['search']
514
514
  if @search == 'set'
515
515
  @search_fields = options['search_fields'].split(',') || @columns
516
+
516
517
  # within the set search we will take out any fields on the query list
517
518
  # or the field
518
519
  @search_query_fields = options['search_query_fields'].split(',') || []
@@ -1454,7 +1455,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
1454
1455
  end
1455
1456
 
1456
1457
  if pundit
1457
- res << "@#{ plural_name } = policy_scope(#{ object_scope }).page(params[:page])#{ n_plus_one_includes }#{ ".per(per)" if @paginate_per_page_selector }"
1458
+ res << " @#{ plural_name } = policy_scope(#{ object_scope }).page(params[:page])#{ n_plus_one_includes }#{ ".per(per)" if @paginate_per_page_selector }"
1458
1459
  else
1459
1460
  if !@self_auth
1460
1461
  res << spaces(4) + "@#{ plural_name } = #{ object_scope.gsub("@",'') }#{ n_plus_one_includes }.page(params[:page])#{ ".per(per)" if @paginate_per_page_selector }"
@@ -1470,14 +1471,16 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
1470
1471
  res << "@#{ plural_name } = #{ class_name }.all"
1471
1472
  else
1472
1473
  res << "@#{ plural_name } = #{ class_name }.where(id: #{ auth_object.gsub("@",'') }.id)#{ n_plus_one_includes }"
1473
- if @search_fields
1474
- res << @search_fields.collect{ |field|
1475
- @columns_map[field.to_sym].where_query_statement
1476
- }.join("\n")
1477
- end
1474
+
1478
1475
  res << ".page(params[:page])#{ ".per(per)" if @paginate_per_page_selector }"
1479
1476
  end
1480
1477
  end
1478
+ res << "\n"
1479
+ if @search_fields
1480
+ res << @search_fields.collect{ |field|
1481
+ spaces(4) + "@#{plural_name} = @#{plural_name}" + @columns_map[field.to_sym].where_query_statement + " if #{field}_query"
1482
+ }.join("\n")
1483
+ end
1481
1484
  res
1482
1485
  end
1483
1486
 
@@ -1,5 +1,5 @@
1
1
  module HotGlue
2
2
  class Version
3
- CURRENT = '0.6.3'
3
+ CURRENT = '0.6.3.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hot-glue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.6.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Fleetwood-Boldt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-15 00:00:00.000000000 Z
11
+ date: 2024-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails