<commit_before>import './gennyBucketView.scss';
import React, { PureComponent } from 'react';
import { BaseEntityQuery, GennyBridge } from 'utils/genny';
import { bool } from 'prop-types';
import { IconSmall, BucketView, Card } from 'views/components';
import { Draggable } from 'react-beautiful-dnd';
import { LayoutLoader } from 'utils/genny/layout-loader';

class GennyBucketView extends PureComponent {

    static defaultProps = {
        allowItemClick: true,
    }

    static propTypes = {
        allowItemClick: bool
    };

    state = {
    }

    constructor(props) {
        super(props);
    }

    didMoveItem = (item, source, destination) => {

        if(item.draggableId && source.droppableId) {

            let begs = BaseEntityQuery.getEntityChildren(source.droppableId);
            if(begs.length > 0) {

                let movedBeg = begs.filter(x => x.code == item.draggableId)[0];
                let loads = movedBeg ? movedBeg.children : null;
                if(loads && loads.length > 0) {

                    let movedLoad = loads[0];
                    let loadCode = movedLoad.code;
                    let linkCode = movedBeg.linkCode;
                    let data_event = {
                        sourceBaseEntityCode: source.droppableId,
                        targetBaseEntityCode: destination.droppableId,
                        linkCode: linkCode,
                        data: {
                            code: item.draggableId,
                            value: loadCode,
                        }
                    };

                    GennyBridge.sendBucketDropEvent(data_event);
                }
            }
        }
    }

    addNewItem = (selectedColumn) => {

        let { root } = this.props;
        let rootGroups = BaseEntityQuery.getEntityChildren(root);
        for (var i = 0; i < rootGroups.length; i++) {
            let group = rootGroups[i];
            if(group.code == selectedColumn) {

                let itemValue = group.attributes["ADD_ITEM"].value;
                let data = {
                    code: group.code,
                    value: itemValue,
                }
                GennyBridge.sendBtnClick("BTN_CLICK", data);
                break;
            }
        }
    }

    handleClick = (bucketItemProps) => {
        let btnValue = {
            hint: bucketItemProps.rootCode,
            itemCode: bucketItemProps.description,
            userCode: GennyBridge.getUser()
        };

        btnValue = JSON.stringify(btnValue);

        GennyBridge.sendBtnClick('BTN_CLICK', {
            code: 'SELECT_EVENT',
            value: btnValue
        });

        this.setState({
            selectedItemState: bucketItemProps.code,
        });

        if (this.props.onClick) this.props.onClick();
    }

    generateBucket(group) {

        let groupCode = group.code;
        let children = [];<commit_msg>added prop to allow bucket card click<commit_after>import './gennyBucketView.scss';
import React, { PureComponent } from 'react';
import { BaseEntityQuery, GennyBridge } from 'utils/genny';
import { bool } from 'prop-types';
import { IconSmall, BucketView, Card } from 'views/components';
import { Draggable } from 'react-beautiful-dnd';
import { LayoutLoader } from 'utils/genny/layout-loader';

class GennyBucketView extends PureComponent {

    static defaultProps = {
        allowItemClick: false,
    }

    static propTypes = {
        allowItemClick: bool
    };

    state = {
    }

    constructor(props) {
        super(props);
    }

    didMoveItem = (item, source, destination) => {

        if(item.draggableId && source.droppableId) {

            let begs = BaseEntityQuery.getEntityChildren(source.droppableId);
            if(begs.length > 0) {

                let movedBeg = begs.filter(x => x.code == item.draggableId)[0];
                let loads = movedBeg ? movedBeg.children : null;
                if(loads && loads.length > 0) {

                    let movedLoad = loads[0];
                    let loadCode = movedLoad.code;
                    let linkCode = movedBeg.linkCode;
                    let data_event = {
                        sourceBaseEntityCode: source.droppableId,
                        targetBaseEntityCode: destination.droppableId,
                        linkCode: linkCode,
                        data: {
                            code: item.draggableId,
                            value: loadCode,
                        }
                    };

                    GennyBridge.sendBucketDropEvent(data_event);
                }
            }
        }
    }

    addNewItem = (selectedColumn) => {

        let { root } = this.props;
        let rootGroups = BaseEntityQuery.getEntityChildren(root);
        for (var i = 0; i < rootGroups.length; i++) {
            let group = rootGroups[i];
            if(group.code == selectedColumn) {

                let itemValue = group.attributes["ADD_ITEM"].value;
                let data = {
                    code: group.code,
                    value: itemValue,
                }
                GennyBridge.sendBtnClick("BTN_CLICK", data);
                break;
            }
        }
    }

    handleClick = (bucketItemProps) => {
        if (this.props.allowItemClick) {
            let btnValue = {
                hint: bucketItemProps.rootCode,
                itemCode: bucketItemProps.description,
                userCode: GennyBridge.getUser()
            };
    
            btnValue = JSON.stringify(btnValue);
    
            GennyBridge.sendBtnClick('BTN_CLICK', {
                code: 'SELECT_EVENT',
                value: btnValue
            });
    
            this.setState({
                selectedItemState: bucketItemProps.code,
            });
    
            if (this.props.onClick) this.props.onClick();
        }
    }

    generateBucket(group) {

        let groupCode = group.code;
        let children = [];
{'fraction_non_alphanumeric': 0.09869521579123453, 'fraction_numerical': 0.0016728002676480427, 'mean_word_length': 1.5027208036835495, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2276808', 'n_tokens_mistral': 1663, 'n_tokens_neox': 1556, 'n_words': 314}