connect-admin/src/app/pages/projects/manage-projects.component.ts

85 lines
3.2 KiB
TypeScript
Raw Normal View History

import {Component, ElementRef, Input, OnInit, ViewChild} from '@angular/core';
import {ActivatedRoute, Router} from "@angular/router";
import {RemoveProjectsComponent} from './remove-projects.component';
import {Title} from '@angular/platform-browser';
import {FullScreenModalComponent} from "../../openaireLibrary/utils/modal/full-screen-modal/full-screen-modal.component";
import {StringUtils} from "../../openaireLibrary/utils/string-utils.class";
import {EnvProperties} from "../../openaireLibrary/utils/properties/env-properties";
import {properties} from "../../../environments/environment";
import {Subscriber} from "rxjs";
import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo";
import {OpenaireEntities} from "../../openaireLibrary/utils/properties/searchFields";
import {CommunityService} from "../../openaireLibrary/connect/community/community.service";
@Component({
selector: 'manage-projects',
template: `
<remove-projects #removeProjectsComponent (addProjects)="openAddProjects()"
[loading]="showLoadingInRemove" [community]="community">
</remove-projects>
[Connect Admin | new-theme]: Updated messages when no results in affiliations, data sources, projects, subjects, zenodo communities | [Bug fix] In add projects, show selected filter if exists (even when no results). 1. affiliations.component.html: Updated "no organizations found" message to "no organizations for {{community}}". 2. add-content-providers.component.html: When no data sources, show info message for missing data sources too. 3. add-content-providers.component.ts: Created get method infoMessage() to return info message for missing data sources. 4. manage-content-providers.component.ts: In <add-content-providers> renamed hash to #addContentProvidersModal. 5. remove-content-providers.component.html & remove-projects.component.html & subjects-edit-form.component.html & manage-zenodo-communities.component.html: Show proper messages if no results at all or if filters return no results. 6. add-projects.component.ts: Created get method infoMessage() to return info message for missing projects | Added field selectedFunder and in getSelectedValues() return selectedFunder if no values from search query. 7. add-projects.component.html: When no projects, show info message for missing funders too | Do not show filters column when no results | Show selectedFunder in selected filters. 8. manage-projects.component.ts: In <fs-modal> renamed hash to #fsModalProjects and in <add-projects> renamed hash to #addProjects. 9. remove-projects.component.ts: Removed old Session.isLoggedIn() checks.
2022-07-11 17:48:24 +02:00
<fs-modal #fsModalProjects>
2023-10-03 09:13:04 +02:00
<add-projects *ngIf="modalIsOpen" #addProjects [community]="community"
(communityProjectsChanged)="communityProjectsChanged($event)"></add-projects>
</fs-modal>
`
})
export class ManageProjectsComponent implements OnInit {
@Input() communityProjects = [];
@ViewChild(RemoveProjectsComponent) removeProjectsComponent: RemoveProjectsComponent;
[Connect Admin | new-theme]: Updated messages when no results in affiliations, data sources, projects, subjects, zenodo communities | [Bug fix] In add projects, show selected filter if exists (even when no results). 1. affiliations.component.html: Updated "no organizations found" message to "no organizations for {{community}}". 2. add-content-providers.component.html: When no data sources, show info message for missing data sources too. 3. add-content-providers.component.ts: Created get method infoMessage() to return info message for missing data sources. 4. manage-content-providers.component.ts: In <add-content-providers> renamed hash to #addContentProvidersModal. 5. remove-content-providers.component.html & remove-projects.component.html & subjects-edit-form.component.html & manage-zenodo-communities.component.html: Show proper messages if no results at all or if filters return no results. 6. add-projects.component.ts: Created get method infoMessage() to return info message for missing projects | Added field selectedFunder and in getSelectedValues() return selectedFunder if no values from search query. 7. add-projects.component.html: When no projects, show info message for missing funders too | Do not show filters column when no results | Show selectedFunder in selected filters. 8. manage-projects.component.ts: In <fs-modal> renamed hash to #fsModalProjects and in <add-projects> renamed hash to #addProjects. 9. remove-projects.component.ts: Removed old Session.isLoggedIn() checks.
2022-07-11 17:48:24 +02:00
@ViewChild('fsModalProjects', { static: true }) fullscreen: FullScreenModalComponent;
private subscriptions: any[] = [];
public showLoadingInRemove: boolean = true;
public body: string = "Send from page";
public properties: EnvProperties = properties;
public community: CommunityInfo = null;
2023-10-03 09:13:04 +02:00
modalIsOpen = false;
constructor(private element: ElementRef,
private title: Title,
private route: ActivatedRoute, private _router: Router,
private communityService: CommunityService) {
}
ngOnInit() {
this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe(community => {
this.community = community;
if (this.community) {
this.title.setTitle(this.community.shortTitle.toUpperCase() + ' | ' + OpenaireEntities.PROJECTS);
this.body = "[Please write your message here]";
this.body = StringUtils.URIEncode(this.body);
}
}));
}
public ngOnDestroy() {
this.subscriptions.forEach(sub => {
if (sub instanceof Subscriber) {
sub.unsubscribe();
}
});
}
public openAddProjects() {
[Connect Admin | new-theme]: Updated messages when no results in affiliations, data sources, projects, subjects, zenodo communities | [Bug fix] In add projects, show selected filter if exists (even when no results). 1. affiliations.component.html: Updated "no organizations found" message to "no organizations for {{community}}". 2. add-content-providers.component.html: When no data sources, show info message for missing data sources too. 3. add-content-providers.component.ts: Created get method infoMessage() to return info message for missing data sources. 4. manage-content-providers.component.ts: In <add-content-providers> renamed hash to #addContentProvidersModal. 5. remove-content-providers.component.html & remove-projects.component.html & subjects-edit-form.component.html & manage-zenodo-communities.component.html: Show proper messages if no results at all or if filters return no results. 6. add-projects.component.ts: Created get method infoMessage() to return info message for missing projects | Added field selectedFunder and in getSelectedValues() return selectedFunder if no values from search query. 7. add-projects.component.html: When no projects, show info message for missing funders too | Do not show filters column when no results | Show selectedFunder in selected filters. 8. manage-projects.component.ts: In <fs-modal> renamed hash to #fsModalProjects and in <add-projects> renamed hash to #addProjects. 9. remove-projects.component.ts: Removed old Session.isLoggedIn() checks.
2022-07-11 17:48:24 +02:00
this.fullscreen.title = "Search and Add " + OpenaireEntities.PROJECTS;
this.fullscreen.okButtonText = "Done";
this.fullscreen.back = true;
this.fullscreen.okButton = true;
this.fullscreen.open();
2023-10-03 09:13:04 +02:00
this.modalIsOpen = true;
}
public communityProjectsChanged($event) {
/* this.communityProjects = $event.value;
this.showLoadingInRemove = false;
if (this.fullscreen.isOpen) {
this.removeProjectsComponent.applyFilters();
this.removeProjectsComponent.createFunderFilter();
}*/
this.removeProjectsComponent.getCommunityProjects();
}
}