petities/petitions.eu

View on GitHub
app/views/updates/_form.html.slim

Summary

Maintainability
Test Coverage
- if policy(update).update?
  - if @petition && @petition.status == 'concept'
    - return

  = form_for update, html: { multipart: true } do |f|
    div.petition-edit-label
      = t('update.label.title')

    = f.text_field(:title, class: 'petition-edit-input')

    div.petition-edit-label
      = t('update.label.text')

    = f.text_area(:text, class: 'petition-edit-input')

    - if current_user.has_role? :admin
      div.petition-edit-label
        |  

      = f.label :show_on_home do
        = f.check_box :show_on_home
        = t('update.label.show_on_homepage')

    - if current_user.has_role? :admin or current_user.has_role?(:admin, @office)
      div.petition-edit-label
        |  

      = f.label :show_on_petition do
        = f.check_box :show_on_petition
        = t('update.label.show_on_petition')

    - if @offices
      div.petition-edit-label
        
      = f.label :show_on_office do
        = f.check_box :show_on_office, { checked: false }
        = t('update.label.show_on_office')

      div.petition-edit-label
        = t('update.label.select_office')

      = f.select :office_id, options_from_collection_for_select(@offices, 'id', 'name', 5), class: 'petition-edit-input'

    - if @petition
      = f.hidden_field :petition_id, value: @petition.id

    div.petition-edit-label
      p  
      = f.submit class: 'petition-edit-save'