Chocobozzz/PeerTube

View on GitHub
client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.html

Summary

Maintainability
Test Coverage
<div class="root">
  <div class="header">
    <div class="first-row">
      <div i18n class="title">Save to</div>
    </div>
  </div>

  <div class="input-container">
    <input type="text" placeholder="Search playlists" i18n-placeholder [(ngModel)]="videoPlaylistSearch" (ngModelChange)="onVideoPlaylistSearchChanged()" />
  </div>

  <div class="playlists">
    <div
      *ngFor="let playlist of videoPlaylists"
      class="playlist dropdown-item" [ngClass]="{ 'has-optional-row': playlist.optionalRowDisplayed }"
    >
      <button class="primary-row button-unstyle" (click)="toggleMainPlaylist($event, playlist)">
        <my-peertube-checkbox
          [disabled]="isPresentMultipleTimes(playlist) || playlist.optionalRowDisplayed" [inputName]="getPrimaryInputName(playlist)"
          [ngModel]="isPrimaryCheckboxChecked(playlist)"
        ></my-peertube-checkbox>

        <label [for]="getPrimaryInputName(playlist)" class="display-name">
          {{ playlist.displayName }}
        </label>

        <button
          class="optional-row-icon button-unstyle" [ngClass]="{ 'invisible': !isPrimaryCheckboxChecked(playlist) }"
          (click)="$event.stopPropagation(); toggleOptionalRow(playlist)"
        >
          <my-global-icon iconName="add" aria-hidden="true"></my-global-icon>
        </button>
      </button>

      <div class="optional-rows" *ngIf="playlist.optionalRowDisplayed">
        <div class="header-label" i18n>Start at</div>
        <div class="header-label" i18n>Stop at</div>

        <ng-container *ngFor="let element of buildOptionalRowElements(playlist)">
          <my-peertube-checkbox
            [inputName]="getOptionalInputName(playlist, element)"
            [ngModel]="element.enabled"
            (click)="toggleOptionalPlaylist($event, playlist, element, startAt.timestamp, stopAt.timestamp)"
          ></my-peertube-checkbox>

          <my-timestamp-input
            [maxTimestamp]="video.duration"
            [(ngModel)]="element.startTimestamp"
            (inputBlur)="onElementTimestampUpdate(playlist, element)"
            #startAt
          ></my-timestamp-input>

          <my-timestamp-input
            [maxTimestamp]="video.duration"
            [(ngModel)]="element.stopTimestamp"
            (inputBlur)="onElementTimestampUpdate(playlist, element)"
            #stopAt
          ></my-timestamp-input>
        </ng-container>
      </div>
    </div>
  </div>

  <button class="new-playlist-button dropdown-item" (click)="openCreateBlock($event)" [hidden]="isNewPlaylistBlockOpened">
    <my-global-icon iconName="add" aria-hidden="true"></my-global-icon>

    <span i18n>Create a private playlist</span>
  </button>

  <form class="new-playlist-block dropdown-item" *ngIf="isNewPlaylistBlockOpened" (ngSubmit)="createPlaylist()" [formGroup]="form">
    <div class="form-group">
      <label i18n for="displayName">Display name</label>
      <input
        type="text" id="displayName"
        formControlName="displayName" [ngClass]="{ 'input-error': formErrors['displayName'] }"
      >
      <div *ngIf="formErrors['displayName']" class="form-error" role="alert">
        {{ formErrors['displayName'] }}
      </div>
    </div>

    <input type="submit" i18n-value value="Create" [disabled]="!form.valid">
  </form>
</div>