Sha256: 3fda5ac6f05964fa8264feb4d5929a6d6c30d10c2ab7d73bec51ac0d3d8ee815

Contents?: true

Size: 1.44 KB

Versions: 3

Compression:

Stored size: 1.44 KB

Contents

module Sufia::Forms
  class WorkForm < CurationConcerns::Forms::WorkForm
    delegate :depositor, :on_behalf_of, :permissions, to: :model
    include HydraEditor::Form::Permissions

    # TODO: remove this when https://github.com/projecthydra/hydra-editor/pull/115
    # is merged and hydra-editor 3.0.0 is released
    delegate :model_name, to: :model

    attr_reader :agreement_accepted

    self.terms += [:collection_ids]
    self.required_fields = [:title, :creator, :keyword, :rights]

    def initialize(model, current_ability)
      @agreement_accepted = !model.new_record?
      super
    end

    def [](key)
      return model.in_collection_ids if key == :collection_ids
      super
    end

    # Fields that are automatically drawn on the page above the fold
    def primary_terms
      required_fields
    end

    # Fields that are automatically drawn on the page below the fold
    def secondary_terms
      terms - primary_terms -
        [:files, :visibility_during_embargo, :embargo_release_date,
         :visibility_after_embargo, :visibility_during_lease,
         :lease_expiration_date, :visibility_after_lease, :visibility,
         :thumbnail_id, :representative_id, :ordered_member_ids,
         :collection_ids]
    end

    def self.multiple?(term)
      return true if [:rights, :collection_ids].include? term
      super
    end

    def self.build_permitted_params
      super + [:on_behalf_of, { collection_ids: [] }]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sufia-7.0.0 app/forms/sufia/forms/work_form.rb
sufia-7.0.0.rc2 app/forms/sufia/forms/work_form.rb
sufia-7.0.0.rc1 app/forms/sufia/forms/work_form.rb