af83/chouette-core

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

Summary

Maintainability
Test Coverage
= simple_form_for [@workbench, @notification_rule], html: {class: 'form-horizontal', id: 'notification_rule_form'}, wrapper: :horizontal_form do |f|
  .row
    .col-lg-12
      = f.input :notification_type, include_blank: false
      = f.input :priority, type: :integer

      .form-group
        = f.label NotificationRule.tmf(:rule_type), class: 'col-sm-4 col-xs-5 control-label'
        = f.input :rule_type, as: :radio_buttons, label: false, wrapper_html: { class: 'date smart_date col-sm-8 col-xs-7', style: 'margin-right: 0px; margin-left: 0px' }

      div[x-data="{ targetType: '#{@notification_rule.target_type}' }"]
        .form-group
          = f.label NotificationRule.tmf(:target_type), class: 'col-sm-4 col-xs-5 control-label'
          = f.input :target_type,
            as: :radio_buttons,
            label: false,
            input_html: { 'x-model': 'targetType' },
            wrapper_html: { class: 'date smart_date col-sm-8 col-xs-7', style: 'margin-right: 0px; margin-left: 0px' }

        div
          template[x-if="targetType =='user'"]

            = f.input :users,
              as: :tom_select,
              collection: @notification_rule.user_items,
              selected: @notification_rule.user_ids,
              required: true,
              input_html: { multiple: true, ':disabled': "targetType != 'user'" },
              config: { type: 'ajax', url: users_workbench_autocomplete_index_path(@workbench), plugins: ['remove_button', 'clear_button'] }

          template[x-if="targetType =='external_email'"]
            = f.input :external_email,
              required: true,
              input_html: { ':disabled': "targetType != 'external_email'" }

  h3 = 'Conditions'
  .separator
    .form-group
      = render 'period_fields', form: f

    = f.input :operation_statuses,
      as: :tom_select,
      collection: operation_statuses_options,
      config: { hidePlaceholder: true }

    = render 'line_ids_field', form: f

    = cancel_button
    = f.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'notification_rule_form'