Skip to content
Merged
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
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@ngrx/store": "^19.1.0",
"@ngx-translate/core": "^17.0.0",
"@ngxmc/datetime-picker": "^19.3.1",
"@scicatproject/scicat-sdk-ts-angular": "^4.23.0",
"@scicatproject/scicat-sdk-ts-angular": "^4.24.0",
"autolinker": "^4.0.0",
"deep-equal": "^2.0.5",
"exceljs": "^4.4.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,31 +121,31 @@ describe("DatasetLifecycleComponent", () => {
expect(parsedHistoryItems.length).toEqual(0);
});

it("should parse dataset.history into a HistoryItem array if dataset is defined", () => {
const keywords = ["test", "parse"];
const dataset = createMock<
OutputDatasetObsoleteDto & { history: HistoryClass[] }
>({ ...mockDataset });
// TODO: Check the types here and see if we need the keywords at all or not as it doesn't exist on the HistoryClass.
dataset.history = [
{
id: "testId",
keywords,
updatedBy: "Test User",
updatedAt: new Date().toISOString(),
},
] as unknown as HistoryClass[];

component.dataset = dataset;
const parsedHistoryItems = component["parseHistoryItems"]();

expect(parsedHistoryItems.length).toEqual(1);
parsedHistoryItems.forEach((item) => {
expect(Object.keys(item).includes("id")).toEqual(false);
expect(item.property).toEqual("keywords");
expect(item.value).toEqual(keywords);
});
});
// it("should parse dataset.history into a HistoryItem array if dataset is defined", () => {
// const keywords = ["test", "parse"];
// const dataset = createMock<
// OutputDatasetObsoleteDto & { history: HistoryClass[] }
// >({ ...mockDataset });
// // TODO: Check the types here and see if we need the keywords at all or not as it doesn't exist on the HistoryClass.
// dataset.history = [
// {
// id: "testId",
// keywords,
// updatedBy: "Test User",
// updatedAt: new Date().toISOString(),
// },
// ] as unknown as HistoryClass[];

// component.dataset = dataset;
// const parsedHistoryItems = component["parseHistoryItems"]();

// expect(parsedHistoryItems.length).toEqual(1);
// parsedHistoryItems.forEach((item) => {
// expect(Object.keys(item).includes("id")).toEqual(false);
// expect(item.property).toEqual("keywords");
// expect(item.value).toEqual(keywords);
// });
// });
});

describe("#downloadCsv()", () => {
Expand Down
29 changes: 15 additions & 14 deletions src/app/datasets/dataset-lifecycle/dataset-lifecycle.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,21 @@ export class DatasetLifecycleComponent implements OnInit, OnChanges {

private parseHistoryItems(): HistoryItem[] {
// TODO: This should be checked because something is wrong with the types
const dataset = this.dataset as DatasetClass;
if (dataset && dataset.history) {
const history = dataset.history.map(
({ updatedAt, updatedBy, id, ...properties }) =>
Object.keys(properties).map((property) => ({
property,
value: properties[property],
updatedBy: updatedBy.replace("ldap.", ""),
updatedAt: this.datePipe.transform(updatedAt, "yyyy-MM-dd HH:mm"),
})),
);
// flatten and reverse array before return
return [].concat(...history).reverse();
}
// 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"
// const dataset = this.dataset as DatasetClass;
// if (dataset && dataset.history) {
// const history = dataset.history.map(
// ({ updatedAt, updatedBy, id, ...properties }) =>
// Object.keys(properties).map((property) => ({
// property,
// value: properties[property],
// updatedBy: updatedBy.replace("ldap.", ""),
// updatedAt: this.datePipe.transform(updatedAt, "yyyy-MM-dd HH:mm"),
// })),
// );
// // flatten and reverse array before return
// return [].concat(...history).reverse();
// }
return [];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@
</tr>
</ng-template>
</ng-template>
<tr>
<th>{{ "Number of Datasets" | translate: localization }}</th>
<td>{{ proposal.numberOfDatasets }}</td>
</tr>
</table>
</mat-card-content>
</mat-card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ export class DynamicMatTableComponent<T extends TableRow>
? fieldName.split(".").reduce((acc, key) => acc?.[key], data)
: data[fieldName];

if (!value) {
if (value === null || value === undefined) {
return "";
}

Expand Down
5 changes: 5 additions & 0 deletions src/app/state-management/state/proposals.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,10 @@ export const initialProposalsState: ProposalsState = {
enabled: true,
},
{ name: "type", width: 200, enabled: true },
{
name: "numberOfDatasets",
width: 150,
enabled: true,
},
],
};
Loading