Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | 93x 93x 93x 93x 5x 5x 5x 5x 5x 1x 1x 1x 1x 93x | import { Accessor, Datasource, DatasourceFactory } from '@zeedhi/core';
import { Input } from '../zd-input/input';
import { InputFactory } from '../zd-input/input-factory';
import { ICheckboxMultiple } from './interfaces';
/**
* Base class for Checkbox multiple component.
*/
export class CheckboxMultiple extends Input implements ICheckboxMultiple {
/**
* Quantity of columns that will be rendered on non vertical case
*/
public columns = 4;
/**
* Field on datasource.data that will be used to set checkbox's label
*/
public dataLabel = '';
/**
* Source of checkbox items
*/
public datasource: Datasource;
/**
* Field on datasource.data that will be used to set checkbox's value
*/
public dataValue = '';
/**
* Defines the checkbox list direction
*/
public vertical = true;
/**
* Defines if field value should be an object
*/
public returnObject = false;
/* istanbul ignore next */
/**
* Create a new Checkbox Multiple.
* @param props CheckBpox Multiple properties
*/
constructor(props: ICheckboxMultiple) {
super(props);
this.columns = this.getInitValue('columns', props.columns, this.columns);
this.dataLabel = this.getInitValue('dataLabel', props.dataLabel, this.dataLabel);
this.dataValue = this.getInitValue('dataValue', props.dataValue, this.dataValue);
this.vertical = this.getInitValue('vertical', props.vertical, this.vertical);
this.returnObject = this.getInitValue('returnObject', props.returnObject, this.returnObject);
if (!Accessor.isAccessorDefinition(props.value)) {
this.value = this.getInitValue('value', props.value, []);
}
if (props.datasource && props.datasource.type === 'simple') {
this.dataValue = 'value';
this.dataLabel = this.dataValue;
}
this.datasource = DatasourceFactory.factory(props.datasource);
}
public onBeforeDestroy() {
super.onBeforeDestroy();
this.datasource!.destroy();
}
onCreated() {
super.onCreated();
this.datasource?.initialize();
}
}
InputFactory.register('ZdCheckboxMultiple', CheckboxMultiple);
|