Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ <h3>{{ formatTabLabel(datatableName) }}</h3>
}
@case ('INTEGER') {
<span>
{{ formatValue(dataObject.data[0].row[i]) }}
@if (getResolvedUserName(columnHeader.columnName, dataObject.data[0].row[i])) {
{{ getResolvedUserName(columnHeader.columnName, dataObject.data[0].row[i]) }}
} @else {
{{ formatValue(dataObject.data[0].row[i]) }}
}
</span>
}
@case ('DECIMAL') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 +25,30 @@

.data-grid {
display: grid;
gap: 20px;
padding: 12px 0;
grid-auto-flow: column;
grid-auto-columns: minmax(220px, 220px);
align-items: stretch;
gap: 16px;
padding: 8px 0;
grid-template-columns: repeat(auto-fill, minmax(256px, 1fr)); /* stylelint-disable-line unit-allowed-list */
}

.data-item {
display: flex;
flex-direction: column;
min-width: 0;
padding: 16px;
background-color: rgb(0 0 0 / 2%);
border-radius: 8px;
border-left: 3px solid transparent;
transition: all 0.2s ease;
min-height: 70px;
padding: 8px 16px;
border-radius: 4px;
transition: background-color 0.2s ease;

&:hover {
background-color: rgb(0 0 0 / 4%);
border-left-color: var(--primary-color, #3f51b5);
transform: translateY(-2px);
box-shadow: 0 2px 8px rgb(0 0 0 / 10%);
background-color: rgb(0 0 0 / 2%);
}
}

.data-label {
font-size: 0.8125rem;
font-size: 0.75rem;
color: rgb(0 0 0 / 54%);
margin-bottom: 8px;
letter-spacing: 0.3px;
letter-spacing: 0.5px;
font-weight: 500;
text-transform: uppercase;
line-height: 1.2;
overflow-wrap: anywhere;
white-space: normal;
Expand Down Expand Up @@ -98,8 +90,6 @@

.system-defined {
margin-top: 3px;
background-color: rgb(63 81 181 / 8%);
border-left-color: #3f51b5;
}

.long-text {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.co
import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component';
import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base';
import { SystemService } from 'app/system/system.service';
import { UsersService } from 'app/users/users.service';
import { NgClass } from '@angular/common';
import { MatButton, MatIconButton } from '@angular/material/button';
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
Expand Down Expand Up @@ -71,13 +72,18 @@ export class DatatableSingleRowComponent implements OnInit, OnChanges {
private settingsService = inject(SettingsService);
public datatables = inject(Datatables);
private systemService = inject(SystemService);
private usersService = inject(UsersService);
private translateService = inject(TranslateService);

@Input() dataObject: any;
@Input() dataObject: {
columnHeaders: { columnName: string; columnDisplayType?: string; columnType?: string }[];
data: { row: any[] }[];
};
@Input() entityId: string;
@Input() entityType: string;
datatableName: string;
isLoading = false;
resolvedUserNames = new Map<number, string>();

formatTabLabel(label: string): string {
return formatDatatableDisplayLabel(label);
Expand Down Expand Up @@ -107,10 +113,57 @@ export class DatatableSingleRowComponent implements OnInit, OnChanges {

ngOnChanges(changes: SimpleChanges): void {
if (changes.dataObject) {
this.resolveUserNames();
this.changeDetectorRef.markForCheck();
}
}

private resolveUserNames(): void {
if (!this.dataObject || !this.dataObject.data || !this.dataObject.data[0]) {
return;
}
const row = this.dataObject.data[0].row;

this.dataObject.columnHeaders.forEach((column: { columnName: string }, index: number) => {
const lowerName = column.columnName.toLowerCase();
if (
lowerName === 'createdby_id' ||
lowerName === 'created_by_id' ||
lowerName === 'lastmodifiedby_id' ||
lowerName === 'last_modified_by_id'
) {
const userId = row[index] as number;
if (userId && !this.resolvedUserNames.has(userId)) {
this.usersService.getUser(userId.toString()).subscribe({
next: (user: { firstname?: string; lastname?: string }) => {
if (user && user.firstname && user.lastname) {
this.resolvedUserNames.set(userId, `${user.firstname} ${user.lastname}`);
this.changeDetectorRef.markForCheck();
}
},
error: (err) => {
console.warn(`Could not resolve user name for ID ${userId}. Falling back to numeric ID.`, err);
}
});
}
}
});
}

getResolvedUserName(columnName: string, value: number | null | undefined): string | null {
if (!value) return null;
const lowerName = columnName.toLowerCase();
if (
lowerName === 'createdby_id' ||
lowerName === 'created_by_id' ||
lowerName === 'lastmodifiedby_id' ||
lowerName === 'last_modified_by_id'
) {
return this.resolvedUserNames.get(value) || null;
}
return null;
}

add() {
let dataTableEntryObject: any = {
locale: this.settingsService.language.code
Expand Down Expand Up @@ -143,6 +196,7 @@ export class DatatableSingleRowComponent implements OnInit, OnChanges {
this.changeDetectorRef.markForCheck();
this.systemService.getEntityDatatable(this.entityId, this.datatableName).subscribe((dataObject: any) => {
this.dataObject = dataObject;
this.resolveUserNames();
this.isLoading = false;
this.changeDetectorRef.markForCheck();
});
Expand Down Expand Up @@ -214,6 +268,7 @@ export class DatatableSingleRowComponent implements OnInit, OnChanges {
this.changeDetectorRef.markForCheck();
this.systemService.getEntityDatatable(this.entityId, this.datatableName).subscribe((dataObject: any) => {
this.dataObject = dataObject;
this.resolveUserNames();
this.isLoading = false;
this.changeDetectorRef.markForCheck();
});
Expand Down
Loading