openaire-library/claims/claim-utils/startOver.component.ts

66 lines
2.4 KiB
TypeScript
Raw Normal View History

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: `
<button (click)="confirmOpen()" class="uk-button uk-button-danger uk-align-left" > <span class="uk-icon"><svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="refresh" ratio="1"><path fill="none" stroke="#000" stroke-width="1.1" d="M17.08,11.15 C17.09,11.31 17.1,11.47 17.1,11.64 C17.1,15.53 13.94,18.69 10.05,18.69 C6.16,18.68 3,15.53 3,11.63 C3,7.74 6.16,4.58 10.05,4.58 C10.9,4.58 11.71,4.73 12.46,5"></path><polyline fill="none" stroke="#000" points="9.9 2 12.79 4.89 9.79 7.9"></polyline></svg></span> Clear All</button>
<modal-alert (alertOutput)="confirmClose($event)">
</modal-alert>
`,
})
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;
confirmOpen(){
this.alertApplyAll.cancelButton = true;
this.alertApplyAll.okButton = true;
this.alertApplyAll.alertTitle = "Remove selected";
this.alertApplyAll.message = "This action will delete every selected entity (projects, communities, research results). Do you wish to continue?";
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);
}
console.log("projects:"+this.projects.length +" contexts:"+this.contexts.length + " results:"+this.results.length );
}
}