onChangeUIReferenceMapping()

in source/web-ui/src/views/overview/Overview.tsx [456:494]


    onChangeUIReferenceMapping(event: any) {
        if (!this._isMounted) { return; }
        const checkboxTarget = event.currentTarget;
        const checkboxId = checkboxTarget.id;
        const checkboxType = checkboxId.split('-')[0];
        const checkboxValue = checkboxId.split('-')[1];

        if (checkboxType === 'line') {
            const lineKeys = this.state.newLineUIReferenceMapping;
            if (checkboxTarget.checked) {
                if (this.state.newLocationUIReferenceMapping.has(checkboxValue)) {
                    alert('This already selected as part of the Location grouping');
                    checkboxTarget.checked = false;
                } else {
                    lineKeys.add(checkboxValue);
                }
            } else {
                lineKeys.delete(checkboxValue);
            }

            lineKeys.delete('');
            this.setState({ newLineUIReferenceMapping: lineKeys });
        } else if (checkboxType === 'location') {
            const locationKeys = this.state.newLocationUIReferenceMapping;
            if (checkboxTarget.checked) {
                if (this.state.newLineUIReferenceMapping.has(checkboxValue)) {
                    alert('This already selected as part of the Line grouping');
                    checkboxTarget.checked = false;
                } else {
                    locationKeys.add(checkboxValue);
                }
            } else {
                locationKeys.delete(checkboxValue);
            }

            locationKeys.delete('');
            this.setState({ newLocationUIReferenceMapping: locationKeys });
        }
    }