af83/chouette-core

View on GitHub
app/views/workgroups/edit_aggregate.html.slim

Summary

Maintainability
Test Coverage
- breadcrumb :workgroup_aggregation_settings, resource
- page_header_content_for resource
- workbenches = resource.workbenches.joins(:organisation).order('organisations.name')

.page_content
  .container
    = simple_form_for resource, html: { class: 'form-horizontal', id: 'workgroup_form' }, wrapper: :horizontal_form do |f|
      .row
        .col-lg-12
          h3= I18n.t('workgroups.edit_aggregate.nightly_aggregate')

      .row x-data="{ nightlyAggregateEnabled: #{resource.nightly_aggregate_enabled} || false}"
        .col-lg-12
          = f.input :nightly_aggregate_enabled, as: :switchable_checkbox, input_html: { 'x-on:click': 'nightlyAggregateEnabled = !nightlyAggregateEnabled' }
        .col-lg-12 x-show="nightlyAggregateEnabled"
          = f.input :nightly_aggregate_time, as: :time_picker
          = f.input :nightly_aggregate_days, as: :day_type
          = f.input :nightly_aggregate_notification_target,
            collection: Aggregate.notification_target.values.delete_if{|value| value == "user"}.map { |k| [k && "enumerize.notification_target.#{k}".t, k] },
            selected: f.object.nightly_aggregate_notification_target,
            input_html: { style: 'max-width: 350px;' }
      .row
        .col-lg-12= I18n.t('workgroups.edit_aggregate.disclaimer').html_safe

      .row
        .col-lg-12
          .edit_table
            .col.first
              - workbenches.each_with_index do |w,i|
                .cell.organisation-name = w.name
            .col.small
              - workbenches.each_with_index do |w,i|
               .cell
                 - if w.locked_referential_to_aggregate.present?
                   span.fa.fa-lock
            .col
              - workbenches.each_with_index do |w,i|
                .cell
                  = hidden_field_tag "workgroup[workbenches_attributes][#{i}][id]", w.id
                  = select_tag "workgroup[workbenches_attributes][#{i}][locked_referential_to_aggregate_id]", options_from_collection_for_select(w.output.referentials_created_before_current, :id, :name, w.locked_referential_to_aggregate_id), include_blank: true, data: { select2ed: true, 'select2ed-allow-clear' => true, 'select2ed-placeholder' => I18n.t('workbenches.current_offer') }, class: 'w-full'
            .col.medium
              - workbenches.each_with_index do |w,i|
               .cell.organisation-name
                = Workbench.tmf(:priority)
            .col.big
              - workbenches.each_with_index do |w,i|
                  .cell
                    = select_tag "workgroup[workbenches_attributes][#{i}][priority]", options_for_select(1..10, w.priority), input_html: { style: 'max-width: 100px;' }
          = cancel_button
          = f.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'workgroup_form'