Class: Hyrax::Forms::PermissionTemplateForm
- Inherits:
-
Object
- Object
- Hyrax::Forms::PermissionTemplateForm
- Includes:
- HydraEditor::Form
- Defined in:
- app/forms/hyrax/forms/permission_template_form.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Adding attributes hash to state to avoid having to pass it around.
-
#release_embargo ⇒ Object
Selected release embargo timeframe (if any) under release “Varies” option.
-
#release_varies ⇒ Object
Stores which radio button under release “Varies” option is selected.
- #workflow_id ⇒ Object
Instance Method Summary collapse
- #embargo_options ⇒ Object
-
#initialize(model) ⇒ PermissionTemplateForm
constructor
A new instance of PermissionTemplateForm.
-
#remove_access!(permission_template_access) ⇒ Void
This method is used to revoke access to a Collection or Admin Set and its workflows.
-
#reset_access_controls! ⇒ Object
deprecated
Deprecated.
use PermissionTemplate#reset_access_controls_for instead.
-
#source_model ⇒ AdminSet, ::Collection
A bit of an analogue for a ‘belongs_to :source_model` as it crosses from Fedora to the DB.
-
#update(attributes) ⇒ Hash{Symbol => String, Boolean}
{ :content_tab (for confirmation message), :updated (true/false), :error_code (for flash error lookup) }.
-
#update_access(remove_agent: false) ⇒ Object
Copy this access to the permissions of the Admin Set or Collection and to the WorkflowResponsibilities of the active workflow if this is an Admin Set.
- #visibility_options ⇒ Object
Constructor Details
#initialize(model) ⇒ PermissionTemplateForm
Returns a new instance of PermissionTemplateForm.
42 43 44 45 46 |
# File 'app/forms/hyrax/forms/permission_template_form.rb', line 42 def initialize(model) super(model) # Ensure proper form options selected, based on model select_release_varies_option(model) end |
Instance Attribute Details
#attributes ⇒ Object
Adding attributes hash to state to avoid having to pass it around
28 29 30 |
# File 'app/forms/hyrax/forms/permission_template_form.rb', line 28 def attributes @attributes end |
#release_embargo ⇒ Object
Selected release embargo timeframe (if any) under release “Varies” option
22 23 24 |
# File 'app/forms/hyrax/forms/permission_template_form.rb', line 22 def @release_embargo end |
#release_varies ⇒ Object
Stores which radio button under release “Varies” option is selected
20 21 22 |
# File 'app/forms/hyrax/forms/permission_template_form.rb', line 20 def release_varies @release_varies end |
#workflow_id ⇒ Object
30 31 32 |
# File 'app/forms/hyrax/forms/permission_template_form.rb', line 30 def workflow_id @workflow_id || active_workflow.try(:id) end |
Instance Method Details
#embargo_options ⇒ Object
38 39 40 |
# File 'app/forms/hyrax/forms/permission_template_form.rb', line 38 def Widgets::AdminSetEmbargoPeriod.new. end |
#remove_access!(permission_template_access) ⇒ Void
This method is used to revoke access to a Collection or Admin Set and its workflows
79 80 81 82 |
# File 'app/forms/hyrax/forms/permission_template_form.rb', line 79 def remove_access!() construct_attributes_from_template_access!() update_access(remove_agent: true) end |
#reset_access_controls! ⇒ Object
use PermissionTemplate#reset_access_controls_for instead.
14 15 16 17 |
# File 'app/forms/hyrax/forms/permission_template_form.rb', line 14 def reset_access_controls! Deprecation.warn("reset_access_controls! is deprecated; use PermissionTemplate#reset_access_controls_for instead.") source_model.reset_access_controls! end |
#source_model ⇒ AdminSet, ::Collection
This method will eventually be replaced by #source which returns a Hyrax::Resource object. Many methods are equally able to process both Hyrax::Resource and ActiveFedora::Base. Only call this method if you need the ActiveFedora::Base object.
A bit of an analogue for a ‘belongs_to :source_model` as it crosses from Fedora to the DB
92 93 94 |
# File 'app/forms/hyrax/forms/permission_template_form.rb', line 92 def source_model # rubocop:disable Rails/Delegate model.source_model end |
#update(attributes) ⇒ Hash{Symbol => String, Boolean}
Returns { :content_tab (for confirmation message), :updated (true/false),
:error_code (for flash error lookup) }.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/forms/hyrax/forms/permission_template_form.rb', line 51 def update(attributes) @attributes = attributes return_info = { content_tab: tab_to_update } error_code = nil case return_info[:content_tab] when "participants" when "visibility" error_code = when "workflow" grant_workflow_roles end return_info[:error_code] = error_code if error_code return_info[:updated] = error_code ? false : true return_info end |
#update_access(remove_agent: false) ⇒ Object
Copy this access to the permissions of the Admin Set or Collection and to the WorkflowResponsibilities of the active workflow if this is an Admin Set
71 72 73 74 |
# File 'app/forms/hyrax/forms/permission_template_form.rb', line 71 def update_access(remove_agent: false) model.reset_access_controls_for(collection: source) update_workflow_responsibilities(remove_agent: remove_agent) if source.is_a?(Hyrax::AdministrativeSet) end |
#visibility_options ⇒ Object
34 35 36 |
# File 'app/forms/hyrax/forms/permission_template_form.rb', line 34 def Widgets::AdminSetVisibility.new. end |