All files / src/fieldcontrols/CheckboxGroup CheckboxGroup.tsx

29.63% Statements 8/27
0% Branches 0/14
12.5% Functions 1/8
24% Lines 6/25
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 78 79 80 81 82 83 84 85 86 87        1x                                   1x                         1x                     1x                                           1x                                   1x
/**
 * @module FieldControls
 * 
 */ /** */
import * as React from 'react'
import { FieldSettings } from 'sn-client-js'
import { IClientFieldSetting, IReactClientFieldSetting } from '../IClientFieldSetting'
import { IChoiceFieldSetting } from '../IChoiceFieldSetting'
 
import { Input } from 'react-materialize'
import { styles } from './CheckboxGroupStyles'
 
/**
 * Interface for CheckboxGroup properties
 */
export interface CheckboxGroupProps extends IReactClientFieldSetting, IClientFieldSetting, IChoiceFieldSetting { 
    onChange: Function
}
 
/**
 * Field control that represents a Choice field. Available values will be populated from the FieldSettings.
 */
export class CheckboxGroup extends React.Component<CheckboxGroupProps, {}> {
    /**
     * constructor
     * @param {object} props
     */
    constructor(props) {
        super(props);
        this.state = {
        };
    }
    /**
     * returns selected options value
     */
    getSelectedValue() {
        this.props.options.map(function (option) {
            if (option.Selected) {
                return option.Value
            }
        })
    }
    /**
     * returns selected options text by its value
     * @param {any} value
     */
    getTextByValue(value) {
        let text = '';
        if (value) {
            this.props.options.map(function (option) {
                if (option.Value === value.toString()) {
                    text = option.Text
                }
            })
        }
        else {
            this.props.options.map(function (option) {
            if (option.Selected) {
                text = option.Text
            }
        })
        }
        return text;
    }
    /**
     * render
     * @return {ReactElement} markup
     */
    render() {
        switch (this.props['data-actionName']) {
            case 'edit':
                return (
                    <span>under consctruction</span>
                )
            case 'new':
                return (
                    <span>under consctruction</span>
                )
            case 'browse':
                return (
                    <span>under consctruction</span>
                )
            default:
                break;
        }
    }
}