.time-tracker-control
  - unless @time_tracker.persisted?
    h3 = t('hourglass.ui.index.time_tracker_control.heading')
    = form_for @time_tracker, url: start_hourglass_time_trackers_path, as: 'time_tracker', remote: true, html: {class: 'new-time-tracker-form js-hourglass-remote'} do |f|
      .form-row
        .form-field
          = text_field_tag :time_tracker_task, nil, size: '30', maxlength: 1024, disabled: !policy(@time_tracker).change?, class: ('js-issue-autocompletion' if policy(Hourglass::TimeLog).book?)
          = f.hidden_field :issue_id if policy(Hourglass::TimeLog).book?
          = f.hidden_field :comments
        .form-field
          = f.submit t('hourglass.ui.index.time_tracker_control.button_start')
  - else
    h3 = t('hourglass.ui.index.time_tracker_control.tracking_heading')
    = form_for @time_tracker, url: stop_hourglass_time_tracker_path(@time_tracker), method: :delete, as: 'time_tracker', remote: true, html: {class: 'edit-time-tracker-form js-validate-form js-hourglass-remote'} do |f|
      .form-row
        = form_field :issue, f, @time_tracker, disabled: !policy(Hourglass::TimeLog).book?, with_link: true
        = form_field :comments, f, @time_tracker

        - rounding_disabled = !@time_tracker.project || Hourglass::SettingsStorage[:round_sums_only, project: @time_tracker.project]
        .form-field class=('hidden' if rounding_disabled)
          .label
            = f.label :round
          .input
            = f.check_box :round, disabled: rounding_disabled
        .form-field
          .label
            = t('hourglass.ui.index.time_tracker_control.label_running_time')
          .input.js-running-time
      .form-row
        = form_field :project, f, @time_tracker, disabled: !policy(Hourglass::TimeLog).book?, with_link: true
        = form_field :activity, f, @time_tracker, disabled: !policy(Hourglass::TimeLog).book?
        = form_field :start, f, @time_tracker, disabled: !policy(@time_tracker).change?(:start)
        .form-field
          .input
            = f.submit t('hourglass.ui.index.time_tracker_control.button_stop'), data: @time_tracker.clamp? ? {confirm: t('hourglass.ui.forms.confirmations.stop_clamping', 'duration': localized_hours_in_units(Hourglass::DateTimeCalculations.in_hours(Hourglass::DateTimeCalculations.clamp_limit(project: @time_tracker.project))))} : {}
            = f.submit t('hourglass.ui.index.time_tracker_control.button_stop_new'), class: 'js-stop-new', data: @time_tracker.clamp? ? {confirm: t('hourglass.ui.forms.confirmations.stop_clamping', 'duration': localized_hours_in_units(Hourglass::DateTimeCalculations.in_hours(Hourglass::DateTimeCalculations.clamp_limit(project: @time_tracker.project))))} : {}
            - if policy(@time_tracker).destroy?
              = link_to '', hourglass_time_tracker_path(@time_tracker), class: 'icon icon-del js-hourglass-remote', title: t(:button_delete), remote: true, method: :delete, data: {confirm: t(:text_are_you_sure)}
      .form-row
        - @time_tracker.custom_field_values.each do |value|
          .form-field = custom_field_tag_with_label :'time_tracker', value
