hot-glue 0.6.27 → 0.6.28
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +32 -4
- data/lib/generators/hot_glue/markup_templates/erb.rb +18 -11
- data/lib/generators/hot_glue/scaffold_generator.rb +52 -12
- data/lib/hotglue/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 139de0a1f6e85c50561d3b69a74618abe2fc808908b7d217adefcd23bf1ee569
|
4
|
+
data.tar.gz: 547d675591fbf331fb2019fc29ddb5bebb080cdd97f523f4c5b8c9ca703739f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 565d6cc9513225395e67015b00b7ef669be883fed53777d0a737328018241a7e2982dc2783bca48962ec7c0eb469ed816ca624b0c444d28f392b103b234364f6
|
7
|
+
data.tar.gz: 1ab45d51300b844444206c685b8ac068dc9b5e22e5399691d342173a5c00c9e0a238673b599a326a8f5919b6e6df78b4f3937fe6fcaf89a328701957cd36626c
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1680,7 +1680,7 @@ Within each option is a label and ruby scope, separated by a colon (:).
|
|
1680
1680
|
|
1681
1681
|
The label comes before the colon the ruby scope. The ruby scope should be specified here without a dot. Each ruby scope must be defined on your model. If there is no scope specified, we assume "all", but we still need to specify a label for "All", which is why in the example above "All" has no colon after it.
|
1682
1682
|
|
1683
|
-
|
1683
|
+
#### Radio Example
|
1684
1684
|
|
1685
1685
|
`--phantom-search='radio_status[Pending:pending|Rejected:rejected|Accepted:accepted|All]'`
|
1686
1686
|
|
@@ -1702,10 +1702,33 @@ This produces a search interface with four options listed as radio buttons:
|
|
1702
1702
|
|
1703
1703
|
The pending, approved, and rejected options will return search results with the corresponding scopes applied. The 'All' option will behave as a no-op, leaving the root search intact (giving all of the other modifications that Hot glue provides in different functionality).
|
1704
1704
|
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1705
|
+
##### Checkboxes example
|
1706
|
+
|
1707
|
+
`rails generate hot_glue:scaffold Invoice --gd --phantom-search='checkboxes_AAA[With Paid:not_paid:|Hide free accounts::without_free_accounts]'`
|
1708
|
+
|
1709
|
+
|
1710
|
+
The syntax is similiar to the radio buttons except that each choice (within `[...]`, separated by `|`) is required to have THREE options, separated by colons `:`
|
1711
|
+
1) the label
|
1712
|
+
2) the OFF case (checkbox is unchecked)
|
1713
|
+
3) the ON case (checkbox is checked)
|
1714
|
+
|
1715
|
+
The scope definition between the `:` characters **may be empty**, in which case this is interprested as "all"
|
1716
|
+
|
1717
|
+
Since checkboxes start as off (unchecked) by default, you can create layouts that show the normal case with the checkboxes off, but show special cases with the checkboxes on.
|
1718
|
+
(This can either exclude or include depending on your preference.)
|
1708
1719
|
|
1720
|
+
In this Invoice scaffold, we have two scopes, searching for fields on our invoice model:
|
1721
|
+
|
1722
|
+
`scope :not_paid, -> {where(paid_at: nil)}`
|
1723
|
+
`scope :without_free_accounts, -> {where(free_account: false)}`
|
1724
|
+
|
1725
|
+
In the checkboxes phantom search we build above, notice by default:
|
1726
|
+
|
1727
|
+
- the PAID invoices do not appear in the search result (the scope `.not_paid` is applied as the OFF scope for the "With Paid" choice. So when you load the page, you see only unpaid invoices. If you check "With Paid" checkbox, there is no scope specified "all" is used indicating not modification is applied and all records are shown.
|
1728
|
+
- both free & non-free accounts (which are simply tracked by a boolean `free_account`) are shown by default, but when you use the "Hide free accounts" checkbox, the scope `.without_free_accounts` is applied, thus hiding the free accounts.
|
1729
|
+
|
1730
|
+
Remember, unlike radio choices which apply exclusively (since the user can select only 1 radio choice at time), checkboxes create
|
1731
|
+
combined search criteria. These combine with all of the other search criteria within the search set, making one big "AND ... AND ... AND" query.
|
1709
1732
|
|
1710
1733
|
### `--stimmify` or `--stimmify=xyz`
|
1711
1734
|
|
@@ -2210,6 +2233,11 @@ These automatic pickups for partials are detected at build time. This means that
|
|
2210
2233
|
|
2211
2234
|
|
2212
2235
|
# VERSION HISTORY
|
2236
|
+
|
2237
|
+
#### 2025-09-26 - v.0.6.28
|
2238
|
+
- Checkboxes option for Phantom Search (previously phantom searches only supported radio).
|
2239
|
+
See "Checkboxes example" under the docs for `--phantom-search` above
|
2240
|
+
|
2213
2241
|
#### 2025-09-24 - v0.6.27
|
2214
2242
|
- Fixes to namespaced models (this is when the model file has a namespace); it now correctly does not namespace the route (fix to plurality)
|
2215
2243
|
|
@@ -149,22 +149,29 @@ module HotGlue
|
|
149
149
|
# phantom searches
|
150
150
|
@phantom_search.each_key do |search_field|
|
151
151
|
data = @phantom_search[search_field]
|
152
|
-
|
153
|
-
|
152
|
+
res << "<div>"
|
153
|
+
res << "<label>#{data[:name]}</label><br />"
|
154
154
|
|
155
|
-
|
156
|
-
|
157
|
-
data[:
|
155
|
+
data[:choices].each do |choice|
|
156
|
+
dom_label = choice[:label].downcase.gsub(" ","_")
|
157
|
+
if data[:type] == "radio"
|
158
158
|
res << "\n<input type='radio'
|
159
|
-
id='#{search_field}_search__#{
|
160
|
-
name='q[0][#{search_field}_search]' value='#{
|
161
|
-
<%= 'checked' if @q['0'][:#{search_field}_search] == \"#{
|
162
|
-
|
159
|
+
id='#{search_field}_search__#{dom_label}}'
|
160
|
+
name='q[0][#{search_field}_search]' value='#{dom_label}'
|
161
|
+
<%= 'checked' if @q['0'][:#{search_field}_search] == \"#{dom_label}\" %> />"
|
162
|
+
elsif data[:type] == "checkboxes"
|
163
|
+
res << "\n<input type='checkbox'
|
164
|
+
id='#{search_field}_search__#{dom_label}'
|
165
|
+
name='q[0][#{search_field}_search__#{dom_label}]'
|
166
|
+
value='1'
|
167
|
+
<%= 'checked' if @q['0'][:#{search_field}_search__#{dom_label}] %> />"
|
168
|
+
|
163
169
|
end
|
170
|
+
res << "\n<label for='#{search_field}_search__#{dom_label}'>#{choice[:label]}</label> <br/>"
|
171
|
+
end
|
164
172
|
|
165
|
-
|
173
|
+
res << "</div>"
|
166
174
|
|
167
|
-
end
|
168
175
|
end
|
169
176
|
|
170
177
|
|
@@ -731,16 +731,30 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
731
731
|
}
|
732
732
|
|
733
733
|
choices.each do |choice|
|
734
|
-
|
735
|
-
|
736
|
-
|
734
|
+
if type == "radio"
|
735
|
+
choice_label = choice.split(":")[0]
|
736
|
+
choice_scope = choice.split(":")[1]
|
737
|
+
elsif type == "checkboxes"
|
738
|
+
choice_label = choice.split(":")[0]
|
739
|
+
choice_scope_negative = choice.split(":")[1]
|
740
|
+
choice_scope = choice.split(":")[2]
|
741
|
+
end
|
742
|
+
|
743
|
+
if choice_scope.nil? || choice_scope.strip.empty?
|
737
744
|
choice_scope = "all"
|
738
745
|
end
|
739
746
|
|
747
|
+
if choice_scope_negative.nil? || choice_scope_negative.strip.empty?
|
748
|
+
choice_scope_negative = "all"
|
749
|
+
end
|
750
|
+
|
740
751
|
choice_scope = ".#{choice_scope}" if !choice_scope.start_with?(".")
|
752
|
+
choice_scope_negative = ".#{choice_scope_negative}" if !choice_scope_negative.start_with?(".")
|
753
|
+
|
741
754
|
@phantom_search[label.to_sym][:choices] << {
|
742
755
|
label: choice_label,
|
743
756
|
scope: choice_scope,
|
757
|
+
scope_negative: choice_scope_negative,
|
744
758
|
}
|
745
759
|
end
|
746
760
|
puts "phantom search #{@phantom_search}"
|
@@ -1834,11 +1848,25 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
1834
1848
|
end
|
1835
1849
|
|
1836
1850
|
@phantom_search.each do |phantom_key, phantom_data|
|
1837
|
-
phantom_data[:
|
1838
|
-
|
1839
|
-
|
1851
|
+
if phantom_data[:type] == "radio"
|
1852
|
+
phantom_data[:choices].each do |choice|
|
1853
|
+
unless choice[:scope] == ".all"
|
1854
|
+
res << "\n @#{plural} = @#{plural}#{choice[:scope]} if @q['0'][:#{phantom_key}_search] == \"#{choice[:label]}\""
|
1855
|
+
end
|
1856
|
+
end
|
1857
|
+
elsif phantom_data[:type] == "checkboxes"
|
1858
|
+
phantom_data[:choices].each do |choice|
|
1859
|
+
|
1860
|
+
# positive case
|
1861
|
+
unless choice[:scope] == ".all"
|
1862
|
+
res << "\n @#{plural} = @#{plural}#{choice[:scope]} if @q['0'][:#{phantom_key}_search__#{choice[:label].gsub(" ", "_").downcase}] == \"1\""
|
1863
|
+
end
|
1864
|
+
unless choice[:scope_negative] == ".all"
|
1865
|
+
res << "\n @#{plural} = @#{plural}#{choice[:scope_negative]} if @q['0'][:#{phantom_key}_search___#{choice[:label].gsub(" ", "_").downcase}] != \"1\""
|
1866
|
+
end
|
1840
1867
|
end
|
1841
1868
|
end
|
1869
|
+
|
1842
1870
|
res << "\n"
|
1843
1871
|
end
|
1844
1872
|
|
@@ -1907,12 +1935,24 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
1907
1935
|
}.reduce({}, :merge)
|
1908
1936
|
|
1909
1937
|
phantom_search_fields = @phantom_search.collect{| k,v|
|
1910
|
-
|
1911
|
-
|
1912
|
-
|
1913
|
-
|
1914
|
-
|
1915
|
-
|
1938
|
+
if v[:type] == "radio"
|
1939
|
+
default = v[:choices][0]
|
1940
|
+
{
|
1941
|
+
"#{k}_match".to_sym => "",
|
1942
|
+
"#{k}_search".to_sym => "#{default[:label]}"
|
1943
|
+
}
|
1944
|
+
elsif v[:type] == "checkboxes"
|
1945
|
+
v[:choices].collect{ |c|
|
1946
|
+
{
|
1947
|
+
"#{k}_#{c[:label].gsub(" ", "_").downcase}".to_sym => ""
|
1948
|
+
}
|
1949
|
+
}
|
1950
|
+
end
|
1951
|
+
}
|
1952
|
+
|
1953
|
+
phantom_search_fields.flatten!
|
1954
|
+
phantom_search_fields = phantom_search_fields.reduce({}, :merge)
|
1955
|
+
|
1916
1956
|
return {"0" => (default_fields.merge(phantom_search_fields))}
|
1917
1957
|
end
|
1918
1958
|
end
|
data/lib/hotglue/version.rb
CHANGED
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.
|
4
|
+
version: 0.6.28
|
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: 2025-09-
|
11
|
+
date: 2025-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|