Fixing insert claims for direct linking| isRouteEnable checks for community also in parameters, if no community avaiable load the page normally
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51198 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
abc97c5abc
commit
3200554a1d
|
@ -113,8 +113,9 @@
|
|||
<claim-selected-results *ngIf=" linkTo =='result' " title= "Selected Research Results" [results]="results" [bulkMode]=false showSearch = false showAccessRights = true>
|
||||
</claim-selected-results>
|
||||
<div class="uk-width-1-1 uk-margin-small-top">
|
||||
<claim-insert class="uk-float-right" [contexts]="contexts" [results]="results" [projects]="projects" [inlineEntity] = "inlineResult" [show] = "show"
|
||||
(showChange)="showChange($event)" [(properties)]=properties></claim-insert>
|
||||
<claim-insert class="uk-float-right" [contexts]="contexts" [results]="results" [projects]="projects" [inlineEntity] = inlineResult [show] = "show"
|
||||
[(properties)]=properties></claim-insert>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<ul *ngIf="linkTo == 'result'" class="uk-pagination">
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {Component, Input, Output, EventEmitter, ViewChild} from '@angular/core';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {Router} from '@angular/router';
|
||||
import {Router, ActivatedRoute} from '@angular/router';
|
||||
import {ClaimsService} from '../../claim-utils/service/claims.service';
|
||||
|
||||
import {ModalLoading} from '../../../utils/modal/loading.component';
|
||||
|
@ -29,12 +29,15 @@ import{EnvProperties} from '../../../utils/properties/env-properties';
|
|||
`
|
||||
})
|
||||
export class ClaimInsertComponent {
|
||||
constructor (private claimService: ClaimsService, private _router:Router) {}
|
||||
constructor (private claimService: ClaimsService, private _router:Router, private route: ActivatedRoute,) {}
|
||||
ngOnInit() {
|
||||
this.route.queryParams.subscribe(params => {
|
||||
this.params = params;
|
||||
});
|
||||
// console.info("Inlineentity:" +(this.inlineEntity)?this.inlineEntity+(this.inlineEntity.id)?this.inlineEntity.id:"no id":"null"+ + " show "+ (!this.claiming && this.showButton) );
|
||||
}
|
||||
|
||||
|
||||
params= {};
|
||||
@Input() public contexts;
|
||||
@Input() public projects;
|
||||
@Input() public results;
|
||||
|
@ -67,7 +70,7 @@ public validateInsertions(){
|
|||
return true;
|
||||
}
|
||||
}
|
||||
return
|
||||
return false;
|
||||
}
|
||||
private insertActions(){
|
||||
this.servicesRespond = 0;
|
||||
|
@ -92,7 +95,7 @@ private insertActions(){
|
|||
this.loading.open();
|
||||
var claims = [];
|
||||
var directclaims = [];
|
||||
if(this.results){
|
||||
if(this.results ){
|
||||
console.info("results: "+this.results.length);
|
||||
|
||||
for (var i = 0; i < this.results.length; i++) {
|
||||
|
@ -121,6 +124,23 @@ private insertActions(){
|
|||
|
||||
}
|
||||
}
|
||||
if(this.inlineEntity ){
|
||||
|
||||
if(this.contexts){
|
||||
for (var j = 0; j < this.contexts.length; j++) {
|
||||
var context = this.contexts[j];
|
||||
var claim = this.createContextClaim(this.inlineEntity, context, user);
|
||||
claims.push(claim);
|
||||
}
|
||||
}
|
||||
if(this.projects){
|
||||
for (var k = 0; k < this.projects.length; k++) {
|
||||
var project = this.projects[k];
|
||||
var projectClaim = this.createProjectClaim(this.inlineEntity, project, user);
|
||||
claims.push(projectClaim);
|
||||
}
|
||||
}
|
||||
}
|
||||
//first call direct index service - when call is done (success or error) call isertBulkClaims method to insert claims in DB
|
||||
console.info("\n\ndirectclaims: "+directclaims.length+"\n\n");
|
||||
if(directclaims.length > 0){
|
||||
|
@ -227,7 +247,7 @@ private afterclaimsInsertion(){
|
|||
|
||||
if(this.errorInClaims.length == 0 && this.insertedClaims.length > 0 && this.errorInRecords.length == 0){
|
||||
|
||||
this._router.navigate( ['/myclaims'] );
|
||||
this._router.navigate( ['/myclaims'],{ queryParams: this.params } );
|
||||
this.showChange.emit({
|
||||
value: this.show
|
||||
});
|
||||
|
@ -277,7 +297,9 @@ private errorsInClaimsInsertion(){
|
|||
}
|
||||
|
||||
|
||||
private createClaim(inlineResult:any, result:any, user:any){
|
||||
|
||||
}
|
||||
private createContextClaim(result:any, context:any, user:any){
|
||||
var claim = { claimedBy : user, sourceId : context.concept.id, sourceType : "context", sourceCollectedFrom:"openaire", sourceAccessRights:"OPEN", sourceEmbargoEndDate:"no", targetId : result.id , targetType : result.type, targetCollectedFrom: result.source, targetAccessRights:result.accessRights, targetEmbargoEndDate: (result.embargoEndDate == null?"":result.embargoEndDate)};
|
||||
return claim;
|
||||
|
|
|
@ -11,18 +11,21 @@ export class IsRouteEnabled implements CanActivate {
|
|||
constructor(private route: ActivatedRoute,private router: Router, private config: ConfigurationService) {}
|
||||
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
|
||||
|
||||
|
||||
let customRedirect = route.data['redirect'];
|
||||
let api = route.data['api'];
|
||||
let community = route.data['community']
|
||||
console.log("In IsRouteEnabled");
|
||||
console.log(state.url.split("?")[0].substring(1));
|
||||
let isEnabled = this.config.isPageEnabled(api, community,"/"+state.url.split("?")[0].substring(1));
|
||||
let redirect = !!customRedirect ? customRedirect : '/error';
|
||||
isEnabled.filter(enabled => !enabled)
|
||||
.subscribe(() => this.router.navigate([redirect], { queryParams: { "page": state.url } }));
|
||||
|
||||
return isEnabled;
|
||||
if(!community){
|
||||
community = (route.queryParams["communityId"])?route.queryParams["communityId"]:route.queryParams["community"];
|
||||
}
|
||||
if(community){
|
||||
let isEnabled = this.config.isPageEnabled(api, community,"/"+state.url.split("?")[0].substring(1));
|
||||
let redirect = !!customRedirect ? customRedirect : '/error';
|
||||
|
||||
isEnabled.filter(enabled => !enabled)
|
||||
.subscribe(() => this.router.navigate([redirect], { queryParams: { "page": state.url } }));
|
||||
return isEnabled;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue