effective_memberships 0.8.1 → 0.8.3
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/app/models/concerns/effective_memberships_directory.rb +16 -31
- data/app/models/effective/membership.rb +0 -2
- data/app/views/effective/applicants/equivalences.html.haml +5 -2
- data/app/views/effective/membership_directory/_membership_directory.html.haml +4 -3
- data/app/views/effective/membership_directory/{_membership.html.haml → _membership_owner.html.haml} +1 -1
- data/lib/effective_memberships/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3936f6e8acaea0e3aea19acfb6ab2919eed75cf533997d7d3ceb9423acb67c1
|
4
|
+
data.tar.gz: d23bdf6c67f07b6d0558a4f03e40237b6a93a2a55603e9d534d4a9d63464f182
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9245f8060285f526b024a616fe0125460fe59567140fd106c6f657f1504b9e5385157ef24f3e3ca5f1ca27ac78280929ee9ea87021ef1ad202bfd03d39d1d526
|
7
|
+
data.tar.gz: 76586e73e7f04ff55343be3012169d5afb6b8fe3265279b46aab16c9f32f6798b7582282fe63bef73cc37278376538ac004b3a21691b4a0da932270786e22664
|
@@ -29,7 +29,8 @@ module EffectiveMembershipsDirectory
|
|
29
29
|
|
30
30
|
# Base collection to search. Can be configured per tenant.
|
31
31
|
def collection
|
32
|
-
|
32
|
+
# Example::User.members.membership_in_good_standing.all
|
33
|
+
raise('to be implemented by app membership_directory')
|
33
34
|
end
|
34
35
|
|
35
36
|
# Search Users and Organizations for only these fields. Passed into search_any. Return nil for all.
|
@@ -50,14 +51,14 @@ module EffectiveMembershipsDirectory
|
|
50
51
|
# Assigns the entire collection() if there are no search terms
|
51
52
|
# Otherwise validate the search terms
|
52
53
|
def search!
|
53
|
-
@
|
54
|
-
@
|
55
|
-
@
|
54
|
+
@membership_owners = build_collection()
|
55
|
+
@membership_owners = @membership_owners.none if present? && !valid?
|
56
|
+
@membership_owners
|
56
57
|
end
|
57
58
|
|
58
59
|
# The unpaginated results of the search
|
59
|
-
def
|
60
|
-
@
|
60
|
+
def membership_owners
|
61
|
+
@membership_owners || collection
|
61
62
|
end
|
62
63
|
|
63
64
|
# The paginated results
|
@@ -65,54 +66,38 @@ module EffectiveMembershipsDirectory
|
|
65
66
|
page = (page || 1).to_i
|
66
67
|
offset = [(page - 1), 0].max * per_page
|
67
68
|
|
68
|
-
|
69
|
+
membership_owners.limit(per_page).offset(offset)
|
69
70
|
end
|
70
71
|
|
71
72
|
protected
|
72
73
|
|
73
74
|
def build_collection
|
74
|
-
|
75
|
-
raise('expected an ActiveRecord collection') unless
|
75
|
+
owners = collection()
|
76
|
+
raise('expected an ActiveRecord collection') unless owners.kind_of?(ActiveRecord::Relation)
|
77
|
+
raise('expected a collection of membership_owners') unless owners.klass.respond_to?(:effective_memberships_owner?)
|
76
78
|
|
77
79
|
# Filter by term
|
78
80
|
if term.present?
|
79
|
-
|
81
|
+
owners = Effective::Resource.new(owners).search_any(term, columns: search_any_columns)
|
80
82
|
end
|
81
83
|
|
82
84
|
# Filter by first name
|
83
85
|
if first_name.present?
|
84
|
-
|
86
|
+
owners = Effective::Resource.new(owners).search_any(first_name, columns: :first_name)
|
85
87
|
end
|
86
88
|
|
87
89
|
# Filter by last name
|
88
90
|
if last_name.present?
|
89
|
-
|
91
|
+
owners = Effective::Resource.new(owners).search_any(last_name, columns: :last_name)
|
90
92
|
end
|
91
93
|
|
92
94
|
# Filter by category
|
93
95
|
if category.present?
|
94
96
|
cat = EffectiveMemberships.Category.where(id: category)
|
95
|
-
|
97
|
+
owners = owners.members_with_category(cat) if cat.present?
|
96
98
|
end
|
97
99
|
|
98
|
-
|
99
|
-
end
|
100
|
-
|
101
|
-
def search_owners(collection, term, columns = nil)
|
102
|
-
results = collection.none()
|
103
|
-
|
104
|
-
owner_klasses.each do |klass|
|
105
|
-
search = Effective::Resource.new(klass).search_any(term, columns: columns)
|
106
|
-
searched = collection.where(owner_type: klass.name, owner_id: search.select('id'))
|
107
|
-
|
108
|
-
results = results.or(searched)
|
109
|
-
end
|
110
|
-
|
111
|
-
collection.merge(results)
|
112
|
-
end
|
113
|
-
|
114
|
-
def owner_klasses
|
115
|
-
@owner_klasses ||= Effective::Membership.owner_klasses
|
100
|
+
owners
|
116
101
|
end
|
117
102
|
|
118
103
|
end
|
@@ -73,8 +73,6 @@ module Effective
|
|
73
73
|
scope :not_in_good_standing, -> { with_status(EffectiveMemberships.Registrar.not_in_good_standing_status) }
|
74
74
|
scope :in_good_standing, -> { without_status(EffectiveMemberships.Registrar.not_in_good_standing_status) }
|
75
75
|
|
76
|
-
scope :directory, -> { deep.in_good_standing.order(:id) }
|
77
|
-
|
78
76
|
before_validation do
|
79
77
|
self.registration_on ||= joined_on
|
80
78
|
end
|
@@ -6,12 +6,15 @@
|
|
6
6
|
%p You must include #{resource.min_applicant_equivalences} or more equivalent memberships.
|
7
7
|
|
8
8
|
- if resource.min_applicant_equivalences == 0
|
9
|
-
%p Equivalent memberships are not required.
|
9
|
+
%p Equivalent memberships are not required.
|
10
|
+
|
11
|
+
- if resource.applicant_equivalences.blank?
|
12
|
+
%p Click Add Another to add an equivalent membership.
|
10
13
|
|
11
14
|
= effective_form_with(model: resource, url: wizard_path(step), method: :put) do |f|
|
12
15
|
= f.hidden_field :id
|
13
16
|
|
14
|
-
= f.has_many(:applicant_equivalences, cards: true) do |aef|
|
17
|
+
= f.has_many(:applicant_equivalences, cards: true, build: false) do |aef|
|
15
18
|
%h4.mb-4 Equivalent Membership
|
16
19
|
|
17
20
|
= aef.text_field :name
|
@@ -8,9 +8,10 @@
|
|
8
8
|
|
9
9
|
- results.in_groups_of(3).each do |group|
|
10
10
|
.row.mt-4
|
11
|
-
- group.each do |
|
12
|
-
- next unless
|
13
|
-
.col-md
|
11
|
+
- group.each do |owner|
|
12
|
+
- next unless owner
|
13
|
+
.col-md
|
14
|
+
= render('effective/membership_directory/membership_owner', membership: owner.membership, owner: owner)
|
14
15
|
|
15
16
|
%nav.d-flex.justify-content-center
|
16
17
|
= bootstrap_paginate(results, per_page: membership_directory.per_page)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_memberships
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -481,8 +481,8 @@ files:
|
|
481
481
|
- app/views/effective/membership_cards/index.html.haml
|
482
482
|
- app/views/effective/membership_directory/_form.html.haml
|
483
483
|
- app/views/effective/membership_directory/_layout.html.haml
|
484
|
-
- app/views/effective/membership_directory/_membership.html.haml
|
485
484
|
- app/views/effective/membership_directory/_membership_directory.html.haml
|
485
|
+
- app/views/effective/membership_directory/_membership_owner.html.haml
|
486
486
|
- app/views/effective/membership_directory/index.html.haml
|
487
487
|
- app/views/effective/memberships/_dashboard.html.haml
|
488
488
|
- app/views/effective/memberships/_membership.html.haml
|