effective_memberships 0.8.1 → 0.8.2
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/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 +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: d55b0a5c31e8f259614c649af1fe89e2d36cb412652dc6d5ac96f051a925a7ee
         | 
| 4 | 
            +
              data.tar.gz: 3850e9a4d2ba175becb4e0f487bc041c726516d9462470ee6c464a19ece0d559
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: d6b197509eb8ce44fd7b15230c8b55171eccf2b017017f6e38eb45917453abf96a210118fd25df35d962cf448efc3625db45f1dafe720da32c18d1ee68ab7569
         | 
| 7 | 
            +
              data.tar.gz: 7c2e9ecd43439c7abf4a174ef1adae97938704a941e8338225b3905b38fb0e7d10aae5d075ce169b1140b77f193dc055349751569524163d5a301d65801848cf
         | 
| @@ -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
         | 
| @@ -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,7 +1,7 @@ | |
| 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.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Code and Effect
         | 
| @@ -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
         |