Frontend display custom fields in dasboard views

This commit is contained in:
shamoon
2024-04-17 16:00:30 -07:00
parent 0f29899b71
commit cd4cc4d9e1
7 changed files with 267 additions and 49 deletions

View File

@@ -14,7 +14,7 @@
<thead>
<tr>
@for (column of savedView.dashboard_view_table_columns; track column; let i = $index) {
@if (columnIsVisible(column)) {
@if (visibleColumns.includes(column)) {
<th
scope="col"
[ngClass]="{
@@ -28,10 +28,10 @@
</tr>
</thead>
<tbody>
@for (doc of documents; track doc) {
<tr (mouseleave)="maybeClosePopover()">
@for (doc of documents; track doc.id) {
<tr>
@for (column of savedView.dashboard_view_table_columns; track column; let i = $index) {
@if (columnIsVisible(column)) {
@if (visibleColumns.includes(column)) {
<td class="py-2 py-md-3 position-relative" [ngClass]="{ 'd-none d-md-table-cell': i > 1 }">
@switch (column) {
@case (DashboardViewTableColumn.ADDED) {
@@ -64,6 +64,31 @@
}
}
}
@if (column.startsWith(DashboardViewTableColumn.CUSTOM_FIELD)) {
@switch(getCustomFieldDataType(column)) {
@case (CustomFieldDataType.Monetary) {
{{ getMonetaryCustomFieldValue(doc, column)[0] | currency: getMonetaryCustomFieldValue(doc, column)[1] }}
}
@case (CustomFieldDataType.Date) {
{{ getCustomFieldValue(doc, column) | customDate }}
}
@case (CustomFieldDataType.Url) {
<a [href]="getCustomFieldValue(doc, column)" class="btn-link text-dark text-decoration-none" target="_blank">{{ getCustomFieldValue(doc, column) }}</a>
}
@case (CustomFieldDataType.DocumentLink) {
<div class="d-flex gap-1 flex-wrap">
@for (docId of getCustomFieldValue(doc, column); track docId) {
<a routerLink="/documents/{{docId}}" class="badge bg-dark text-primary" title="View" i18n-title>
<i-bs width="0.9em" height="0.9em" name="file-text"></i-bs>&nbsp;<span>{{ getDocumentTitle(docId) }}</span>
</a>
}
</div>
}
@default {
{{ getCustomFieldValue(doc, column) }}
}
}
}
@if (i === savedView.dashboard_view_table_columns.length - 1) {
<div class="btn-group position-absolute top-50 end-0 translate-middle-y">
<a [href]="getPreviewUrl(doc)" title="View Preview" i18n-title target="_blank" class="btn px-4 btn-dark border-dark-subtle"