[develop | DONE | CHANGED]: Parse organization versions from "children" field of the record, instead of querying explicitly.

1. organizationInfo.ts: Added field "children".
2. organization.service.ts: Set children field.
3. organization.component.html: In <organizationsDeletedByInference> add parameter children.
4. organization/deletedByInference/deletedByInference.component.ts: Parse children to initialize resultsPreview: ResultPreview[] and show versions accordingly.
This commit is contained in:
Konstantina Galouni 2024-07-02 00:15:21 +03:00
parent 1b70600397
commit a8c2b2d0a3
4 changed files with 45 additions and 28 deletions

View File

@ -19,28 +19,30 @@ import {HelperFunctions} from "../../../utils/HelperFunctions.class";
template: `
<div id="versions_container">
<errorMessages [status]="[status]" [type]="type" tab_error_class=true></errorMessages>
<no-load-paging *ngIf="results.length > pageSize" [type]="type"
<no-load-paging *ngIf="resultsPreview.length > pageSize" [type]="type"
(pageChange)="updatePage($event)"
[page]="page" [pageSize]="pageSize"
[totalResults]="results.length">
[totalResults]="resultsPreview.length">
</no-load-paging>
<ul class="uk-list uk-list-divider uk-margin">
<li *ngFor="let result of results.slice((page-1)*pageSize, page*pageSize)">
<result-preview [modal]="modal" [properties]="properties" [hasLink]="false" [result]="getResultPreview(result)"
<li *ngFor="let result of resultsPreview.slice((page-1)*pageSize, page*pageSize)">
<result-preview [modal]="modal" [properties]="properties" [hasLink]="false" [result]="result"
[isCard]="false" [prevPath]="prevPath" [isDeletedByInferenceModal]="true"></result-preview>
</li>
</ul>
<no-load-paging *ngIf="results.length > pageSize" [type]="type"
<no-load-paging *ngIf="resultsPreview.length > pageSize" [type]="type"
(pageChange)="updatePage($event)"
[page]="page" [pageSize]="pageSize"
[totalResults]="results.length">
[totalResults]="resultsPreview.length">
</no-load-paging>
</div>
`
})
export class OrganizationsDeletedByInferenceComponent {
@Input() prevPath: string = "";
public results: OrganizationInfo[] = [];
public resultsPreview: ResultPreview[] = [];
@Input() children = [];
@Input() id: string;
@Input() ids: string[] = [];
@Input() type: string;
@ -67,10 +69,10 @@ export class OrganizationsDeletedByInferenceComponent {
this.properties = properties;
this.subscriptions.push(this.route.queryParams.subscribe(data => {
this.errorCodes = new ErrorCodes();
this.status = this.errorCodes.LOADING;
this.errorCodes = new ErrorCodes();
this.status = this.errorCodes.LOADING;
this.getDeletedByInference();
this.parseDeletedByInference();
}));
}
@ -81,27 +83,38 @@ export class OrganizationsDeletedByInferenceComponent {
}
});
}
getDeletedByInference() {
this.results = [];
this.status = this.errorCodes.LOADING;
this.subscriptions.push(this._deletedByInferenceService.getDeletedByInferenceResults(this.id, String(this.ids.length), this.properties).subscribe(
data => {
this.results = data;
this.status = this.errorCodes.DONE;
},
error => {
if(error.status == '404') {
this.status = this.errorCodes.NOT_FOUND;
} else if(error.status == '500') {
this.status = this.errorCodes.ERROR;
public parseDeletedByInference() {
let length = Array.isArray(this.children) ? this.children.length : 1;
for (let i = 0; i < length; i++) {
let result = Array.isArray(this.children) ? this.children[i] : this.children;
let preview = new ResultPreview();
if(result.hasOwnProperty("websiteurl")) {
preview.websiteURL = result.websiteurl;
}
if(result.hasOwnProperty("legalshortname")) {
preview.title = result.legalshortname;
}
if(result.hasOwnProperty("legalname")) {
if(preview.title && preview.title != result.legalname) {
preview.title += "("+result.legalname+")";
} else {
this.status = this.errorCodes.NOT_AVAILABLE;
preview.title = result.legalname;
}
}
));
if(result.hasOwnProperty("country")) {
preview.countries = [result['country'].classname];
}
preview.resultType = 'organization';
this.resultsPreview.push(preview);
}
this.status = this.errorCodes.DONE;
}
public getResultPreview(result: OrganizationInfo): ResultPreview {
return ResultPreview.organizationInfoConvert(result);
}

View File

@ -370,7 +370,8 @@
[id]="organizationInfo.objIdentifier"
[ids]="organizationInfo.deletedByInferenceIds"
[modal]="AlertModalDeletedByInference"
[type]="'organizations'" [prevPath]="prevPath">
[type]="'organizations'" [prevPath]="prevPath"
[children]="organizationInfo.children">
</organizationsDeletedByInference>
</modal-alert>
@ -484,7 +485,8 @@
<organizationsDeletedByInference *ngIf="deleteByInferenceOpened"
[id]="organizationInfo.objIdentifier"
[ids]="organizationInfo.deletedByInferenceIds"
[type]="'organizations'" [prevPath]="prevPath">
[type]="'organizations'" [prevPath]="prevPath"
[children]="organizationInfo.children">
</organizationsDeletedByInference>
</fs-modal>
<!-- Share -->

View File

@ -93,6 +93,7 @@ export class OrganizationService {
this.organizationInfo.deletedByInferenceIds.push(result.objidentifier);
}
}
this.organizationInfo.children = children['organization'];
}
if(organization['pid']) {

View File

@ -28,6 +28,7 @@ export class OrganizationInfo {
// organizations: {name: string; url: string}[]}[];
deletedByInferenceIds: string[];
children;
identifiers: Map<string, string[]>; //key is the classname
belongsTo: boolean = true;
message: string;