<div
  id="objective-{{@sessionObjective.id}}"
  class="grid-row objective-row {{if this.showRemoveConfirmation "confirm-removal"}} {{if this.highlightSave.isRunning "highlight-ok"}} {{if this.isManaging "is-managing"}}"
  data-test-session-objective-list-item
  {{did-insert this.load @sessionObjective}}
  {{did-update this.load @sessionObjective}}
>
  <div class="description grid-item" data-test-description>
    {{#if (and @editable (not this.isManaging) (not this.showRemoveConfirmation))}}
      <EditableField
        @value={{@sessionObjective.title}}
        @renderHtml={{true}}
        @isSaveDisabled={{has-error-for this "title"}}
        @save={{perform this.saveTitleChanges}}
        @close={{this.revertTitleChanges}}
      >
        <HtmlEditor @content={{@sessionObjective.title}} @update={{this.changeTitle}} @autofocus={{true}} />
        <ValidationError @errors={{get-errors-for this.title}} />
      </EditableField>
    {{else}}
      {{! template-lint-disable no-triple-curlies }}
      {{{@sessionObjective.title}}}
    {{/if}}
  </div>
  <Session::ObjectiveListItemParents
    @parents={{this.parents}}
    @editable={{and @editable (not this.isManaging) (not this.showRemoveConfirmation)}}
    @manage={{perform this.manageParents}}
    @isManaging={{this.isManagingParents}}
    @save={{perform this.saveParents}}
    @isSaving={{this.saveParents.isRunning}}
    @cancel={{this.cancel}}
  />

  <ObjectiveListItemTerms
      @subject={{@sessionObjective}}
      @editable={{and @editable (not this.isManaging) (not this.showRemoveConfirmation)}}
      @manage={{perform this.manageTerms}}
      @isManaging={{this.isManagingTerms}}
      @save={{perform this.saveTerms}}
      @isSaving={{this.saveTerms.isRunning}}
      @cancel={{this.cancel}}
  />

  <Session::ObjectiveListItemDescriptors
    @meshDescriptors={{this.meshDescriptors}}
    @editable={{and @editable (not this.isManaging) (not this.showRemoveConfirmation)}}
    @manage={{perform this.manageDescriptors}}
    @isManaging={{this.isManagingDescriptors}}
    @save={{perform this.saveDescriptors}}
    @isSaving={{this.saveDescriptors.isRunning}}
    @cancel={{this.cancel}}
  />

  <div class="actions grid-item" data-test-actions>
    {{#if (and @editable (not this.isManaging) (not this.showRemoveConfirmation) (not this.showRemoveConfirmation))}}
      <button
        class="link-button"
        type="button"
        aria-label={{t "general.remove"}}
        {{on "click" (set this.showRemoveConfirmation true)}}
        data-test-remove
      >
        <FaIcon @icon="trash" class="enabled remove" />
      </button>
    {{else}}
      <FaIcon @icon="trash" class="disabled" />
    {{/if}}
  </div>

  {{#if this.showRemoveConfirmation}}
    <div class="confirm-message" data-test-confirm-removal>
      {{t "general.confirmObjectiveRemoval"}}
      <button
        class="remove"
        type="button"
        data-test-confirm
        {{on "click" (perform this.deleteObjective)}}
      >
        {{#if this.deleteObjective.isRunning}}
          <FaIcon @icon="spinner" @spin={{true}} />
        {{else}}
          {{t "general.yes"}}
        {{/if}}
      </button>
      <button
        class="done"
        type="button"
        data-test-cancel
        {{on "click" (set this.showRemoveConfirmation false)}}
      >
        {{t "general.cancel"}}
      </button>
    </div>
  {{/if}}

  {{#if this.isManagingParents}}
    <Session::ManageObjectiveParents
      @courseObjectives={{@courseObjectives}}
      @courseTitle={{@courseTitle}}
      @selected={{this.parentsBuffer}}
      @add={{this.addParentToBuffer}}
      @remove={{this.removeParentFromBuffer}}
    />
  {{/if}}
  {{#if this.isManagingDescriptors}}
    <Session::ManageObjectiveDescriptors
      @selected={{this.descriptorsBuffer}}
      @add={{this.addDescriptorToBuffer}}
      @remove={{this.removeDescriptorFromBuffer}}
      @editable={{@editable}}
      @save={{perform this.saveDescriptors}}
      @cancel={{this.cancel}}
    />
  {{/if}}
  {{#if this.isManagingTerms}}
    <TaxonomyManager
      @vocabularies={{@session.course.assignableVocabularies}}
      @vocabulary={{this.selectedVocabulary}}
      @selectedTerms={{this.termsBuffer}}
      @add={{this.addTermToBuffer}}
      @remove={{this.removeTermFromBuffer}}
      @editable={{@editable}}
      @save={{perform this.saveTerms}}
      @cancel={{this.cancel}}
    />
  {{/if}}
</div>
