[plugins-functionality | DONE | FIX] initialize properly view for master zenodo community
This commit is contained in:
parent
ed512f6f05
commit
b12ce55b20
|
@ -22,7 +22,6 @@
|
||||||
<div *ngIf="searchUtils.status == errorCodes.LOADING" class="uk-position-center">
|
<div *ngIf="searchUtils.status == errorCodes.LOADING" class="uk-position-center">
|
||||||
<loading></loading>
|
<loading></loading>
|
||||||
</div>
|
</div>
|
||||||
{{selectedCommunities.length}} {{previewCommunities.length}}
|
|
||||||
<div *ngIf="searchUtils.status !== errorCodes.LOADING">
|
<div *ngIf="searchUtils.status !== errorCodes.LOADING">
|
||||||
<div *ngIf="previewCommunities.length == 0"
|
<div *ngIf="previewCommunities.length == 0"
|
||||||
class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
|
class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
|
||||||
|
|
|
@ -42,7 +42,7 @@ export class ZenodoCommunitiesComponent implements OnInit, OnDestroy {
|
||||||
zenodoSearchUtils: SearchUtilsClass = new SearchUtilsClass();
|
zenodoSearchUtils: SearchUtilsClass = new SearchUtilsClass();
|
||||||
public errorCodes: ErrorCodes = new ErrorCodes();
|
public errorCodes: ErrorCodes = new ErrorCodes();
|
||||||
subscriptions = [];
|
subscriptions = [];
|
||||||
@ViewChild('fsModal', { static: true }) fullscreen: FullScreenModalComponent;
|
@ViewChild('fsModal', {static: true}) fullscreen: FullScreenModalComponent;
|
||||||
@ViewChild(ManageZenodoCommunitiesComponent) manage: ManageZenodoCommunitiesComponent;
|
@ViewChild(ManageZenodoCommunitiesComponent) manage: ManageZenodoCommunitiesComponent;
|
||||||
public showLoadingInRemove: boolean = true;
|
public showLoadingInRemove: boolean = true;
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ export class ZenodoCommunitiesComponent implements OnInit, OnDestroy {
|
||||||
private _zenodoCommunitieService: ZenodoCommunitiesService, private title: Title,
|
private _zenodoCommunitieService: ZenodoCommunitiesService, private title: Title,
|
||||||
private _communityService: CommunityService) {
|
private _communityService: CommunityService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.zenodoSearchUtils.status = this.errorCodes.LOADING;
|
this.zenodoSearchUtils.status = this.errorCodes.LOADING;
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
|
@ -61,41 +61,22 @@ export class ZenodoCommunitiesComponent implements OnInit, OnDestroy {
|
||||||
this.title.setTitle(this.community.shortTitle.toUpperCase() + ' | Zenodo Communities');
|
this.title.setTitle(this.community.shortTitle.toUpperCase() + ' | Zenodo Communities');
|
||||||
this.masterZenodoCommunityId = this.community.zenodoCommunity;
|
this.masterZenodoCommunityId = this.community.zenodoCommunity;
|
||||||
this.selectedCommunities = [];
|
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]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// },
|
this.zenodoSearchUtils.status = this.errorCodes.LOADING;
|
||||||
// error => {
|
|
||||||
// console.log('list of zenodo communities couldn\'t be loaded');
|
this.selectedCommunityIds = this.community.otherZenodoCommunities;
|
||||||
// this.zenodoSearchUtils.status = this.errorCodes.DONE;
|
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.okButtonText = "Done";
|
||||||
this.fullscreen.okButton = true;
|
this.fullscreen.okButton = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this.subscriptions.forEach(subscription => {
|
this.subscriptions.forEach(subscription => {
|
||||||
if (subscription instanceof Subscription) {
|
if (subscription instanceof Subscription) {
|
||||||
|
@ -111,18 +92,23 @@ export class ZenodoCommunitiesComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getZenodoCommunityById(zenodoid) {
|
getZenodoCommunityById(zenodoid) {
|
||||||
this.subscriptions.push(this._zenodoCommunitieService.getZenodoCommunityById(this.properties,
|
this.subscriptions.push(this._zenodoCommunitieService.getZenodoCommunityById(this.properties,
|
||||||
zenodoid).subscribe(
|
zenodoid).subscribe(
|
||||||
result => {
|
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++;
|
this.zenodocommunitiesloadedCount++;
|
||||||
if (this.zenodocommunitiesloadedCount >= this.selectedCommunityIds.length) {
|
if (this.zenodocommunitiesloadedCount >= this.selectedCommunityIds.length) {
|
||||||
this.zenodoSearchUtils.status = this.errorCodes.DONE;
|
this.zenodoSearchUtils.status = this.errorCodes.DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
const emptyCommunity: ZenodoCommunityInfo = new ZenodoCommunityInfo();
|
const emptyCommunity: ZenodoCommunityInfo = new ZenodoCommunityInfo();
|
||||||
|
|
Loading…
Reference in New Issue