import {Component, Input, Output, EventEmitter, ViewChild} from '@angular/core';
import {AlertModal} from '../../utils/modal/alert';
@Component({
selector: 'start-over',
template: `
Remove '+message+''" aria-expanded="false" class="uk-width-small" [style]="'cursor: '+ ((results.length > 0)?'pointer;':'not-allowed;')" [style.cursor]="((results.length> 0)?'pointer':'not-allowed')">
Remove all
`,
})
export class StartOverComponent {
constructor () {
}
ngOnInit() {
}
@Input() public type:string;
@Input() public linkTo:string;
@Input() public results;
@Input() public message = "selected entities";
@ViewChild(AlertModal) alertApplyAll;
@Input() localStoragePrefix:string = "";
confirmOpen(){
if( this.results.length == 0 ){
return;
}
this.alertApplyAll.cancelButton = true;
this.alertApplyAll.okButton = true;
this.alertApplyAll.alertTitle = "Remove entities";
this.alertApplyAll.message = "Do you want to remove " + this.message + "?";
this.alertApplyAll.okButtonText = "Yes";
this.alertApplyAll.cancelButtonText = "No";
this.alertApplyAll.open();
this.alertApplyAll.okButtonLeft = false;
}
confirmClose(data){
this.startOver();
}
startOver(){
if(this.type != null && this.linkTo != null){
//console.log("inline");
//TODO
// 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 == "entity"){
// this.results.splice(0, this.results.length);
// }
}else{
this.results.splice(0, this.results.length);
}
localStorage.removeItem(this.localStoragePrefix);
}
}