From 762b1fec329a20553d265fd5bb5715e1a7e04c3d Mon Sep 17 00:00:00 2001 From: Avior Date: Thu, 5 Dec 2019 09:54:00 +0100 Subject: [PATCH] Added new input ! Signed-off-by: Avior --- src/modules/CheckboxInput.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/modules/CheckboxInput.ts diff --git a/src/modules/CheckboxInput.ts b/src/modules/CheckboxInput.ts new file mode 100644 index 0000000..4128ba8 --- /dev/null +++ b/src/modules/CheckboxInput.ts @@ -0,0 +1,30 @@ +import InputIdentity from './Interfaces/InputIdentity'; +import DefaultInput from './DefaultInput'; +import { toBoolean } from '../Functions'; + +/** + * + * @class FMDateInput + * @extends {FMInput} + */ +export default class CheckboxInput extends DefaultInput { + + public setValue(value: any) { + this.element.checked = this.formatValue(value) + } + public getValue(): boolean { + return this.element.checked + } + public formatValue(value: any): boolean { + value = toBoolean(value) + if (typeof value === "undefined") { + return false + } + return value + } + + public static identity: InputIdentity = { + input: CheckboxInput, + type: "checkbox" + } +}