diff --git a/src/app/components/editor/database/columns/columns.component.html b/src/app/components/editor/database/columns/columns.component.html index 3fb61b0..4f04302 100644 --- a/src/app/components/editor/database/columns/columns.component.html +++ b/src/app/components/editor/database/columns/columns.component.html @@ -84,6 +84,7 @@ True/False Yes/No 1/0 + Checkbox diff --git a/src/app/components/editor/database/renderers/boolean-renderer.component.ts b/src/app/components/editor/database/renderers/boolean-renderer.component.ts index 9189fdf..dd5bd75 100644 --- a/src/app/components/editor/database/renderers/boolean-renderer.component.ts +++ b/src/app/components/editor/database/renderers/boolean-renderer.component.ts @@ -1,24 +1,44 @@ 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 }}`, + template: ` + {{ display }} +
+ +
+ `, + styles: [` + :host { + width: 100%; + height: 100%; + display: inline-block; + } + `], }) export class BooleanRendererComponent implements ICellRendererAngularComp { public params: ICellRendererParams; public emptyValue = ''; public trueValue = 'True'; public falseValue = 'False'; + public checkbox = false; + + public checked = 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]; + this.checkbox = params.colDef.additionalData.labelType === 'checkbox'; + + if ( !this.checkbox ) { + // @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() { @@ -34,4 +54,10 @@ export class BooleanRendererComponent implements ICellRendererAngularComp { refresh(params: any): boolean { return false; } + + onChecked($event) { + const checked = !this.params.value; + const colId = this.params.column.getColId(); + this.params.node.setDataValue(colId, checked); + } }