[plugins-functionality | DONE | FIX] initialize properly view for master zenodo community

This commit is contained in:
argirok 2024-03-11 14:08:51 +02:00
parent ed512f6f05
commit b12ce55b20
2 changed files with 28 additions and 43 deletions

View File

@ -22,7 +22,6 @@
<div *ngIf="searchUtils.status == errorCodes.LOADING" class="uk-position-center">
<loading></loading>
</div>
{{selectedCommunities.length}} {{previewCommunities.length}}
<div *ngIf="searchUtils.status !== errorCodes.LOADING">
<div *ngIf="previewCommunities.length == 0"
class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">

View File

@ -42,7 +42,7 @@ export class ZenodoCommunitiesComponent implements OnInit, OnDestroy {
zenodoSearchUtils: SearchUtilsClass = new SearchUtilsClass();
public errorCodes: ErrorCodes = new ErrorCodes();
subscriptions = [];
@ViewChild('fsModal', { static: true }) fullscreen: FullScreenModalComponent;
@ViewChild('fsModal', {static: true}) fullscreen: FullScreenModalComponent;
@ViewChild(ManageZenodoCommunitiesComponent) manage: ManageZenodoCommunitiesComponent;
public showLoadingInRemove: boolean = true;
@ -50,7 +50,7 @@ export class ZenodoCommunitiesComponent implements OnInit, OnDestroy {
private _zenodoCommunitieService: ZenodoCommunitiesService, private title: Title,
private _communityService: CommunityService) {
}
ngOnInit() {
this.zenodoSearchUtils.status = this.errorCodes.LOADING;
this.properties = properties;
@ -61,41 +61,22 @@ export class ZenodoCommunitiesComponent implements OnInit, OnDestroy {
this.title.setTitle(this.community.shortTitle.toUpperCase() + ' | Zenodo Communities');
this.masterZenodoCommunityId = this.community.zenodoCommunity;
this.selectedCommunities = [];
if (this.masterZenodoCommunityId) {
this.subscriptions.push(this._zenodoCommunitieService.getZenodoCommunityById(this.properties,
this.masterZenodoCommunityId).subscribe(
result => {
this.masterZenodoCommunity = result;
this.selectedCommunities.unshift(this.masterZenodoCommunity);
},
error => {
const emptyCommunity: ZenodoCommunityInfo = new ZenodoCommunityInfo();
emptyCommunity.id = this.masterZenodoCommunityId;
emptyCommunity.title = this.masterZenodoCommunityId;
this.masterZenodoCommunity = emptyCommunity;
}
));
}
this.zenodoSearchUtils.status = this.errorCodes.LOADING;
this.zenodoSearchUtils.status = this.errorCodes.LOADING;
// this._searchZenodoCommunitiesService.searchZCommunities(this.properties, this.community.communityId).subscribe(
// result => {
this.selectedCommunityIds = this.community.otherZenodoCommunities;
this.zenodoSearchUtils.totalResults = this.selectedCommunityIds.length;
if (this.selectedCommunityIds.length === 0) {
this.zenodoSearchUtils.status = this.errorCodes.NONE;
}
for (let i = 0; i < this.selectedCommunityIds.length; i++) {
this.getZenodoCommunityById(
this.selectedCommunityIds[i]);
}
// },
// error => {
// console.log('list of zenodo communities couldn\'t be loaded');
// this.zenodoSearchUtils.status = this.errorCodes.DONE;
// }
// );
this.zenodoSearchUtils.status = this.errorCodes.LOADING;
this.selectedCommunityIds = this.community.otherZenodoCommunities;
if(this.masterZenodoCommunityId){
this.selectedCommunityIds.unshift(this.masterZenodoCommunityId)
}
this.zenodoSearchUtils.totalResults = this.selectedCommunityIds.length;
if (this.selectedCommunityIds.length === 0) {
this.zenodoSearchUtils.status = this.errorCodes.NONE;
}
for (let i = 0; i < this.selectedCommunityIds.length; i++) {
this.getZenodoCommunityById(
this.selectedCommunityIds[i]);
}
})
);
@ -103,7 +84,7 @@ export class ZenodoCommunitiesComponent implements OnInit, OnDestroy {
this.fullscreen.okButtonText = "Done";
this.fullscreen.okButton = true;
}
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscription) {
@ -111,18 +92,23 @@ export class ZenodoCommunitiesComponent implements OnInit, OnDestroy {
}
});
}
getZenodoCommunityById(zenodoid) {
this.subscriptions.push(this._zenodoCommunitieService.getZenodoCommunityById(this.properties,
zenodoid).subscribe(
zenodoid).subscribe(
result => {
this.selectedCommunities.push(result);
if(zenodoid == this.masterZenodoCommunityId){
this.masterZenodoCommunity = result;
result.master = true;
this.selectedCommunities.unshift(result);
}else {
this.selectedCommunities.push(result);
}
this.zenodocommunitiesloadedCount++;
if (this.zenodocommunitiesloadedCount >= this.selectedCommunityIds.length) {
this.zenodoSearchUtils.status = this.errorCodes.DONE;
}
},
error => {
const emptyCommunity: ZenodoCommunityInfo = new ZenodoCommunityInfo();