recourse 5.8.0 → 5.9.0

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: 2b7756a87eb7ee1ef4267480a0e8370c1b63e50623a7a22cf0efe6a7a7a46644
4
- data.tar.gz: 0e7e84177bc55634878165dd8ba0fe19ad2c9d635c586211477d48431354cb47
3
+ metadata.gz: 2ba8a80061822d678d1c06188fbb414a30f289cb66ad3bcab42a3f49b8547f5d
4
+ data.tar.gz: 97c05101da058c66b87b5a743bc86f88d045b3af82f597975ba1889bed3f984a
5
5
  SHA512:
6
- metadata.gz: 468364cedb2192b3a73d7b4642689d0c6b984b156c0a20b7d6930c7a982e406d5c33132bc4fd8158b1c274eb47a925e299728d5f09530dc0421fdd72d303a243
7
- data.tar.gz: d34ed9fd8cbe6f355a0bf9889d7cfa4e4ce9ebd02686ac2f1070fefb3230322173855a0662f720a3380f1d8e10224b0e7d5bf125af13287a41a9f81dbf457f01
6
+ metadata.gz: 655a718dabdb3ef9293fc01fdcb2955564cceed83244ec6c39f93fe29223eed5a616907116843d9482eb7d4141d6f11358403f55bcf924bec78b206295238a8e
7
+ data.tar.gz: 87c137dbd709ee575981876bf3d3de2a6c6eaae3a09d747ee1b89e67f24c5ba52ffd1f0305953171e38cf8bc6aead8d7e0510cb1f1753ae2046f088137d6cc2d
data/README.md CHANGED
@@ -68,6 +68,19 @@ offers is the record's to say: nothing to add where there is already one, nothin
68
68
  delete where there is none. A write has no index to return to, so it lands on the
69
69
  record's own page: a singular resource is the collection of one.
70
70
 
71
+ Filters are drawn per enum, per boolean and per foreign key. A model adds one the schema
72
+ says nothing about — the type behind a `has_one`, a word reached through another table —
73
+ by naming the words itself, and naming the menu too, since there is no column to head it:
74
+
75
+ ```ruby
76
+ def self.filter_fields
77
+ super.merge 'integration_type_in' => { label: 'CRM', values: Integration.selectable }
78
+ end
79
+ ```
80
+
81
+ Naming the words is not leave to query through a table, so `ransackable_associations`
82
+ still says how far Ransack may reach.
83
+
71
84
  Every nested recourse gets namespaced after the parent:
72
85
 
73
86
  <img width="3824" height="2274" alt="Image" src="https://github.com/user-attachments/assets/9b242335-a25b-4fa8-8023-422538d235b0" />
@@ -1,7 +1,8 @@
1
1
  module Recourse
2
2
  module Helpers
3
3
  # The filter menus whose options are values rather than records: what a column
4
- # itself admits, read off the model rather than out of another table.
4
+ # itself admits, read off the model rather than out of another table — and the
5
+ # words a host named where no column admits anything.
5
6
  module Choices
6
7
  private
7
8
 
@@ -38,6 +39,16 @@ module Recourse
38
39
  filter_menu predicate, title, values, choices_all(title)
39
40
  end
40
41
 
42
+ # A menu of the words a host named, for a predicate no column of this model
43
+ # describes: the type behind a `has_one`, or anything else Ransack can ask that
44
+ # a schema says nothing about. Each option is a `[label, value]` pair — the words
45
+ # read, the value submitted — or a bare word standing as both. There is no column
46
+ # to take a heading from, so the `label:` is what heads it and what the way back
47
+ # is named after.
48
+ def values_filter(predicate, label, values)
49
+ filter_menu predicate, label, values, choices_all(label)
50
+ end
51
+
41
52
  # The way back to no filter at all, named after what the menu is of: `All
42
53
  # statuses`, `All CRMs`. An acronym keeps its capitals, the way every title
43
54
  # the gem lower-cases does.
@@ -1,7 +1,7 @@
1
1
  module Recourse
2
2
  module Helpers
3
3
  # The menus beside a search box: one per foreign key a table can be narrowed by,
4
- # and one per column whose values are a known few.
4
+ # and one per list of words a host named itself.
5
5
  module Filters
6
6
  private
7
7
 
@@ -24,9 +24,13 @@ module Recourse
24
24
  filters.except "#{parent.foreign_key}_in"
25
25
  end
26
26
 
27
- # One filter: the values a column of its own admits, or a menu of the records a
28
- # foreign key points at, holding whichever the request already asked for.
29
- def filter_field(predicate, label: nil, scope: nil)
27
+ # One filter: the words a host named, the values a column of its own admits, or
28
+ # a menu of the records a foreign key points at, holding whichever the request
29
+ # already asked for. `values:` is the shape for a predicate no column of this
30
+ # model describes, and it needs the `label:` there is no column to read one off.
31
+ def filter_field(predicate, label: nil, scope: nil, values: nil)
32
+ return values_filter predicate, label, values if values
33
+
30
34
  column = predicate.to_s.sub Search::LIST_PREDICATES, ''
31
35
 
32
36
  choice_filter(predicate, column, label) || reference_filter(predicate, column, label, scope)
@@ -1,4 +1,4 @@
1
1
  module Recourse
2
2
  # Version of the gem, read by the gemspec and by hosts checking compatibility.
3
- VERSION = '5.8.0'
3
+ VERSION = '5.9.0'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recourse
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.8.0
4
+ version: 5.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - claudiob