+
+
+
-
-
-
-
-
{{selectedCommunityLabel}} community is now in your Links Basket
+
{{selectedCommunityLabel}}
Loading communities information...
An error occured while loading communities...
-
-
0 ">
- Optionally, you can specify additional Community's paths to link your sources.
-
+
0 ">
+ Optionally, you can specify additional Community's paths to link your
+ sources.
+
- No aditional community paths found for this community.
+ class=" uk-text-small uk-text-muted">
+ No additional community paths found for this community.
+
+
diff --git a/claims/claim-utils/claimContextSearchForm.component.ts b/claims/claim-utils/claimContextSearchForm.component.ts
index 620879e8..f6088264 100644
--- a/claims/claim-utils/claimContextSearchForm.component.ts
+++ b/claims/claim-utils/claimContextSearchForm.component.ts
@@ -1,4 +1,4 @@
-import {Component, Input} from '@angular/core';
+import {Component, Input, ViewChild} from '@angular/core';
import {Router} from '@angular/router';
import {ContextsService} from './service/contexts.service';
import {ClaimEntity, ShowOptions} from './claimHelper.class';
@@ -7,6 +7,8 @@ import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
import {EnvProperties} from '../../utils/properties/env-properties';
import {Subscriber} from "rxjs";
import {OpenaireEntities} from "../../utils/properties/searchFields";
+import {CommunityService} from "../../connect/community/community.service";
+import {CommunitiesService} from "../../connect/communities/communities.service";
declare var UIkit: any;
@@ -23,7 +25,8 @@ export class ClaimContextSearchFormComponent {
@Input() public inlineClaim: boolean = false;
@Input() basketLimit;
@Input() showOptions:ShowOptions;
-
+ @ViewChild('modal') modal;
+ modalClicked = false;
public selectedCommunityId: string = "0";
public selectedCategoryId: string = "0";
public query = '';
@@ -44,9 +47,27 @@ export class ClaimContextSearchFormComponent {
entitiesSelectOptions;
keyword = "";
subscriptions = [];
+ communityLogos = {};
ngOnInit() {
this.entitiesSelectOptions = this.showOptions.selectOptions;
- this.getCommunities();
+ //get community logos
+ this.subscriptions.push(this._communitiesService.getCommunities(this.properties, this.properties.communityAPI+"/communities/").subscribe(
+ communitiesResults => {
+ if(communitiesResults!=null) {
+ this.communityLogos = {};
+ for (let community of communitiesResults) {
+ if(community.logoUrl && community.logoUrl.length > 0) {
+ this.communityLogos[community.communityId] = community;
+ }
+ }
+ this.getCommunities();
+ }
+ },
+ error => {
+ this.getCommunities();
+ }
+ ));
+
}
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
@@ -55,36 +76,64 @@ export class ClaimContextSearchFormComponent {
}
});
}
- constructor(private _contextService: ContextsService, private router: Router) {
+ constructor(private _contextService: ContextsService, private router: Router, private _communitiesService: CommunitiesService) {
}
- getCommunityClass(community) {
- let addclass = "";
- if (this.isSelected(community.id)) {
- addclass += " contextlabelSelected ";
- } else {
- addclass += " contextlabelNotSelected ";
- }
- if (this.keyword.length > 0) {
- if (community.label.toLowerCase().indexOf(this.keyword.toLowerCase()) == -1) {
- addclass += " fadeOut "
- }
- }
- return addclass + 'uk-label';
+ filter() {
+ return this.communities?this.communities.filter(community => this.keyword.length ==0 || community.label.toLowerCase().indexOf(this.keyword.toLowerCase()) != -1):[];
}
-
- select(community) {
+ remove(community: any) {
this.selectedCommunityId = community.id;
this.selectedCommunityLabel = community.label;
this.getCategories();
- if (this.isSelected(community.id)) {
+ this.removeById(community.id);
+ this.openModal();
+ }
+ removeById(id) {
+ let index: number = -1;
+ for (let _i = 0; _i < this.results.length; _i++) {
+ let item = this.results[_i];
+ if (item.id == id) {
+ index = _i;
+ }
+ }
+
+ if (index > -1) {
+ this.results.splice(index, 1);
+ if (this.results != null) {
+ localStorage.setItem(this.localStoragePrefix, JSON.stringify(this.results));
+ }
+ UIkit.notification(OpenaireEntities.COMMUNITY + ' removed from your basket!', {
+ status: 'warning',
+ timeout: 4000,
+ pos: 'bottom-right'
+ });
+ }
+
+ }
+ select(communityId, communityLabel) {
+ console.log("SELECT", communityId)
+ this.selectedCommunityId = communityId;
+ this.selectedCommunityLabel = communityLabel;
+ this.getCategories();
+ if (this.isSelected(communityId)) {
} else {
- this.addNewContext(community.label, null, {'id': community.id, 'label': community.label});
+ this.addNewContext(communityLabel, null, {'id': communityId, 'label': communityLabel});
}
+ this.openModal()
}
+ public openModal() {
+ this.modalClicked = true;
+ this.modal.cancelButton = false;
+ this.modal.okButton = false;
+ this.modal.alertTitle = this.selectedCommunityLabel;
+ this.modal.open();
+ }
+
+
isSelected(id): boolean {
for (let _i = 0; _i < this.results.length; _i++) {
let item = this.results[_i];
@@ -95,26 +144,24 @@ export class ClaimContextSearchFormComponent {
}
return false;
}
-
- addNewContext(community, category, concept, notify = true) {
- // if (this.results.length > 50) {
- // UIkit.notification({
- // message: 'Your basket exceeds the number of allowed concepts (50)',
- // status: 'warning',
- // timeout: 1500,
- // pos: 'top-center'
- // });
- // return;
- // }
+ getClaimEntity(community, category, concept){
const entity: ClaimEntity = new ClaimEntity() ;
entity.type = "community";
-
entity.context = {community: community, category: category, concept: concept};
entity.id = entity.context.concept.id;
+ return entity;
+ }
+ addNewContext(community, category, concept, notify = true) {
+ const entity: ClaimEntity = this.getClaimEntity(community, category, concept) ;
this.warningMessage = "";
if (!this.isSelected(entity.id)) {
this.results.push(entity);
localStorage.setItem(this.localStoragePrefix, JSON.stringify(this.results));
+ UIkit.notification(OpenaireEntities.COMMUNITY + ' added in your basket!', {
+ status: 'success',
+ timeout: 4000,
+ pos: 'bottom-right'
+ });
}
}
@@ -128,6 +175,7 @@ export class ClaimContextSearchFormComponent {
this.subscriptions.push(this._contextService.getPublicCommunitiesByState().subscribe(
data => {
this.communities = data;
+ console.log(this.communities)
if (this.communities.length > 0) {
this.communities.sort((n1, n2) => n1.label > n2.label);
}
@@ -191,77 +239,7 @@ export class ClaimContextSearchFormComponent {
}
}
}
- /*
- getConcepts() {
- this.loading = true;
- if (this.selectedCategoryId != '0') {
- if (!Session.isLoggedIn()) {
- this.saveStateAndRedirectLogin();
- } else {
- this.concepts = [];
-
- this._contextService.getConcepts(this.selectedCategoryId, "", true, this.properties.contextsAPI).subscribe(
- data => {
-
- this.concepts = data;
- for (var i = 0; i < data.length; i++) {
- if (data[i].hasSubConcept == true) {
- this.getSubConcepts(data[i].id);
- }
- }
- this.addCommunityInConcepts();
- if (this.query !== "") {
- var event = {value: ""};
- event.value = this.query;
- // this.filter(event);
- }
- this.loading = false;
- },
- err => {
- //console.log(err);
- this.handleError("Error getting concepts for category with id: " + this.selectedCategoryId, err);
- this.loading = false;
- }
- );
- }
- } else {
- this.concepts = [];
- this.loading = false;
- }
- }*/
- /*
- getSubConcepts(conceptId) {
- this.loading = true;
- if (this.selectedCategoryId != '0') {
- if (!Session.isLoggedIn()) {
- this.saveStateAndRedirectLogin();
- } else {
- this._contextService.getSubConcepts(conceptId, "", true, this.properties.contextsAPI).subscribe(
- data => {
- for (var i = 0; i < data.length; i++) {
- this.concepts.push(data[i]);
- }
-
- if (this.query !== "") {
- var event = {value: ""};
- event.value = this.query;
- // this.filter(event);
- }
- this.loading = false;
- },
- err => {
- //console.log(err);
- this.handleError("Error getting subconcepts for concept with id: " + conceptId, err);
- this.loading = false;
- }
- );
- }
- } else {
- this.concepts = [];
- this.loading = false;
- }
- }*/
-
+
displaySubcategory(id) {
if (this.conceptsClassDisplay[id] != null) {
this.conceptsClassDisplay[id] = !this.conceptsClassDisplay[id];
@@ -325,44 +303,9 @@ export class ClaimContextSearchFormComponent {
}
- // communityChanged(){
- // this.warningMessage = "";
- // this.infoMessage = "";
- // for(var i = 0; i< this.communities.length; i++){
- // if(this.communities[i].id==this.selectedCommunityId){
- // this.selectedCommunityLabel = this.communities[i].label;
- // break;
- // }
- // }
- // this.selectedCategoryId = "0";
- // this.selectedCategoryLabel="Select Category:";
- // if(this.selectedCommunityId != "0"){
- // this.getCategories();
- // }
- // }
- // categoryChanged(){
- // this.warningMessage = "";
- // this.infoMessage = "";
- // for(var i = 0; i< this.categories.length; i++){
- // if(this.categories[i].id==this.selectedCategoryId){
- // this.selectedCategoryLabel = this.categories[i].label;
- // break;
- // }
- // }
- // this.getConcepts();
- // }
- /* addCommunityInConcepts() {
- this.concepts.push({"id": this.selectedCommunityId, "label": this.selectedCommunityLabel});
- // if(this.autocomplete){
- // this.autocomplete.updateList(this.concepts);
- // }
- }*/
saveStateAndRedirectLogin() {
- // if(this.projects != null){
- // localStorage.setItem(this.localStoragePrefix + "projects", JSON.stringify(this.projects));
- // }
- // localStorage.setItem(this.localStoragePrefix + "contexts", JSON.stringify(this.selectedList));
+
if (this.results != null) {
localStorage.setItem(this.localStoragePrefix + "results", JSON.stringify(this.results));
}
diff --git a/claims/claim-utils/claimContextSearchForm.module.ts b/claims/claim-utils/claimContextSearchForm.module.ts
index 2b32cd17..1f1276ec 100644
--- a/claims/claim-utils/claimContextSearchForm.module.ts
+++ b/claims/claim-utils/claimContextSearchForm.module.ts
@@ -8,14 +8,19 @@ import { ClaimContextSearchFormComponent } from './claimContextSearchForm.compon
import {ClaimProjectsSearchFormModule} from "./claimProjectSearchForm.module";
import {AdvancedSearchInputModule} from "../../sharedComponents/advanced-search-input/advanced-search-input.module";
import {InputModule} from "../../sharedComponents/input/input.module";
+import {CommunitiesService} from "../../connect/communities/communities.service";
+import {LogoUrlPipeModule} from "../../utils/pipes/logoUrlPipe.module";
+import {IconsModule} from "../../utils/icons/icons.module";
+import {AlertModalModule} from "../../utils/modal/alertModal.module";
@NgModule({
imports: [
SharedModule, RouterModule,
StaticAutocompleteModule,
- HelperModule, ClaimProjectsSearchFormModule, AdvancedSearchInputModule, InputModule
+ HelperModule, ClaimProjectsSearchFormModule, AdvancedSearchInputModule, InputModule, LogoUrlPipeModule, IconsModule, AlertModalModule
],
+ providers: [CommunitiesService],
declarations: [
ClaimContextSearchFormComponent
], exports: [ClaimContextSearchFormComponent ]
diff --git a/claims/claim-utils/claimProjectSearchForm.component.html b/claims/claim-utils/claimProjectSearchForm.component.html
index 8cce8ca6..2bcb9e4d 100644
--- a/claims/claim-utils/claimProjectSearchForm.component.html
+++ b/claims/claim-utils/claimProjectSearchForm.component.html
@@ -6,7 +6,7 @@