summaryrefslogtreecommitdiffstats
path: root/sdc-workflow-designer-ui/src/app/paletx/core/boolean-field-value.ts
blob: dc1f86e244b99cb2e7089235fff4bb1026d6d020 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* tslint:disable:array-type member-access variable-name */
function booleanFieldValueFactory() {
  return function booleanFieldValueMetadata(target: any, key: string): void {
	const defaultValue = target[key];
	const localKey = `__ky_private_symbol_${key}`;
	target[localKey] = defaultValue;

	Object.defineProperty(target, key, {
		get() {
		return (this)[localKey];
		},
		set(value: boolean) {
		(this)[localKey] = value !== null && `${value}` !== 'false';
		}
	});
  };
}

export {booleanFieldValueFactory as BooleanFieldValue};