2020-11-28 21:28:07 +01:00
|
|
|
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
2020-12-07 22:29:51 +01:00
|
|
|
import { map } from 'rxjs/operators';
|
2020-10-27 01:10:18 +01:00
|
|
|
import { PaperlessDocument } from 'src/app/data/paperless-document';
|
2020-11-28 21:28:07 +01:00
|
|
|
import { PaperlessTag } from 'src/app/data/paperless-tag';
|
2020-10-27 01:10:18 +01:00
|
|
|
import { DocumentService } from 'src/app/services/rest/document.service';
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-document-card-small',
|
|
|
|
|
templateUrl: './document-card-small.component.html',
|
2020-11-22 14:43:59 +01:00
|
|
|
styleUrls: ['./document-card-small.component.scss']
|
2020-10-27 01:10:18 +01:00
|
|
|
})
|
|
|
|
|
export class DocumentCardSmallComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
constructor(private documentService: DocumentService) { }
|
|
|
|
|
|
2020-12-13 14:10:55 +01:00
|
|
|
_selected = false
|
|
|
|
|
|
|
|
|
|
get selected() {
|
|
|
|
|
return this._selected
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Input()
|
|
|
|
|
set selected(value: boolean) {
|
|
|
|
|
this._selected = value
|
|
|
|
|
this.selectedChange.emit(value)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Output()
|
|
|
|
|
selectedChange = new EventEmitter<boolean>()
|
2020-12-11 17:35:21 +01:00
|
|
|
|
2020-10-27 01:10:18 +01:00
|
|
|
@Input()
|
|
|
|
|
document: PaperlessDocument
|
|
|
|
|
|
2020-11-28 21:28:07 +01:00
|
|
|
@Output()
|
2020-12-03 20:28:17 +01:00
|
|
|
clickTag = new EventEmitter<number>()
|
2020-11-28 21:28:07 +01:00
|
|
|
|
|
|
|
|
@Output()
|
2020-12-03 20:28:17 +01:00
|
|
|
clickCorrespondent = new EventEmitter<number>()
|
2020-11-28 21:28:07 +01:00
|
|
|
|
2020-12-07 22:29:51 +01:00
|
|
|
moreTags: number = null
|
|
|
|
|
|
2020-10-27 01:10:18 +01:00
|
|
|
ngOnInit(): void {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getThumbUrl() {
|
|
|
|
|
return this.documentService.getThumbUrl(this.document.id)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getDownloadUrl() {
|
|
|
|
|
return this.documentService.getDownloadUrl(this.document.id)
|
|
|
|
|
}
|
2020-11-28 14:50:14 +01:00
|
|
|
|
|
|
|
|
getPreviewUrl() {
|
|
|
|
|
return this.documentService.getPreviewUrl(this.document.id)
|
|
|
|
|
}
|
2020-12-07 22:29:51 +01:00
|
|
|
|
|
|
|
|
getTagsLimited$() {
|
|
|
|
|
return this.document.tags$.pipe(
|
|
|
|
|
map(tags => {
|
|
|
|
|
if (tags.length > 7) {
|
|
|
|
|
this.moreTags = tags.length - 6
|
|
|
|
|
return tags.slice(0, 6)
|
|
|
|
|
} else {
|
|
|
|
|
return tags
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-27 01:10:18 +01:00
|
|
|
}
|