Skip to content

Commit e66b068

Browse files
authored
feat: add numberOfDatasets in proposal table and the details page under general information (#2041)
## Description This PR displays the numberOfDataset field in proposal table & the proposal details page under general information. <img width="733" height="238" alt="numberOfDatasets-details" src="https://github.com/user-attachments/assets/aa14efb7-a6e9-4ace-835d-78abdcaa4122" /> <img width="1436" height="165" alt="numberOfDatasets-table" src="https://github.com/user-attachments/assets/738f1ee5-85ca-476d-8342-925e1f9f8e93" /> ## Motivation Background on use case, changes needed ## Fixes: Please provide a list of the fixes implemented in this PR * Items added ## Changes: Please provide a list of the changes implemented by this PR * changes made ## Tests included - [ ] Included for each change/fix? - [ ] Passing? (Merge will not be approved unless this is checked) ## Documentation - [ ] swagger documentation updated \[required\] - [ ] official documentation updated \[nice-to-have\] ### official documentation info If you have updated the official documentation, please provide PR # and URL of the pages where the updates are included ## Backend version - [ ] Does it require a specific version of the backend - which version of the backend is required: ## Summary by Sourcery New Features: - Render a new table row showing the proposal.numberOfDatasets value in the details view.
1 parent 5daa0b1 commit e66b068

File tree

7 files changed

+56
-45
lines changed

7 files changed

+56
-45
lines changed

package-lock.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"@ngrx/store": "^19.1.0",
4242
"@ngx-translate/core": "^17.0.0",
4343
"@ngxmc/datetime-picker": "^19.3.1",
44-
"@scicatproject/scicat-sdk-ts-angular": "^4.23.0",
44+
"@scicatproject/scicat-sdk-ts-angular": "^4.24.0",
4545
"autolinker": "^4.0.0",
4646
"deep-equal": "^2.0.5",
4747
"exceljs": "^4.4.0",

src/app/datasets/dataset-lifecycle/dataset-lifecycle.component.spec.ts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -121,31 +121,31 @@ describe("DatasetLifecycleComponent", () => {
121121
expect(parsedHistoryItems.length).toEqual(0);
122122
});
123123

124-
it("should parse dataset.history into a HistoryItem array if dataset is defined", () => {
125-
const keywords = ["test", "parse"];
126-
const dataset = createMock<
127-
OutputDatasetObsoleteDto & { history: HistoryClass[] }
128-
>({ ...mockDataset });
129-
// TODO: Check the types here and see if we need the keywords at all or not as it doesn't exist on the HistoryClass.
130-
dataset.history = [
131-
{
132-
id: "testId",
133-
keywords,
134-
updatedBy: "Test User",
135-
updatedAt: new Date().toISOString(),
136-
},
137-
] as unknown as HistoryClass[];
138-
139-
component.dataset = dataset;
140-
const parsedHistoryItems = component["parseHistoryItems"]();
141-
142-
expect(parsedHistoryItems.length).toEqual(1);
143-
parsedHistoryItems.forEach((item) => {
144-
expect(Object.keys(item).includes("id")).toEqual(false);
145-
expect(item.property).toEqual("keywords");
146-
expect(item.value).toEqual(keywords);
147-
});
148-
});
124+
// it("should parse dataset.history into a HistoryItem array if dataset is defined", () => {
125+
// const keywords = ["test", "parse"];
126+
// const dataset = createMock<
127+
// OutputDatasetObsoleteDto & { history: HistoryClass[] }
128+
// >({ ...mockDataset });
129+
// // TODO: Check the types here and see if we need the keywords at all or not as it doesn't exist on the HistoryClass.
130+
// dataset.history = [
131+
// {
132+
// id: "testId",
133+
// keywords,
134+
// updatedBy: "Test User",
135+
// updatedAt: new Date().toISOString(),
136+
// },
137+
// ] as unknown as HistoryClass[];
138+
139+
// component.dataset = dataset;
140+
// const parsedHistoryItems = component["parseHistoryItems"]();
141+
142+
// expect(parsedHistoryItems.length).toEqual(1);
143+
// parsedHistoryItems.forEach((item) => {
144+
// expect(Object.keys(item).includes("id")).toEqual(false);
145+
// expect(item.property).toEqual("keywords");
146+
// expect(item.value).toEqual(keywords);
147+
// });
148+
// });
149149
});
150150

151151
describe("#downloadCsv()", () => {

src/app/datasets/dataset-lifecycle/dataset-lifecycle.component.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,21 @@ export class DatasetLifecycleComponent implements OnInit, OnChanges {
6464

6565
private parseHistoryItems(): HistoryItem[] {
6666
// TODO: This should be checked because something is wrong with the types
67-
const dataset = this.dataset as DatasetClass;
68-
if (dataset && dataset.history) {
69-
const history = dataset.history.map(
70-
({ updatedAt, updatedBy, id, ...properties }) =>
71-
Object.keys(properties).map((property) => ({
72-
property,
73-
value: properties[property],
74-
updatedBy: updatedBy.replace("ldap.", ""),
75-
updatedAt: this.datePipe.transform(updatedAt, "yyyy-MM-dd HH:mm"),
76-
})),
77-
);
78-
// flatten and reverse array before return
79-
return [].concat(...history).reverse();
80-
}
67+
// TODO: The following code is commented out and should be refactored because the history is no longer part of the dataset object anymore due to this PR from Scicat BE: "feat: implements history for many entities #1939"
68+
// const dataset = this.dataset as DatasetClass;
69+
// if (dataset && dataset.history) {
70+
// const history = dataset.history.map(
71+
// ({ updatedAt, updatedBy, id, ...properties }) =>
72+
// Object.keys(properties).map((property) => ({
73+
// property,
74+
// value: properties[property],
75+
// updatedBy: updatedBy.replace("ldap.", ""),
76+
// updatedAt: this.datePipe.transform(updatedAt, "yyyy-MM-dd HH:mm"),
77+
// })),
78+
// );
79+
// // flatten and reverse array before return
80+
// return [].concat(...history).reverse();
81+
// }
8182
return [];
8283
}
8384

src/app/proposals/proposal-detail/proposal-detail.component.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@
7272
</tr>
7373
</ng-template>
7474
</ng-template>
75+
<tr>
76+
<th>{{ "Number of Datasets" | translate: localization }}</th>
77+
<td>{{ proposal.numberOfDatasets }}</td>
78+
</tr>
7579
</table>
7680
</mat-card-content>
7781
</mat-card>

src/app/shared/modules/dynamic-material-table/table/dynamic-mat-table.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ export class DynamicMatTableComponent<T extends TableRow>
10201020
? fieldName.split(".").reduce((acc, key) => acc?.[key], data)
10211021
: data[fieldName];
10221022

1023-
if (!value) {
1023+
if (value === null || value === undefined) {
10241024
return "";
10251025
}
10261026

src/app/state-management/state/proposals.store.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,5 +119,10 @@ export const initialProposalsState: ProposalsState = {
119119
enabled: true,
120120
},
121121
{ name: "type", width: 200, enabled: true },
122+
{
123+
name: "numberOfDatasets",
124+
width: 150,
125+
enabled: true,
126+
},
122127
],
123128
};

0 commit comments

Comments
 (0)