How to use the @amalto/helpers.addValToArrayNoDup function in @amalto/helpers

To help you get started, we’ve selected a few @amalto/helpers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github amalto / platform6-ui-components / components / checkboxes-input / index.tsx View on Github external
private handleChange = ( event: any ) => {

        const { input } = this.props

        const selectedValues = input.value ? input.value.filter( ( item: string ) => !!item ) : []

        if ( event.target.checked ) {
            input.onChange( addValToArrayNoDup( selectedValues, event.target.value ), undefined, undefined )
        }
        else {
            input.onChange( removeValFromArrayNoDup( selectedValues, event.target.value ), undefined, undefined )
        }
    }
github amalto / platform6-ui-components / components / multi-select-input / index.tsx View on Github external
private handleChoiceSelect = ( field: WrappedFieldProps, currentSelection: string[], choice: string, cmdOrCtrlKeyOn?: boolean ) => {

        const newSelection: string[] = currentSelection.indexOf( choice ) !== -1
            ? removeValFromArrayNoDup( currentSelection as string[], choice )
            : addValToArrayNoDup( currentSelection as string[], choice )

        this.props.handleChange( {
            target: {
                value: currentSelection.indexOf( choice ) !== -1
                    ? removeValFromArrayNoDup( currentSelection as string[], choice )
                    : addValToArrayNoDup( currentSelection as string[], choice ),
                name: this.props.name
            }
        } )

        if ( cmdOrCtrlKeyOn && this.dropdownCtn ) {
            $( this.dropdownCtn ).removeClass( 'open' ).addClass( 'open' )
        } else {
            $( event.currentTarget ).scrollTop( 0 )
        }
github amalto / platform6-ui-components / components / multi-select-input / index.tsx View on Github external
private handleChoiceSelect = ( field: WrappedFieldProps, currentSelection: string[], choice: string, cmdOrCtrlKeyOn?: boolean ) => {

        const newSelection: string[] = currentSelection.indexOf( choice ) !== -1
            ? removeValFromArrayNoDup( currentSelection as string[], choice )
            : addValToArrayNoDup( currentSelection as string[], choice )

        this.props.handleChange( {
            target: {
                value: currentSelection.indexOf( choice ) !== -1
                    ? removeValFromArrayNoDup( currentSelection as string[], choice )
                    : addValToArrayNoDup( currentSelection as string[], choice ),
                name: this.props.name
            }
        } )

        if ( cmdOrCtrlKeyOn && this.dropdownCtn ) {
            $( this.dropdownCtn ).removeClass( 'open' ).addClass( 'open' )
        } else {
            $( event.currentTarget ).scrollTop( 0 )
        }

        field.input.onChange( newSelection.join( ',' ), undefined, undefined )
    }