Slightly better embedded doc link element

This commit is contained in:
shamoon 2024-09-08 17:46:24 -07:00
parent 8e5cc66dae
commit b3c60b383b
4 changed files with 74 additions and 49 deletions

View File

@ -79,8 +79,7 @@
<ng-container *ngTemplateOutlet="comparisonValueTemplate; context: { atom: atom }"></ng-container> <ng-container *ngTemplateOutlet="comparisonValueTemplate; context: { atom: atom }"></ng-container>
} }
@case (CustomFieldQueryOperator.Contains) { @case (CustomFieldQueryOperator.Contains) {
<!-- TODO: needs visual work --> <pngx-input-document-link [(ngModel)]="atom.value" class="w-25 form-select doc-link-select" placeholder="Search docs" [minimal]="true"></pngx-input-document-link>
<pngx-input-document-link [(ngModel)]="atom.value" [horizontal]="true"></pngx-input-document-link>
} }
@default { @default {
<input class="w-25 form-control rounded-end" type="text" [(ngModel)]="atom.value" [disabled]="disabled"> <input class="w-25 form-control rounded-end" type="text" [(ngModel)]="atom.value" [disabled]="disabled">

View File

@ -15,3 +15,18 @@
min-width: 35%; min-width: 35%;
font-size: 14px; font-size: 14px;
} }
::ng-deep .doc-link-select {
padding-top: 0 !important;
border-top-right-radius: var(--bs-border-radius) !important;
border-bottom-right-radius: var(--bs-border-radius) !important;
.ng-select-container {
border: none !important;
min-height: auto !important;
}
.ng-select {
max-width: 200px;
min-width: 140px;
}
}

View File

@ -1,50 +1,58 @@
<div class="mb-3 paperless-input-select" [class.disabled]="disabled"> @if (minimal) {
<div class="row"> <ng-container *ngTemplateOutlet="select"></ng-container>
<div class="d-flex align-items-center position-relative hidden-button-container" [class.col-md-3]="horizontal"> } @else {
@if (title) { <div class="mb-3 paperless-input-select" [class.disabled]="disabled">
<label class="form-label" [class.mb-md-0]="horizontal" [for]="inputId">{{title}}</label> <div class="row">
} <div class="d-flex align-items-center position-relative hidden-button-container" [class.col-md-3]="horizontal">
@if (removable) { @if (title) {
<button type="button" class="btn btn-sm btn-danger position-absolute left-0" (click)="removed.emit(this)"> <label class="form-label" [class.mb-md-0]="horizontal" [for]="inputId">{{title}}</label>
<i-bs name="x"></i-bs>&nbsp;<ng-container i18n>Remove</ng-container> }
</button> @if (removable) {
} <button type="button" class="btn btn-sm btn-danger position-absolute left-0" (click)="removed.emit(this)">
</div> <i-bs name="x"></i-bs>&nbsp;<ng-container i18n>Remove</ng-container>
<div [class.col-md-9]="horizontal"> </button>
<div> }
<ng-select name="inputId" [(ngModel)]="selectedDocuments" </div>
[disabled]="disabled" <div [class.col-md-9]="horizontal">
[items]="foundDocuments$ | async" <ng-container *ngTemplateOutlet="select"></ng-container>
placeholder="Search for documents" @if (hint) {
[notFoundText]="notFoundText" <small class="form-text text-muted">{{hint}}</small>
[multiple]="true" }
bindValue="id"
[compareWith]="compareDocuments"
[trackByFn]="trackByFn"
[minTermLength]="2"
[loading]="loading"
[typeahead]="documentsInput$"
(change)="onChange(selectedDocuments)">
<ng-template ng-label-tmp let-document="item">
<div class="d-flex align-items-center">
<button class="btn p-0 lh-1" (click)="unselect(document)" title="Remove link" i18n-title><i-bs name="x"></i-bs></button>
<a routerLink="/documents/{{document.id}}" class="badge bg-light text-primary" (mousedown)="$event.stopImmediatePropagation();" title="Open link" i18n-title>
<i-bs width="0.9em" height="0.9em" name="file-text"></i-bs>&nbsp;<span>{{document.title}}</span>
</a>
</div>
</ng-template>
<ng-template ng-loadingspinner-tmp>
<div class="spinner-border spinner-border-sm fw-normal ms-2 me-auto" role="status"></div>
<div class="visually-hidden" i18n>Loading...</div>
</ng-template>
<ng-template ng-option-tmp let-document="item" let-index="index" let-search="searchTerm">
<div>{{document.title}} <small class="text-muted">({{document.created | customDate:'shortDate'}})</small></div>
</ng-template>
</ng-select>
</div> </div>
@if (hint) {
<small class="form-text text-muted">{{hint}}</small>
}
</div> </div>
</div> </div>
</div> }
<ng-template #select>
<div class="doc-link-select">
<ng-select name="inputId" [(ngModel)]="selectedDocuments"
[disabled]="disabled"
[items]="foundDocuments$ | async"
placeholder="Search for documents"
[notFoundText]="notFoundText"
[multiple]="true"
bindValue="id"
[compareWith]="compareDocuments"
[trackByFn]="trackByFn"
[minTermLength]="2"
[loading]="loading"
[typeahead]="documentsInput$"
(change)="onChange(selectedDocuments)">
<ng-template ng-label-tmp let-document="item">
<div class="d-flex align-items-center">
<button class="btn p-0 lh-1" (click)="unselect(document)" title="Remove link" i18n-title><i-bs name="x"></i-bs></button>
<a routerLink="/documents/{{document.id}}" class="badge bg-light text-primary" (mousedown)="$event.stopImmediatePropagation();" title="Open link" i18n-title>
<i-bs width="0.9em" height="0.9em" name="file-text"></i-bs>&nbsp;<span>{{document.title}}</span>
</a>
</div>
</ng-template>
<ng-template ng-loadingspinner-tmp>
<div class="spinner-border spinner-border-sm fw-normal ms-2 me-auto" role="status"></div>
<div class="visually-hidden" i18n>Loading...</div>
</ng-template>
<ng-template ng-option-tmp let-document="item" let-index="index" let-search="searchTerm">
<div>{{document.title}} <small class="text-muted">({{document.created | customDate:'shortDate'}})</small></div>
</ng-template>
</ng-select>
</div>
</ng-template>

View File

@ -46,6 +46,9 @@ export class DocumentLinkComponent
@Input() @Input()
parentDocumentID: number parentDocumentID: number
@Input()
minimal: boolean = false
constructor(private documentsService: DocumentService) { constructor(private documentsService: DocumentService) {
super() super()
} }