/.form-row
  .form-label= t 'attributes.workflow_group.name'
  .form-field= input value=model.name enter="saveRecord"
  /.small-12.medium-9.columns= input value=model.name
/.form-row
  .form-label= t 'attributes.workflow_group.offset_value'
  .form-field
    .ui.right.labeled.action.input
      = number-input numericValue=model.offset_value step=1
      /button.ui.grey.icon.button{action (mut model.offset_value)}: i.remove.icon
      .ui.label days
/.form-row
  .form-label= t 'attributes.workflow_group.duration_value'
  .form-field
    .ui.right.labeled.action.input
      = number-input numericValue=model.duration_value step=1
      /button.ui.grey.icon.button{action (mut model.duration_value)}: i.remove.icon
      .ui.label days
table.ui.definition.table
  tr
    td= t 'attributes.workflow_group.name'
    td= input value=model.name enter="saveRecord"
  tr
    td= t 'attributes.workflow_group.offset_type'
    td
      .ui.buttons
        .ui.button class=offset_type_none:active click="'set_offset_type' 'none'"
          = t 'workflow_group.offset_type.none.label'
        .or
        .ui.button class=offset_type_connected_finish:active click="'set_offset_type' 'connected_finish'"
          = t 'workflow_group.offset_type.connected_finish.label'
        /.or
        /.ui.button class=offset_type_reference_date:active click="'set_offset_type' 'reference_date'"
          = t 'workflow_group.offset_type.reference_date.label'
        .or
        .ui.button class=offset_type_connected_start:active click="'set_offset_type' 'connected_start'"
          = t 'workflow_group.offset_type.connected_start.label'
      /.inline.fields
        .field: .ui.radio.checkbox
          ui-checkbox checked=offset_type_none onChange=(action 'set_offset_type' 'none') label=(t 'workflow_group.offset_type.none.label')
        .field: .ui.radio.checkbox
          ui-checkbox checked=offset_type_connected_finish onChange=(action 'set_offset_type' 'connected_finish') label=(t 'workflow_group.offset_type.connected_finish.label')
        .field: .ui.radio.checkbox
          ui-checkbox checked=offset_type_reference_date onChange=(action 'set_offset_type' 'reference_date') label=(t 'workflow_group.offset_type.reference_date.label')
        .field: .ui.radio.checkbox
          ui-checkbox checked=offset_type_connected_start onChange=(action 'set_offset_type' 'connected_start') label=(t 'workflow_group.offset_type.connected_start.label')
  unless offset_type_none
    tr
      td
        = t model.offset_type scope='workflow_group.offset_type' suffix='offset_value_label'
        /= t 'attributes.workflow_group.offset_value'
      td
        .ui.right.labeled.action.input
          = number-input numericValue=model.offset_value step=1
          /button.ui.grey.icon.button{action (mut model.offset_value)}: i.remove.icon
          .ui.label= t model.duration_unit scope='date.unit.plural'
    tr
      td
        = t model.offset_type scope='workflow_group.offset_type' suffix='offset_base_label'
        /= t 'attributes.workflow_group.offset_base'
      td
        x-select value=model.offset_base.content on-change=(action (mut model.offset_base)) as |xs|
          option X
          each offset_selectable_workflow_groups as |workflow_group|
            unless (eq workflow_group.id model.id)
              xs.option value=workflow_group
                span= t model.offset_type scope='workflow_group.offset_type' suffix='offset_base_prefix'
                span= workflow_group.name
    tr
      td= t 'attributes.workflow_group.duration_value'
      td
        .ui.right.labeled.action.input
          = number-input numericValue=model.duration_value step=1
          /button.ui.grey.icon.button{action (mut model.duration_value)}: i.remove.icon
          .ui.label= t model.duration_unit scope='date.unit.plural'
    if model.project.instance_scope_batch
      tr
        td= t 'attributes.workflow_group.batch_element_threshold_value'
        td
          .ui.right.labeled.action.input
            = number-input numericValue=model.batch_element_threshold_value step=1
            if model.batch_element_threshold_value
              button.ui.grey.icon.button{action (mut model.batch_element_threshold_value)}: i.remove.icon
            /.ui.basic.dropdown.button
            = ui-dropdown class='selection' selected=model.batch_element_threshold_unit onChange=(action 'set_batch_element_threshold_unit')
              /.default.text= t model.batch_element_threshold_unit scope='date.unit.plural' bare=true
              .text
              i.dropdown.icon
              .menu
                each globals.workflow_group.batch_element_threshold_unit_options as |batch_element_threshold_unit|
                  .item data-value=batch_element_threshold_unit
                    span per 
                    = t batch_element_threshold_unit scope='date.unit'
            /.ui.label
              /= t model.batch_element_threshold_unit scope='date.unit.plural'
          /x-select value=model.batch_element_threshold_unit on-change=(action (mut model.batch_element_threshold_unit)) as |xs|
            each globals.workflow_group.batch_element_threshold_unit_options as |batch_element_threshold_unit|
              xs.option value=batch_element_threshold_unit
                = t batch_element_threshold_unit scope='date.unit.plural'
unless model.isNew
  each organization_tracker_subjects as |tracker_subject|
    .form-row
      .form-label= tracker_subject.model.name
      .form-field
        x-select value=tracker_subject.current_tracker_group on-change=(action (mut tracker_subject.current_tracker_group)) as |xs|
          option --
          each tracker_subject.model.tracker_groups as |tracker_group|
            xs.option value=tracker_group
              = tracker_group.name
  /h3
    = push-action type="new" action="newConstraint" class="right"
    = t 'models.plural.workflow_group_constraint'
  /.clearfix
  /each model.constraints as |constraint|
    workflow-group-edit-constraint constraint=constraint constraint_workflow_groups=constraint_workflow_groups

.modal-actions.sticky
  button.ui.primary.button.modal-save.pull-right{ action "saveRecord"}= t 'general.save'
  unless model.isNew
    button.ui.negative.button.modal-destroy.pull-right{ action "destroyRecord"}= t 'general.destroy.button'
  button.ui.basic.button.modal-rollback{ action "rollback_and_close"}= t 'general.rollback'
