frontend/src/app/components/editor/database/renderers/boolean-renderer.component.ts

38 lines
1.1 KiB
TypeScript
Raw Normal View History

import {ICellRendererAngularComp} from 'ag-grid-angular';
import {Component} from '@angular/core';
import {ICellRendererParams} from 'ag-grid-community';
import * as moment from 'moment';
@Component({
selector: 'editor-boolean-renderer',
template: `{{ display }}`,
})
export class BooleanRendererComponent implements ICellRendererAngularComp {
public params: ICellRendererParams;
public emptyValue = '';
public trueValue = 'True';
public falseValue = 'False';
agInit(params: ICellRendererParams): void {
this.params = params;
// @ts-ignore
const labelType = params.colDef.additionalData.labelType.split('_').map(x => x.charAt(0).toUpperCase() + x.slice(1));
this.trueValue = labelType[0];
this.falseValue = labelType[1];
}
public get display() {
if ( this.params.value === true ) {
return this.trueValue;
} else if ( this.params.value === false ) {
return this.falseValue;
} else {
return this.emptyValue;
}
}
refresh(params: any): boolean {
return false;
}
}