Revision 56714
Added by Argiro Kokogiannaki almost 5 years ago
linkingGeneric.component.ts | ||
---|---|---|
1 |
import {Component, Input} from '@angular/core'; |
|
2 |
import {ActivatedRoute, Router} from '@angular/router'; |
|
3 |
import {Title, Meta} from '@angular/platform-browser'; |
|
4 |
import {Observable} from 'rxjs'; |
|
1 |
import {Component, Input, ViewChild} from '@angular/core'; |
|
2 |
import {ActivatedRoute, Router} from '@angular/router'; |
|
3 |
import {Meta, Title} from '@angular/platform-browser'; |
|
4 |
import {EnvProperties} from '../../utils/properties/env-properties'; |
|
5 |
import {ClaimEntity, ShowOptions} from '../claim-utils/claimHelper.class'; |
|
6 |
import {EntitiesSearchService} from '../../utils/entitiesAutoComplete/entitySearch.service'; |
|
7 |
import {SearchPublicationsService} from '../../services/searchPublications.service'; |
|
8 |
import {SearchDatasetsService} from '../../services/searchDatasets.service'; |
|
9 |
import {SEOService} from '../../sharedComponents/SEO/SEO.service'; |
|
10 |
import {AlertModal} from "../../utils/modal/alert"; |
|
11 |
import {HelperFunctions} from "../../utils/HelperFunctions.class"; |
|
5 | 12 |
|
6 |
import {EnvProperties} from '../../utils/properties/env-properties'; |
|
7 |
|
|
8 |
import {ClaimProject, ClaimResult} from '../claim-utils/claimEntities.class'; |
|
9 |
|
|
10 |
import {EntitiesSearchService} from '../../utils/entitiesAutoComplete/entitySearch.service'; |
|
11 |
import {SearchPublicationsService} from '../../services/searchPublications.service'; |
|
12 |
import {SearchDatasetsService} from '../../services/searchDatasets.service'; |
|
13 |
import { SEOService } from '../../sharedComponents/SEO/SEO.service'; |
|
14 |
|
|
15 | 13 |
declare var UIkit:any; |
16 | 14 |
|
17 | 15 |
@Component({ |
... | ... | |
20 | 18 |
|
21 | 19 |
}) |
22 | 20 |
export class LinkingGenericComponent { |
23 |
|
|
24 |
@Input() bulkMode: boolean = false; |
|
25 | 21 |
@Input() communityId:string= null; |
26 | 22 |
sourceType:string; |
27 | 23 |
targetType:string; |
28 | 24 |
step:number = 1; |
29 |
contexts=[]; |
|
30 |
projects=[]; |
|
31 |
results = []; |
|
32 |
show = "project"; |
|
33 |
date='8-6-2016'; |
|
34 |
keyword: string = ""; |
|
35 |
linkType:string ="project"; // link type (selected in home page) : project, context, software, etc |
|
36 |
/* url Parameters for inline linking */ |
|
37 |
id:string = null; //entity id |
|
38 |
type:string = null; // entity type (publication or research data) |
|
39 |
linkTo:string = null; // entity type (project or context or result) |
|
25 |
@Input() results:ClaimEntity[] = []; |
|
26 |
@Input() inlineEntity:ClaimEntity = null; |
|
40 | 27 |
|
41 |
entityTypes=["dataset", "publication", "project","context"]; |
|
42 |
inlineResult:ClaimResult =null; |
|
28 |
@Input() showOptions:ShowOptions = new ShowOptions(); |
|
29 |
//show values: source, result, project, context, claim |
|
30 |
// linkTo /values: result, project, context |
|
31 |
// show linkToEntities /values: result, project, context |
|
32 |
|
|
33 |
@Input() sources:ClaimEntity[] =[]; |
|
43 | 34 |
sub:any =null; |
44 | 35 |
properties:EnvProperties; |
45 |
localStoragePrefix:string = "linking_"; |
|
36 |
@Input() localStoragePrefix:string = "linking_";
|
|
46 | 37 |
url=null; |
38 |
@ViewChild(AlertModal) alert; |
|
47 | 39 |
|
40 |
|
|
41 |
|
|
48 | 42 |
constructor (private _router: Router, private route: ActivatedRoute, private entitySearch:EntitiesSearchService, |
49 | 43 |
private publicationsSearch:SearchPublicationsService, private datasetsSearch:SearchDatasetsService, |
50 | 44 |
private _meta: Meta, private _title: Title, |
51 | 45 |
private seoService: SEOService ) { |
52 | 46 |
|
53 |
var title = "OpenAIRE | Linking";
|
|
47 |
let title = "OpenAIRE | Linking";
|
|
54 | 48 |
this._meta.updateTag({content:title},"property='og:title'"); |
55 | 49 |
this._title.setTitle(title); |
56 | 50 |
|
57 | 51 |
|
58 | 52 |
} |
59 | 53 |
ngOnInit() { |
54 |
this.showOptions.show = 'source'; |
|
55 |
if(this.inlineEntity){ |
|
56 |
this.showOptions.basketShowSources = false; |
|
57 |
this.showOptions.basketShowLinksTo = true; |
|
58 |
this.showOptions.show = this.showOptions.linkTo; |
|
59 |
} |
|
60 | 60 |
this.route.data |
61 | 61 |
.subscribe((data: { envSpecific: EnvProperties }) => { |
62 | 62 |
this.properties = data.envSpecific; |
... | ... | |
65 | 65 |
|
66 | 66 |
}); |
67 | 67 |
if( typeof localStorage !== 'undefined') { |
68 |
if(localStorage.getItem(this.localStoragePrefix + "projects")){ |
|
69 |
this.projects = JSON.parse(localStorage.getItem(this.localStoragePrefix + "projects")); |
|
70 |
|
|
71 |
} |
|
72 |
if(localStorage.getItem(this.localStoragePrefix + "contexts")){ |
|
73 |
this.contexts = JSON.parse(localStorage.getItem(this.localStoragePrefix + "contexts")); |
|
74 |
} |
|
68 |
this.localStoragePrefix +=(this.communityId?this.communityId+"_":""); |
|
75 | 69 |
if(localStorage.getItem(this.localStoragePrefix + "results")){ |
76 | 70 |
this.results = JSON.parse(localStorage.getItem(this.localStoragePrefix + "results")); |
71 |
} |
|
77 | 72 |
|
73 |
if(localStorage.getItem(this.localStoragePrefix + "sources")){ |
|
74 |
this.sources = JSON.parse(localStorage.getItem(this.localStoragePrefix + "sources")); |
|
78 | 75 |
} |
79 | 76 |
} |
80 | 77 |
} |
81 | 78 |
|
82 |
next(){ |
|
79 |
openSelectionModal() { |
|
80 |
this.alert.cancelButton = false; |
|
81 |
this.alert.okButton = false; |
|
82 |
this.alert.alertTitle = "Select the type of Entity to Link to your sources"; |
|
83 |
// this.alert.message = "<div>All the links you provided will be published in the OpenAIRE platform. " + |
|
84 |
// "<br>Make sure you have checked all the information you provided. In some cases some links take more time to be published. " + |
|
85 |
// "<br>For more information please check the linking status in My-Links page. " + |
|
86 |
// "<br><br>Do you confirm the information you provide are valid?</div>"; |
|
83 | 87 |
|
84 |
if((this.show == 'result' && this.keyword == '')||(this.show == 'dataset' || this.show == 'publication')){ |
|
85 |
this.show='claim'; |
|
86 |
|
|
87 |
} |
|
88 |
this.alert.open(); |
|
88 | 89 |
} |
89 |
prev(){ |
|
90 |
if(this.show == 'claim'){ |
|
91 |
this.show='result'; |
|
92 |
} |
|
93 |
} |
|
94 | 90 |
|
95 |
|
|
96 |
resultsChange($event) { |
|
97 |
this.results=$event.value; |
|
98 |
} |
|
99 |
|
|
100 |
projectsChange($event) { |
|
101 |
this.projects=$event.value; |
|
102 |
} |
|
103 |
|
|
104 |
linkTypeChange($event) { |
|
105 |
|
|
106 |
this.linkType =$event.value; |
|
107 |
this.show="result"; |
|
108 |
if(this.bulkMode){ |
|
109 |
this.show="claim"; |
|
91 |
closeSelectionModal(show:string=null) { |
|
92 |
if(show){ |
|
93 |
this.showOptions.show = show; |
|
94 |
this.showOptions.basketShowSources=false; |
|
95 |
this.showOptions.basketShowLinksTo=true; |
|
110 | 96 |
} |
111 |
} |
|
97 |
this.alert.cancel(); |
|
98 |
this.scrollUp(); |
|
112 | 99 |
|
113 |
showChange($event) { |
|
114 |
this.show=$event.value; |
|
115 |
this.showChangedType($event.value); |
|
116 | 100 |
} |
101 |
scrollUp(){ |
|
102 |
HelperFunctions.scroll(); |
|
117 | 103 |
|
118 |
showChangedType(type:string) { |
|
119 |
this.show=type; |
|
120 |
if(this.show == 'project' || this.show == 'context' || this.show == 'software'){ |
|
121 |
this.linkType = this.show; |
|
122 |
} |
|
123 | 104 |
} |
124 |
|
|
125 |
canProceedToMetadata(){ |
|
126 |
if(this.results.length == 0){ |
|
127 |
|
|
128 |
UIkit.notification({ |
|
129 |
message : 'No research results selected!<br>Please select research results to link with projects and/ or ommunities.', |
|
130 |
status : 'warning', |
|
131 |
timeout : 1000, |
|
132 |
pos : 'top-center' |
|
133 |
}); |
|
134 |
}else{ |
|
135 |
this.show = 'claim'; |
|
136 |
this.step = 3; |
|
137 |
} |
|
138 |
} |
|
139 | 105 |
} |
Also available in: Unified diff
[Library|Trunk]
Merging branch newlinking into Trunk 55132:56708