petities/petitions.eu

View on GitHub
app/views/petitions/edit.html.slim

Summary

Maintainability
Test Coverage
- title @petition.name

div.page

  div.center
    div.petition-edit-button
      = link_to(t('edit.petition.sign_page'), petition_path(@petition))
    div.whitespace
    div.petition-edit-button onclick=="$('.petition-intro-container.edit').show(); $('#introContainer').hide();"
     = t('edit.petition.edit_text')

  - if @petition_flash.present?
    section.petition-intro-container
      div
        h2.petition-section-title
          = @petition_flash

div.page

  section class=(@petition.image ? 'petition-intro-container' : 'petition-intro-container-noimage') id="introContainer"
    div.petition-intro-image-container
      = image_tag( @petition.image.upload.url(:listing), class: 'petition-intro-image') if @petition.image
    div.petition-intro-info-container
      h1.petition-intro-info-title= @petition.name
      div.petition-intro-info-counter
        - if @petition.get_count > 0 || @petition.is_live?
          = t('show.signatures_count', display: number_with_delimiter(@petition.get_count), count: @petition.get_count)
        - else
          = t("show.overview.status.#{@petition.state_summary}")
      div.petition-intro-info-text
        p= markdown @petition.description

    - if @petition.versions.size > 1

      div class="petition-editbutton-container"

          h2
          - if @petition.paper_trail.next_version
            div.petition-editbutton.pull-left
              =<> link_to t('edit.petition.newer_version'), edit_petition_path(@petition, ({version: @petition.paper_trail.next_version.version.index} if @petition.paper_trail.next_version.version))

          - if @petition.paper_trail.previous_version
            div.petition-editbutton.pull-right
              =<> link_to t('edit.petition.older_version'), edit_petition_path(@petition, {version: @petition.paper_trail.previous_version.version.index})

  section class="petition-intro-container edit"
    div.petition-edit-close-button onclick=="$(this).parent('.edit').hide(); $('#introContainer').show();"

    = render 'form'

  section.petition-container id="petitionState"
    div.petition-text-wrapper
      h2.petition-section-title= t('show.petition.title')
      div.petition-text
        h3= t('show.petition.we')
        = markdown @petition.initiators
        p &nbsp;

        h3= t('show.petition.observe')
        = markdown @petition.statement
        p &nbsp;

        h3= t('show.petition.request')
        = markdown @petition.request

    javascript:
      var petition_state_summary = '#{@petition.state_summary}' || 'draft';

    div.petition-form-wrapper
      div.petition-form-indication-wrapper
        h2 class="petition-section-title"
          = t "petition.current_state_is"
        div.petition-state-container
          div id="draft" class="petition-state-label"
            = t "petition.state.not_yet_finished"
          div id="signable" class="petition-state-label"
              = t "petition.signable"
          div id="closed" class="petition-state-label"
            = t "petition.closed"
          div id="in_treatment" class="petition-state-label"
            = t "petition.in_treatment"
          div id="completed" class="petition-state-label"
            = t "petition.states.completed"

        h2 class="petition-section-title"
        p
          = t('edit.petition.status.explanation')

  section.petition-container id="petitionStateEdit" style="display: none"
    div.petition-text-wrapper
      h2.petition-section-title= t('show.petition.title')
      div.petition-text
        h3= t('show.petition.we')
        p= @petition.initiators
        p &nbsp;

        h3= t('show.petition.observe')
        p= @petition.statement
        p &nbsp;

        h3= t('show.petition.request')
        p= @petition.request

    div.petition-form-wrapper
      div onclick=="$('#petitionState').css('display','flex'); $('#petitionStateEdit').hide();" class="petition-edit-close-button"
      div class="petition-form-indication-wrapper"
        h2 class="petition-section-title"
          = t 'petition.current_state_is'
        div.whitespace

- unless @petition.concept?
  div.center
    div.petition-edit-button
      = link_to(t('edit.petition.write_news'), '#petitionnews')
  div.whitespace

- if policy(@petition).finalize?
  div.center
    = button_to(t('start.form.finalize'), petition_finalize_path(@petition), class: 'petition-edit-button')

  div.whitespace

- if policy(@petition).release?
  div.center
    = button_to(t('start.form.release'), petition_release_path(@petition), class: 'petition-edit-button')

  div.whitespace

  /<!-- /editbutton -->
div.page
  section.petition-details-container

    div#petition_details.petition_details
    = render partial: 'detailbox'

    = render partial: 'petitioner'

    = render partial: 'edit_details'

    = render partial: 'edit_details_docs'

  /<!-- editbutton -->
  javascript:
    var showEdit = function(){
      $('#detailbox').hide();
      $('.petitioner-details').hide();
      $('#edit_details').show();
      $('#edit_details_docs').show();
      $('#edit_detail_button').hide();

    };
    var showDetails = function(){
      $('#edit_details').hide();
      $('#edit_details_docs').hide();
      $('#detailbox').show();
      $('.petitioner-details').show();
      $('#edit_detail_button').show();
    };

  div.whitespace

  div.center
    div.petition-edit-button#edit_detail_button onclick=="showEdit()"
      = t 'edit.petition.edit_details_button'

- unless @petition.concept?

  = render partial: 'petition_updates'