<div class="container">
  <div class="row">
    <div class="col-12">
      <h2>{{'collection.edit.item-mapper.head' | translate}}</h2>
      <p [innerHTML]="'collection.edit.item-mapper.collection' | translate:{ name: (collectionRD$ | async)?.payload?.name }" id="collection-name"></p>
      <p>{{'collection.edit.item-mapper.description' | translate}}</p>

      <ngb-tabset (tabChange)="tabChange($event)" [destroyOnHide]="true" #tabs="ngbTabset">
        <ngb-tab title="{{'collection.edit.item-mapper.tabs.browse' | translate}}" id="browseTab">
          <ng-template ngbTabContent>
            <div class="mt-2">
              <ds-item-select class="mt-2"
                [key]="'browse'"
                [dsoRD$]="collectionItemsRD$"
                [paginationOptions]="(searchOptions$ | async)?.pagination"
                [confirmButton]="'collection.edit.item-mapper.remove'"
                [cancelButton]="'collection.edit.item-mapper.cancel'"
                [dangerConfirm]="true"
                [hideCollection]="true"
                (confirm)="mapItems($event, true)"
                (cancel)="onCancel()"></ds-item-select>
            </div>
          </ng-template>
        </ngb-tab>
        <ngb-tab title="{{'collection.edit.item-mapper.tabs.map' | translate}}" id="mapTab">
          <ng-template ngbTabContent>
            <div class="row mt-2">
              <div class="col-12 col-lg-6">
                <ds-search-form id="search-form"
                                [query]="(searchOptions$ | async)?.query"
                                [scope]="(searchOptions$ | async)?.scope"
                                [currentUrl]="'./'"
                                [inPlaceSearch]="true"
                                (submitSearch)="performedSearch = true">
                </ds-search-form>
              </div>
            </div>

            <div *ngIf="performedSearch">
              <ds-item-select class="mt-2"
                [key]="'map'"
                [dsoRD$]="mappedItemsRD$"
                [paginationOptions]="(searchOptions$ | async)?.pagination"
                [confirmButton]="'collection.edit.item-mapper.confirm'"
                [cancelButton]="'collection.edit.item-mapper.cancel'"
                (confirm)="mapItems($event)"
                (cancel)="onCancel()"></ds-item-select>
            </div>
            <div *ngIf="!performedSearch" class="alert alert-info w-100" role="alert">
              {{'collection.edit.item-mapper.no-search' | translate}}
            </div>
          </ng-template>
        </ngb-tab>
      </ngb-tabset>
    </div>
  </div>
</div>
