

export class BooleanFilterHelper {
    public FILTER_NONE: string = 'none';
    public FILTER_TRUE: string = 'true';
    public FILTER_FALSE: string = 'false';

    private FILTER_NAMES: Array<string> = ['No Filter', 'Yes', 'No'];
    private FILTER_ICONS: Array<string> = ['digi-filter', 'digi-valid', 'digi-cross'];
    public FILTER_VALUES: Array<string> = [this.FILTER_NONE, this.FILTER_TRUE, this.FILTER_FALSE];

    public setFilterNames(filterNames: Array<string>): void {
        this.FILTER_NAMES = filterNames;
    }

    public getFilterName(filterIndex: number): string {
        return this.FILTER_NAMES[filterIndex];
    }

    public getFilterNone() {
        return this.FILTER_NONE;
    }

    public setFilterIcons(filterIcons: Array<string>) {
        this.FILTER_ICONS = filterIcons;
    }

    public getFilterIcon(iconIndex: number) {
        return this.FILTER_ICONS[iconIndex];
    }

    public getFilterValue(valueIndex: number): string {
        return this.FILTER_VALUES[valueIndex];
    }

    public getFilterValueIndex(filterValue: string): number {
        return this.FILTER_VALUES.findIndex(x => x == filterValue);
    }

    public setupContentGui(groupName: string): string {
        return `
      <div class="floating-filter__body__boolean">
        <ui-radio name="${groupName}" model.one-time="1" checked.bind="selectedIndex"><span>${this.FILTER_NAMES[1]}</span></ui-radio>
        <ui-radio name="${groupName}" model.one-time="2" checked.bind="selectedIndex"><span>${this.FILTER_NAMES[2]}</span></ui-radio>
      </div>`;
    }

    public getValue(selectedIndex: number): boolean {
        if (this.FILTER_VALUES[selectedIndex] == this.FILTER_TRUE) {
            return true;
        }
        else if (this.FILTER_VALUES[selectedIndex] == this.FILTER_FALSE) {
            return false;
        }
        return null;
    }

    public getModelAsString?(selectedIndex: number): string {
        return this.FILTER_NAMES[selectedIndex];
    }

    public setupContentGuiSideFilter(): string {
        return `
        <div class="col s12 m12 l12">
        <ui-field class="filter-segmented-control" label.bind="params.colDef.headerName">
            <ui-segmented-control name.bind="groupName">
            <ui-segmented-option model.one-time="1" checked.bind="selectedIndex" t="[label]common:general.yes">
            </ui-segmented-option>
            <ui-segmented-option model.one-time="2" checked.bind="selectedIndex" t="[label]common:general.no">
            </ui-segmented-option>
            </ui-segmented-control>
        </ui-field>
        </div>`;
    }
}