Module: RecordsHelperBehavior

Included in:
RecordsHelper
Defined in:
app/helpers/concerns/records_helper_behavior.rb

Instance Method Summary collapse

Instance Method Details

#edit_record_titleObject



28
29
30
# File 'app/helpers/concerns/records_helper_behavior.rb', line 28

def edit_record_title
  I18n.t('hydra_editor.edit.title') % render_record_title
end

#model_label(key) ⇒ Object



2
3
4
# File 'app/helpers/concerns/records_helper_behavior.rb', line 2

def model_label(key)
  I18n.t("hydra_editor.form.model_label.#{key}", default: key.to_s.humanize)
end

#new_record_titleObject



24
25
26
# File 'app/helpers/concerns/records_helper_behavior.rb', line 24

def new_record_title
  I18n.t('hydra_editor.new.title') % model_label(params[:type])
end

#object_type_optionsObject



6
7
8
9
10
11
12
# File 'app/helpers/concerns/records_helper_behavior.rb', line 6

def object_type_options
  @object_type_options ||= HydraEditor.models.inject({}) do |h, model|
    label = model_label(model)
    h["#{label[0].upcase}#{label[1..-1]}"] = model
    h
  end
end

#record_form_action_url(record) ⇒ Object



19
20
21
22
# File 'app/helpers/concerns/records_helper_behavior.rb', line 19

def record_form_action_url(record)
  router = respond_to?(:hydra_editor) ? hydra_editor.routes.url_helpers : self
  record.persisted? ? router.record_path(record) : router.records_path
end

#render_edit_field_partial(field_name, locals) ⇒ Object



14
15
16
17
# File 'app/helpers/concerns/records_helper_behavior.rb', line 14

def render_edit_field_partial(field_name, locals)
  collection = locals[:f].object.model_name.collection
  render_edit_field_partial_with_action(collection, field_name, locals)
end

#render_record_titleObject



32
33
34
# File 'app/helpers/concerns/records_helper_behavior.rb', line 32

def render_record_title
  Array(form.title).first
end