Skip to content

Commit 6ede450

Browse files
authored
ALLIN-215: Full objects history (#489)
1 parent 9583937 commit 6ede450

File tree

12 files changed

+402
-322
lines changed

12 files changed

+402
-322
lines changed

projects/matez/src/lib/components/table/table-resource.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ import { TableModule } from './table.module';
2727
imports: [TableModule],
2828
})
2929
export class TableResourceComponent<T extends object, C extends object> {
30-
resource = input<PagedObservableResource<T, unknown> | ObservableResource<T[], unknown>>();
30+
resource = input<
31+
PagedObservableResource<T, unknown> | ObservableResource<unknown, unknown, T[]>
32+
>();
3133
columns = input<Column<T, C>[]>([]);
3234
filter = model('');
3335
externalFilter = input(false, { transform: booleanAttribute });

src/app/domain-config/domain-objects-table/domain-objects-table.component.ts

Lines changed: 46 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import startCase from 'lodash-es/startCase';
33
import { CommonModule } from '@angular/common';
44
import {
55
Component,
6+
Injector,
67
TemplateRef,
78
booleanAttribute,
89
computed,
910
inject,
1011
input,
1112
model,
1213
output,
14+
runInInjectionContext,
1315
} from '@angular/core';
1416
import { ReactiveFormsModule } from '@angular/forms';
1517
import { MatButtonModule } from '@angular/material/button';
@@ -20,6 +22,7 @@ import {
2022
ActionsModule,
2123
Column,
2224
DialogResponseStatus,
25+
MenuItem,
2326
PagedObservableResource,
2427
SelectFieldModule,
2528
TableModule,
@@ -51,52 +54,14 @@ import {
5154
export class DomainObjectsTableComponent {
5255
private sidenavInfoService = inject(SidenavInfoService);
5356
private domainObjectService = inject(DomainObjectService);
57+
private injector = inject(Injector);
5458

5559
selectedTypeChange = output<keyof ReflessDomainObject>();
5660
resource = input<PagedObservableResource<LimitedVersionedObject, unknown>>();
5761
filter = model<string>('');
5862
tableInputsContent = input<TemplateRef<unknown>>();
5963
externalFilter = input(false, { transform: booleanAttribute });
60-
menu = input<Column<LimitedVersionedObject>>(
61-
createMenuColumn((d) => ({
62-
items: [
63-
{
64-
label: 'Details',
65-
click: () => {
66-
this.sidenavInfoService.toggle(DomainObjectCardComponent, {
67-
ref: d.ref,
68-
version: d.info.version,
69-
});
70-
},
71-
},
72-
{
73-
label: 'History',
74-
click: () => {
75-
this.domainObjectService.history(d.ref);
76-
},
77-
},
78-
{
79-
label: 'Edit',
80-
click: () => {
81-
this.domainObjectService.edit(d.ref).next((res) => {
82-
if (res.status === DialogResponseStatus.Success) {
83-
this.resource().reload();
84-
}
85-
});
86-
},
87-
},
88-
{
89-
label: 'Delete',
90-
click: () => {
91-
this.domainObjectService.delete(d.ref).next(() => {
92-
this.resource().reload();
93-
});
94-
},
95-
},
96-
],
97-
})),
98-
);
99-
64+
menu = input<(d: LimitedVersionedObject) => MenuItem[]>();
10065
columns = computed<Column<LimitedVersionedObject>[]>(() => [
10166
{ field: 'id', cell: (d) => ({ value: getReferenceId(d.ref) }) },
10267
{
@@ -126,6 +91,46 @@ export class DomainObjectsTableComponent {
12691
description: d.info.changed_by?.email,
12792
}),
12893
},
129-
this.menu(),
94+
runInInjectionContext(this.injector, () =>
95+
createMenuColumn((d) => ({
96+
items: this.menu()
97+
? this.menu()(d)
98+
: [
99+
{
100+
label: 'Details',
101+
click: () => {
102+
this.sidenavInfoService.toggle(DomainObjectCardComponent, {
103+
ref: d.ref,
104+
version: d.info.version,
105+
});
106+
},
107+
},
108+
{
109+
label: 'History',
110+
click: () => {
111+
this.domainObjectService.history(d.ref);
112+
},
113+
},
114+
{
115+
label: 'Edit',
116+
click: () => {
117+
this.domainObjectService.edit(d.ref).next((res) => {
118+
if (res.status === DialogResponseStatus.Success) {
119+
this.resource().reload();
120+
}
121+
});
122+
},
123+
},
124+
{
125+
label: 'Delete',
126+
click: () => {
127+
this.domainObjectService.delete(d.ref).next(() => {
128+
this.resource().reload();
129+
});
130+
},
131+
},
132+
],
133+
})),
134+
),
130135
]);
131136
}
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
11
<cc-page-layout fullHeight title="Wallets">
2-
<v-table
3-
[columns]="columns"
4-
[data]="wallets.value()"
5-
[progress]="wallets.isLoading()"
6-
name="ftsWallets"
7-
standaloneFilter
8-
(update)="reload($event)"
9-
></v-table>
2+
<cc-wallets-table [resource]="wallets"></cc-wallets-table>
103
</cc-page-layout>

0 commit comments

Comments
 (0)