Class: Ez::Resources::FormCell

Inherits:
ApplicationCell show all
Defined in:
app/cells/ez/resources/form_cell.rb

Constant Summary

Constants inherited from ApplicationCell

ApplicationCell::CSS_SCOPE

Instance Method Summary collapse

Methods inherited from ApplicationCell

#css_for, #custom_css_map, #div_for, form, #t

Instance Method Details

#form_header_labelObject



8
9
10
11
12
13
14
# File 'app/cells/ez/resources/form_cell.rb', line 8

def form_header_label
  if model.data.new_record?
    "#{t('actions.new')} #{model.resource_name.downcase}"
  else
    "#{t('actions.edit')} #{model.data.public_send(model.resource_label)} #{model.resource_name.downcase}"
  end
end

#readonly?Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
# File 'app/cells/ez/resources/form_cell.rb', line 16

def readonly?
  @readonly ||= if model.data.new_record?
                  !Ez::Resources::Manager::Hooks.can?(:can_create?, model, model.data)
                else
                  !Ez::Resources::Manager::Hooks.can?(:can_update?, model, model.data)
                end
end

#submit_button_textObject



24
25
26
27
28
29
30
# File 'app/cells/ez/resources/form_cell.rb', line 24

def submit_button_text
  if model.data.new_record?
    t('actions.create')
  else
    t('actions.update')
  end
end