Skip to content

Commit

Permalink
MauroDataMappergh-363 parameter to get latest finalised data model
Browse files Browse the repository at this point in the history
  • Loading branch information
GBishop-PHSA authored and joe-crawford committed Oct 18, 2022
1 parent de04837 commit 5c3104f
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 27 deletions.
5 changes: 3 additions & 2 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,10 @@ export const pageRoutes: { states: Ng2StateDeclaration[] } = {
},
{
name: 'appContainer.mainApp.twoSidePanel.catalogue.dataModel',
url: '/dataModel/:id/{tabView:string}',
url: '/dataModel/:id/{tabView:string}?{finalised:string}',
component: DataModelComponent,
params: { tabView: { dynamic: true, value: null, squash: true } },
params: { tabView: { dynamic: true, value: null, squash: true },
finalised: { dynamic: true, value: null, squash: true, inherit: false} },
data: {
allowAnonymous: true
}
Expand Down
84 changes: 59 additions & 25 deletions src/app/dataModel/data-model.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class DataModelComponent
implements OnInit, AfterViewChecked {
@ViewChild('tab', { static: false }) tabGroup: MatTabGroup;
parentId: string;
showFinalised: string;

dataModel: DataModelDetail;
editMode = false;
Expand Down Expand Up @@ -106,6 +107,7 @@ export class DataModelComponent
}
this.showExtraTabs = this.sharedService.isLoggedIn();
this.parentId = this.uiRouterGlobals.params.id;
this.showFinalised = this.uiRouterGlobals.params.finalised;

this.activeTab = this.tabs.getByName(
this.uiRouterGlobals.params.tabView ?? 'description'
Expand All @@ -114,7 +116,7 @@ export class DataModelComponent

this.title.setTitle('Data Model');

this.dataModelDetails(this.parentId);
this.dataModelDetails(this.parentId, this.showFinalised);
}

save(saveItems: Array<DefaultProfileItem>) {
Expand Down Expand Up @@ -162,35 +164,67 @@ export class DataModelComponent
}
}

dataModelDetails(id: string) {
dataModelDetails(id: string, showFinalised: string) {
let arr = [];

this.resourcesService.dataModel
.get(id)
.subscribe(async (result: DataModelDetailResponse) => {
this.dataModel = result.body;
this.catalogueItem = result.body;

this.watchDataModelObject();
this.parentId = this.catalogueItem.id;

await this.resourcesService.versionLink
.list('dataModels', this.catalogueItem.id)
.subscribe((response) => {
if (response.body.count > 0) {
arr = response.body.items;
for (const val in arr) {
if (this.catalogueItem.id !== arr[val].targetModel.id) {
this.semanticLinks.push(arr[val]);
if (!showFinalised) {
this.resourcesService.dataModel
.get(id)
.subscribe(async (result: DataModelDetailResponse) => {
this.dataModel = result.body;
this.catalogueItem = result.body;

this.watchDataModelObject();
this.parentId = this.catalogueItem.id;

await this.resourcesService.versionLink
.list('dataModels', this.catalogueItem.id)
.subscribe((response) => {
if (response.body.count > 0) {
arr = response.body.items;
for (const val in arr) {
if (this.catalogueItem.id !== arr[val].targetModel.id) {
this.semanticLinks.push(arr[val]);
}
}
}
}
});
});

if (this.sharedService.isLoggedIn(true)) {
this.DataModelPermissions(this.catalogueItem.id);
}
});
if (this.sharedService.isLoggedIn(true)) {
this.DataModelPermissions(this.catalogueItem.id);
}
});
} else {
const data = {
finalised: this.showFinalised
};
this.resourcesService.catalogueItem
.getPath('dataModels', id, data)
.subscribe(async (result: DataModelDetailResponse) => {
this.dataModel = result.body;
this.catalogueItem = result.body;

this.watchDataModelObject();
this.parentId = this.catalogueItem.id;

await this.resourcesService.versionLink
.list('dataModels', this.catalogueItem.id)
.subscribe((response) => {
if (response.body.count > 0) {
arr = response.body.items;
for (const val in arr) {
if (this.catalogueItem.id !== arr[val].targetModel.id) {
this.semanticLinks.push(arr[val]);
}
}
}
});

if (this.sharedService.isLoggedIn(true)) {
this.DataModelPermissions(this.catalogueItem.id);
}
});
}
}

async DataModelPermissions(id: any) {
Expand Down

0 comments on commit 5c3104f

Please sign in to comment.