effective_products 0.5.0 → 0.5.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: 6fcdbeb5c90fb3b4d7a67d83deb961d25f7158229300d3afc56d936441b79ca0
4
- data.tar.gz: 7cce45fb0b386fd6389d60294e53a854d44f3b764d71a77d9603679b550cc00a
3
+ metadata.gz: 3dc771ff3044d1e94868f560e22f8109b9c5d2daf9dc9d10f6904c7def5761cb
4
+ data.tar.gz: a62fa8ce36db37c1853d30b1b13713626908565ee8e51eef7f1c2e18aacc8499
5
5
  SHA512:
6
- metadata.gz: 1783696edd49f896da317f8e73fdf8a884a5cca7697d71e233376d7fa0c75603133049454d6a40ffa205f260b02a6f101e6069ced13555b6f4eae311d12acc93
7
- data.tar.gz: 8ef6e547e4d29ca9346604b59631ff5e30354727d77173d815330e8dfc640288c7ae6d6898a7acfb079d193ad07b8316e09e4d02e267b585097326bd2f9fa1f6
6
+ metadata.gz: 332000cfc71e3677d70fd46ceb177a24f15d8425d1bc3926c89812e71bca1c85e993c18e50ef16c4a14c0a58a208635251b392ce6548309ec3f1322ebb814378
7
+ data.tar.gz: 52141a466fc83a8a2387b0d8115af3d1077daf862c794dff259d57da870109a15e7be2c80e5fbac41501bb694b21c1f2042761837483b38e3057cd1c26f1cd1c
@@ -20,8 +20,22 @@ module Admin
20
20
  col :issued_at, as: :date, visible: false
21
21
 
22
22
  col :owner, label: 'User', search: :string
23
- col :parent
24
-
23
+ val(:current_category, label: 'Current Category', search: category_search_collection, sort: false, visible: false) do |stamp|
24
+ stamp.owner.try(:membership).try(:categories).to_a.map(&:to_s).presence
25
+ end.search do |collection, term, _, index|
26
+ collection.select { |row| Array(row[index]).include?(term.to_s) }
27
+ end
28
+ val(:applicant_category, label: 'Applicant Category', search: category_search_collection, sort: false, visible: false) do |stamp|
29
+ stamp.applicant_categories.presence
30
+ end.search do |collection, term, _, index|
31
+ collection.select { |row| Array(row[index]).include?(term.to_s) }
32
+ end
33
+ val(:applicant_status, label: 'Applicant Status', search: applicant_status_search_collection, sort: false, visible: false) do |stamp|
34
+ stamp.applicant_statuses.presence
35
+ end.search do |collection, term, _, index|
36
+ collection.select { |row| Array(row[index]).include?(term.to_s) }
37
+ end
38
+ col :parent, badge: false, visible: false
25
39
  col(:email, visible: false) { |stamp| mail_to(stamp.owner.email) }
26
40
  col(:phone, visible: false) { |stamp| stamp.owner.phone }
27
41
 
@@ -32,7 +46,9 @@ module Admin
32
46
  col :name
33
47
  col :name_confirmation, visible: false
34
48
 
35
- col :category, search: EffectiveProducts.stamp_categories
49
+ col :stamp_category, search: EffectiveProducts.stamp_categories do |stamp|
50
+ stamp.category
51
+ end
36
52
 
37
53
  col(:shipping_address, visible: true) { |stamp| stamp.owner.try(:shipping_address).try(:to_html) }
38
54
  col(:address1, visible: false) { |stamp| stamp.owner.try(:shipping_address).try(:address1) }
@@ -53,5 +69,19 @@ module Admin
53
69
  collection do
54
70
  Effective::Stamp.deep.all
55
71
  end
72
+
73
+ def category_search_collection
74
+ return false unless defined?(EffectiveMemberships)
75
+ return false unless view.current_user.class.try(:effective_memberships_user?)
76
+
77
+ EffectiveMemberships.Category.sorted.map(&:to_s)
78
+ end
79
+
80
+ def applicant_status_search_collection
81
+ return false unless defined?(EffectiveMemberships)
82
+ return false unless view.current_user.class.try(:effective_memberships_user?)
83
+
84
+ EffectiveMemberships.Applicant.const_get(:STATUSES).map { |status| status.to_s.humanize }
85
+ end
56
86
  end
57
87
  end
@@ -67,6 +67,38 @@ module Effective
67
67
  [model_name.human, name.presence, category.presence].compact.join(' - ')
68
68
  end
69
69
 
70
+ def applicant_status
71
+ applicant_statuses.to_sentence.presence
72
+ end
73
+
74
+ def applicant_category
75
+ applicant_categories.to_sentence.presence
76
+ end
77
+
78
+ def applicant_categories
79
+ linked_applicants
80
+ .filter_map { |applicant| applicant.try(:category) }
81
+ .map(&:to_s)
82
+ .uniq
83
+ end
84
+
85
+ def applicant_statuses
86
+ linked_applicants
87
+ .filter_map { |applicant| applicant.try(:status).presence }
88
+ .map { |status| status.to_s.humanize }
89
+ .uniq
90
+ end
91
+
92
+ def linked_applicants
93
+ if parent.class.try(:effective_memberships_applicant?)
94
+ [parent]
95
+ elsif parent.respond_to?(:registration_applicants)
96
+ Array(parent.registration_applicants)
97
+ else
98
+ []
99
+ end
100
+ end
101
+
70
102
  # Called by a stamp wizard, applicant or fee payment when submitted
71
103
  def submit!
72
104
  submitted!
@@ -1,17 +1,22 @@
1
1
  = effective_table_with(stamp) do |f|
2
- = f.content_for :owner, label: 'User' do
3
- - owner = f.object.owner
2
+ = f.belongs_to :owner, label: 'User'
3
+ = render 'effective/stamps/fields', f: f, stamp: f.object
4
4
 
5
- = owner.to_s
6
-
7
- - if owner.try(:email).present?
8
- %br
9
- = mail_to(owner.email)
10
-
11
- - if owner.try(:phone).present?
12
- %br
13
- = owner.phone
14
-
15
- - if owner.try(:membership).try(:number).present?
16
- %br
17
- Member Number #{owner.membership.number}
5
+ = f.text_field :status
6
+ = f.datetime_field :submitted_at
7
+ = f.datetime_field :purchased_at
8
+ = f.datetime_field :issued_at
9
+ = f.belongs_to :parent
10
+ = f.text_field :applicant_status, label: 'Applicant Status'
11
+ = f.email_field :email, value: (f.object.owner.try(:email).presence || '-')
12
+ = f.text_field :phone, value: (f.object.owner.try(:phone).presence || '-')
13
+ = f.text_field :member_number, label: 'Member #', value: (f.object.owner.try(:membership).try(:number).presence || '-')
14
+ = f.text_field :current_category, label: 'Current Category', value: (f.object.owner.try(:membership).try(:categories).to_a.to_sentence.presence || '-')
15
+ = f.text_field :applicant_category, label: 'Applicant Category', value: (f.object.applicant_category || '-')
16
+ = f.belongs_to :purchased_order
17
+ = f.price_field :price
18
+ = f.boolean_row :tax_exempt
19
+ = f.text_field :qb_item_name
20
+ = f.datetime_field :created, label: 'Created at', value: (f.object.created_at || '-')
21
+ = f.datetime_field :updated, label: 'Updated at', value: (f.object.updated_at || '-')
22
+ = f.text_field :id
@@ -1,3 +1,3 @@
1
1
  module EffectiveProducts
2
- VERSION = '0.5.0'.freeze
2
+ VERSION = '0.5.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_products
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
@@ -43,14 +43,14 @@ dependencies:
43
43
  requirements:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 4.0.0
46
+ version: 4.37.0
47
47
  type: :runtime
48
48
  prerelease: false
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: 4.0.0
53
+ version: 4.37.0
54
54
  - !ruby/object:Gem::Dependency
55
55
  name: effective_orders
56
56
  requirement: !ruby/object:Gem::Requirement