effective_resources 2.8.7 → 2.8.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b20557b39c6a58e12d87157ccc21b3ce99ac38e2a57e1c3c45b0a07333d45e05
4
- data.tar.gz: 2bfc034398f369c999e26f8907c6790d127102d9416b5914e63066b16003d452
3
+ metadata.gz: 6a38e2952ba5fef52c6aa082b18ef2d9261c32dcd89f629fa548b22b4c5f70b6
4
+ data.tar.gz: 0aebae2fb3691c17fcc6cbe84d3a153592cd0fd4c49aafdeadcf77d511bd5c30
5
5
  SHA512:
6
- metadata.gz: d2e218f0580ab6d3a5f7a2f7bfaf5d2d27967f1670628dbb8580d6e4d44717c80904ac4bbb33c15f1da079420e5a3518cfb0a1dc8ce00bd5c58d49396941bf43
7
- data.tar.gz: d2e2f6fd1cd3ca5a6de6b6c6e3ed306d10a1615b1b9abdc534d4510fa91612a79eb947ff08cc4746b57162ebc1e5d586adf4dc385a8f773b63878b6d59442235
6
+ metadata.gz: da673d1b40fbdf5c6ddf6322619c4cf8e1641b3aa28a81395de8080f5220d371a272f9cca5541eae8f8206c5020418d1562f1db3f22117c0513eb9fd2df0bc72
7
+ data.tar.gz: b0167300f0a180b5f7bb4445aa70750b6a606a38633d9fcb4ba22ea68d5e290602cfc5b659638e4703bed29fb2df8863ce4a94cdc59def680fdeec1acfefdc0f
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2019 Code and Effect Inc.
1
+ Copyright 2024 Code and Effect Inc.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -42,19 +42,32 @@ module EffectiveResourcesWizardHelper
42
42
  end
43
43
  end
44
44
 
45
- def render_wizard_resource(resource, as: nil, path: nil)
45
+ def render_wizard_resource_step(resource, step, as: nil, path: nil)
46
+ render_wizard_resource(resource, only: step, as: as, path: path)
47
+ end
48
+
49
+ def render_wizard_resource(resource, only: [], except: [], as: nil, path: nil)
46
50
  effective_resource = Effective::Resource.new(resource)
47
51
 
52
+ # Render path
48
53
  as ||= effective_resource.name
49
- path ||= effective_resource.view_file_path(nil)
54
+ path ||= effective_resource.wizard_file_path(resource)
50
55
  raise('expected a path') unless path.present?
51
56
 
52
57
  resource.render_path = path.to_s.chomp('/')
53
58
 
54
- resource.render_steps.map do |partial|
55
- resource.render_step = partial
59
+ # Render steps
60
+ only = Array(only)
61
+ except = Array(except)
62
+
63
+ steps = resource.render_steps
64
+ steps = (steps - except) if except.present?
65
+ steps = (steps & only) if only.present?
66
+
67
+ steps.map do |step|
68
+ resource.render_step = step
56
69
 
57
- render_if_exists("#{path}/#{partial}", as.to_sym => resource) || render('effective/acts_as_wizard/wizard_step', resource: resource, resource_path: path)
70
+ render_if_exists("#{path}/#{step}", as.to_sym => resource) || render('effective/acts_as_wizard/wizard_step', resource: resource, resource_path: path)
58
71
  end.join.html_safe
59
72
  end
60
73
 
@@ -5,8 +5,10 @@ module Effective
5
5
  module I18n
6
6
  def human_action_name(action)
7
7
  if klass.respond_to?(:model_name)
8
- value = ::I18n.t("activerecord.actions.#{klass.model_name.i18n_key}.#{action}")
9
- return value unless value.start_with?('translation missing:')
8
+ key = "activerecord.actions.#{klass.model_name.i18n_key}.#{action}"
9
+
10
+ value = ::I18n.t(key)
11
+ return value unless value.include?(key) # missing translation
10
12
  end
11
13
 
12
14
  if crud_actions.include?(action)
@@ -19,8 +21,10 @@ module Effective
19
21
 
20
22
  def human_action_confirm(action)
21
23
  if klass.respond_to?(:model_name)
22
- value = ::I18n.t("activerecord.actions.#{klass.model_name.i18n_key}.#{action}_confirm")
23
- return value unless value.start_with?('translation missing:')
24
+ key = "activerecord.actions.#{klass.model_name.i18n_key}.#{action}_confirm"
25
+
26
+ value = ::I18n.t(key)
27
+ return value unless value.include?(key) # missing translation
24
28
  end
25
29
 
26
30
  "Really #{human_action_name(action)} @resource?"
@@ -35,6 +35,15 @@ module Effective
35
35
  File.join(*[tenant_path, 'app/datatables', namespace, "effective_#{plural_name}_datatable.rb"].compact)
36
36
  end
37
37
 
38
+ # Wizards are kinda weird, we need some help for effective_memberships
39
+ def wizard_file_path(resource)
40
+ if resource.class.try(:effective_memberships_applicant?) || resource.class.try(:effective_memberships_applicant_review?)
41
+ File.join(*['effective', plural_name].compact)
42
+ else
43
+ view_file_path(nil)
44
+ end
45
+ end
46
+
38
47
  # Views
39
48
  def view_file(action = :index, partial: false)
40
49
  File.join(*[tenant_path, 'app/views', class_path, namespace, plural_name, "#{'_' if partial}#{action}.html.haml"].compact)
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '2.8.7'.freeze
2
+ VERSION = '2.8.9'.freeze
3
3
  end
@@ -180,12 +180,13 @@ module EffectiveResources
180
180
  end
181
181
  end
182
182
 
183
+ # effective_translate
183
184
  def self.et(resource, attribute = nil)
184
185
  if resource.respond_to?(:datatable_name)
185
186
  resource.datatable_name
186
- elsif resource.respond_to?(:model_name) == false
187
+ elsif resource.respond_to?(:model_name) == false # Just a string. Fees will do this
187
188
  value = I18n.t(resource)
188
- raise("Missing translation: #{resource}") if value.start_with?('translation missing:')
189
+ raise StandardError.new("Missing translation: #{resource}") if value.include?(resource)
189
190
  value
190
191
  elsif attribute.blank?
191
192
  resource.model_name.human
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.7
4
+ version: 2.8.9
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: 2023-07-11 00:00:00.000000000 Z
11
+ date: 2023-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails