import {Component, Input, Output, EventEmitter, ViewChild} from '@angular/core';
import {ClaimResult} from '../claim-utils/claimEntities.class';
import {AlertModal} from '../../utils/modal/alert';
@Component({
selector: 'start-over',
template: `
0)?'pointer;':'not-allowed;')" [style.cursor]="((results.length + projects.length + contexts.length > 0)?'pointer':'not-allowed')">
`,
})
export class StartOverComponent {
constructor () {
}
ngOnInit() {
}
// @Input() public inlineEntity = null;
@Input() public type:string;
@Input() public linkTo:string;
@Input() public results;
@Input() public projects;
@Input() public contexts;
@ViewChild(AlertModal) alertApplyAll;
@Input() localStoragePrefix:string = "";
confirmOpen(){
if(this.projects.length + this.results.length + this.contexts.length == 0 ){
return;
}
this.alertApplyAll.cancelButton = true;
this.alertApplyAll.okButton = true;
this.alertApplyAll.alertTitle = "Remove selected";
this.alertApplyAll.message = "Do you want to remove selected entities (projects, communities, research results)?";
this.alertApplyAll.okButtonText = "Yes";
this.alertApplyAll.cancelButtonText = "No";
this.alertApplyAll.open();
}
confirmClose(data){
this.startOver();
}
startOver(){
if(this.type != null && this.linkTo != null){
console.log("inline");
if(this.linkTo == "project"){
this.projects.splice(0, this.projects.length);
}else if(this.linkTo == "context"){
this.contexts.splice(0, this.contexts.length);
}else if(this.linkTo == "result"){
this.results.splice(0, this.results.length);
}
}else{
console.log("generic");
this.results.splice(0, this.results.length);
this.projects.splice(0, this.projects.length);
this.contexts.splice(0, this.contexts.length);
}
localStorage.removeItem(this.localStoragePrefix + "projects");
localStorage.removeItem(this.localStoragePrefix + "contexts");
localStorage.removeItem(this.localStoragePrefix + "results");
console.log("projects:"+this.projects.length +" contexts:"+this.contexts.length + " results:"+this.results.length );
}
}