Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

11.7 KB
Raw Blame
<div class="card document-card-large mb-3 shadow-sm bg-light placeholder-glow fade" [class.show]="show()" [class.card-selected]="selected()" [class.document-card]="selectable" (mouseleave)="mouseLeaveCard()">
  <div class="row g-0">
    <div class="col-md-2 doc-img-container rounded-start" (click)="this.toggleSelected.emit($event)" (dblclick)="dblClickDocument.emit()">
       @if (document()) {
        @if (priority()) {
          <img [ngSrc]="getThumbUrl()" fill priority class="card-img doc-img border-end rounded-start" [class.inverted]="getIsThumbInverted()" alt="{{ document().title | documentTitle }} thumbnail" i18n-alt>
        } @else {
          <img [ngSrc]="getThumbUrl()" fill class="card-img doc-img border-end rounded-start" [class.inverted]="getIsThumbInverted()" alt="{{ document().title | documentTitle }} thumbnail" i18n-alt>
        }

        <div class="border-end border-bottom bg-light document-card-check">
          <div class="form-check">
            <input type="checkbox" class="form-check-input" id="smallCardCheck{{document().id}}" [checked]="selected()" (click)="this.toggleSelected.emit($event)">
            <label class="form-check-label" for="smallCardCheck{{document().id}}"></label>
          </div>
        </div>
      } @else {
        <div class="placeholder bg-secondary w-100 card-img doc-img border-end rounded-start"></div>
      }

    </div>
    <div class="col col-md-10">
      <div class="card-body">
        <div class="d-flex justify-content-between align-items-center">
          <h5 class="card-title w-100">
             @if (document()) {
              @if (displayFields().includes(DisplayField.CORRESPONDENT) && document().correspondent) {
                @if (clickCorrespondent.observers.length ) {
                  <a title="Filter by correspondent" i18n-title (click)="clickCorrespondent.emit(document().correspondent);$event.stopPropagation()" class="fw-bold btn-link">{{document().correspondent | correspondentName | async}}</a>
                } @else {
                  {{document().correspondent | correspondentName | async}}
                }
                @if (displayFields().includes(DisplayField.TITLE)) {:}
              }
              @if (displayFields().includes(DisplayField.TITLE)) {
                {{document().title | documentTitle}}
              }
              @if (displayFields().includes(DisplayField.TAGS)) {
                @for (tagID of document().tags; track tagID) {
                  <pngx-tag [tagID]="tagID" linkTitle="Filter by tag" i18n-linkTitle class="ms-1" (click)="clickTag.emit(tagID);$event.stopPropagation()" [clickable]="clickTag.observers.length"></pngx-tag>
                }
              }
            } @else {
              <div class="placeholder bg-secondary w-75 mb-3">&nbsp;</div>
            }
          </h5>
        </div>
        <p class="card-text">
           @if (document()) {
            @if (hasSearchHighlights) {
              <span [innerHtml]="document().__search_hit__.highlights"></span>
            }
            @for (highlight of searchNoteHighlights; track highlight) {
              <span class="d-block">
                <pngx-bs-icon name="chat-left-text"></pngx-bs-icon>
                <span [innerHtml]="highlight"></span>
              </span>
            }
            @if (shouldShowContentFallback) {
              <span class="result-content">{{contentTrimmed}}</span>
            }
          } @else {
            <div class="placeholder bg-secondary w-100 d-block mb-2"></div>
            <div class="placeholder bg-secondary w-75 d-block mb-2"></div>
            <div class="placeholder bg-secondary w-25 d-block"></div>
          }
        </p>

        <div class="d-flex flex-column flex-md-row align-items-md-center">
          <div class="btn-group">
             @if (document()) {
              <a class="btn btn-sm btn-outline-secondary" (click)="clickMoreLike.emit()">
                <pngx-bs-icon name="diagram-3" class="me-1"></pngx-bs-icon><span class="d-none d-md-inline" i18n>More like this</span>
              </a>
              <a routerLink="/documents/{{document().id}}" class="btn btn-sm btn-outline-secondary">
                <pngx-bs-icon name="file-earmark-richtext" class="me-1"></pngx-bs-icon><span class="d-none d-md-inline" i18n>Open</span>
              </a>
              <pngx-preview-popup [document]="document()" #popupPreview>
                <pngx-bs-icon name="eye" class="me-1"></pngx-bs-icon><span class="d-none d-md-inline" i18n>View</span>
              </pngx-preview-popup>
              <a class="btn btn-sm btn-outline-secondary" [href]="getDownloadUrl()">
                <pngx-bs-icon name="download" class="me-1"></pngx-bs-icon><span class="d-none d-md-inline" i18n>Download</span>
              </a>
            } @else {
              <div class="placeholder btn btn-sm btn-outline-secondary bg-secondary" style="width: 60px;">&nbsp;</div>
              <div class="placeholder btn btn-sm btn-outline-secondary bg-secondary" style="width: 60px;">&nbsp;</div>
              <div class="placeholder btn btn-sm btn-outline-secondary bg-secondary" style="width: 60px;">&nbsp;</div>
              <div class="placeholder btn btn-sm btn-outline-secondary bg-secondary" style="width: 60px;">&nbsp;</div>
            }
          </div>

          <div class="list-group list-group-horizontal border-0 card-info ms-md-auto mt-2 mt-md-0">
             @if (document()) {
              @if (displayFields().includes(DisplayField.NOTES) && notesEnabled && document().notes.length) {
                <button routerLink="/documents/{{document().id}}/notes" class="list-group-item btn btn-sm bg-light text-dark p-1 border-0 me-2 d-flex align-items-center" title="View notes" i18n-title>
                  <pngx-bs-icon width=".9em" height=".9em" class="me-2 text-muted" name="chat-left-text"></pngx-bs-icon><small>{{document().notes.length}} Notes</small>
                </button>
              }
              @if (displayFields().includes(DisplayField.DOCUMENT_TYPE) && document().document_type) {
                <button type="button" class="list-group-item btn btn-sm bg-light text-dark p-1 border-0 me-2 d-flex align-items-center" title="Filter by document type" i18n-title
                  (click)="clickDocumentType.emit(document().document_type);$event.stopPropagation()">
                  <pngx-bs-icon width=".9em" height=".9em" class="me-2 text-muted" name="file-earmark"></pngx-bs-icon><small>{{document().document_type | documentTypeName | async}}</small>
                </button>
              }
              @if (displayFields().includes(DisplayField.STORAGE_PATH) && document().storage_path) {
                <button type="button" class="list-group-item btn btn-sm bg-light text-dark p-1 border-0 me-2 d-flex align-items-center" title="Filter by storage path" i18n-title
                  (click)="clickStoragePath.emit(document().storage_path);$event.stopPropagation()">
                  <pngx-bs-icon width=".9em" height=".9em" class="me-2 text-muted" name="archive"></pngx-bs-icon><small>{{document().storage_path | storagePathName | async}}</small>
                </button>
              }
              @if (displayFields().includes(DisplayField.ASN) && document().archive_serial_number | isNumber) {
                <div class="list-group-item me-2 bg-light text-dark p-1 border-0 d-flex align-items-center">
                  <pngx-bs-icon width=".9em" height=".9em" class="me-2 text-muted" name="upc-scan"></pngx-bs-icon><small>#{{document().archive_serial_number}}</small>
                </div>
              }
              @if (displayFields().includes(DisplayField.CREATED) || displayFields().includes(DisplayField.ADDED)) {
                <ng-template #dateTooltip>
                  <div class="d-flex flex-column text-light">
                    <span i18n>Created: {{ document().created | customDate }}</span>
                    <span i18n>Added: {{ document().added | customDate }}</span>
                    <span i18n>Modified: {{ document().modified | customDate }}</span>
                  </div>
                </ng-template>
                @if (displayFields().includes(DisplayField.CREATED)) {
                  <div class="list-group-item bg-light text-dark p-1 border-0 d-flex align-items-center" [ngbTooltip]="dateTooltip">
                    <pngx-bs-icon width=".9em" height=".9em" class="me-2 text-muted" name="calendar-event"></pngx-bs-icon><small>{{document().created | customDate:'mediumDate'}}</small>
                  </div>
                }
                @if (displayFields().includes(DisplayField.ADDED)) {
                  <div class="list-group-item bg-light text-dark p-1 border-0 d-flex align-items-center" [ngbTooltip]="dateTooltip">
                    <pngx-bs-icon width=".9em" height=".9em" class="me-2 text-muted" name="calendar-event"></pngx-bs-icon><small>{{document().added | customDate:'mediumDate'}}</small>
                  </div>
                }
              }
              @if (displayFields().includes(DisplayField.PAGE_COUNT) && document().page_count) {
                <div class="list-group-item bg-light text-dark p-1 border-0 d-flex align-items-center">
                  <pngx-bs-icon width=".9em" height=".9em" class="me-2 text-muted" name="files"></pngx-bs-icon>
                  <small i18n>{document().page_count, plural, =1 {1 page} other {{{document().page_count}} pages}}</small>
                </div>
              }
              @if (displayFields().includes(DisplayField.OWNER) && document().owner && document().owner !== settingsService.currentUser().id) {
                <div class="list-group-item bg-light text-dark p-1 border-0 d-flex align-items-center">
                  <pngx-bs-icon width=".9em" height=".9em" class="me-2 text-muted" name="person-fill-lock"></pngx-bs-icon><small>{{document().owner | username | async}}</small>
                </div>
              }
              @if (displayFields().includes(DisplayField.SHARED) && document().is_shared_by_requester) {
                <div class="list-group-item bg-light text-dark p-1 border-0 d-flex align-items-center">
                  <pngx-bs-icon width=".9em" height=".9em" class="me-2 text-muted" name="people-fill"></pngx-bs-icon><small i18n>Shared</small>
                </div>
              }
              @if (document().__search_hit__?.score) {
                <div class="list-group-item bg-light text-dark border-0 d-flex p-0 ps-4 search-score">
                  <small class="me-2 text-muted" i18n>Score:</small>
                  <ngb-progressbar [type]="searchScoreClass" [value]="document().__search_hit__.score" class="search-score-bar mx-2 mt-1" [max]="1"></ngb-progressbar>
                </div>
              }
              @for (field of document().custom_fields; track field.field) {
                @if (displayFields().includes(DisplayField.CUSTOM_FIELD + field.field)) {
                  <div class="list-group-item bg-light text-dark p-1 border-0 d-flex align-items-center">
                    <pngx-bs-icon width=".9em" height=".9em" class="me-2 text-muted" name="ui-radios"></pngx-bs-icon>
                    <small>
                      <pngx-custom-field-display [document]="document()" [fieldId]="field.field" showNameIfEmpty="true"></pngx-custom-field-display>
                    </small>
                  </div>
                }
              }
            } @else {
              <div class="placeholder list-group-item bg-secondary w-25">&nbsp;</div>
              <div class="placeholder list-group-item bg-secondary w-25">&nbsp;</div>
              <div class="placeholder list-group-item bg-secondary w-25">&nbsp;</div>
              <div class="placeholder list-group-item bg-secondary w-25">&nbsp;</div>
              <div class="placeholder list-group-item bg-secondary w-25">&nbsp;</div>
            }
          </div>
        </div>
      </div>
    </div>
  </div>
</div>