How to use the @dhis2/d2-ui-core.Action.create function in @dhis2/d2-ui-core

To help you get started, we’ve selected a few @dhis2/d2-ui-core 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 dhis2 / d2-ui / packages / expression-manager / src / ExpressionManager.js View on Github external
setInstance(this.props.d2)

        this.i18n = this.props.d2.i18n;

        this.i18n.strings.add('description');
        this.i18n.strings.add('program_tracked_entity_attributes');
        this.i18n.strings.add('program_indicators');
        this.i18n.strings.add('program_data_elements');
        this.i18n.strings.add('field_is_required');
        this.i18n.strings.add('organisation_unit_counts'); // shorten to org_unit_counts in maintenance
        this.i18n.strings.add('reporting_rates');
        this.i18n.strings.add('data_elements');
        this.i18n.strings.add('constants');
        this.i18n.strings.add('programs');

        this.requestExpressionStatusAction = Action.create('requestExpressionStatus');
    }
github dhis2 / d2-ui / packages / legend / src / LegendItem.actions.js View on Github external
import { Action } from '@dhis2/d2-ui-core';
import { setDialogStateTo } from './LegendItem.store';

export const setDialogStateToAction = Action.create('setDialogStateToAction'); // name in debug

setDialogStateToAction.subscribe(action => setDialogStateTo(action.data));
github dhis2 / d2-ui / packages / header-bar / src / search / search.stores.js View on Github external
...searchResult,
                    searchResults: appsMenuItems,
                };
            }

            return searchResult;
        },
    )
    .map(resultState => ({
        ...resultState,
        searchResults: resultState.searchResults
            .map((item, index) => Object.assign({}, item, { selected: resultState.selected === index })),
        open: Boolean(resultState.isSearchFieldFocused),
    }));

export const handleKeyPress = Action.create();
const keyPress$ = handleKeyPress
    .map(action => action.data);


// Handle an enter key press to go the location of the first item
keyPress$
    .filter(([event]) => event.keyCode === 13 || event.key === 'Enter')
    .flatMap(() => searchResultBoxStateStore$.take(1))
    // Find the selected menu item in the search results list by the `selected` index
    .map(state => state.searchResults.find((item, index) => index === state.selected))
    .filter(identity)
    .subscribe(
        itemToGoTo => window.location = itemToGoTo.action,
        log.error,
    );
github dhis2 / d2-ui / packages / header-bar / src / search / search.stores.js View on Github external
return;
    }

    searchResultBoxStateStore$.setState({
        ...searchResultBoxStateStore$.getState(),
        selected: searchResultBoxStateStore$.getState().selected + selected,
    });
}

export function hideWhenNotHovering() {
    if (searchResultBoxStateStore$.getState() && !searchResultBoxStateStore$.getState().isHoveringOverResults) {
        setSearchFieldFocusTo(false);
    }
}

export const search = Action.create('Search Apps');
search
    .map(action => action.data || '')
    .subscribe(setSearchValue);

const searchSourceStore$ = headerBarStore$
    .map(headerBarState => [].concat(headerBarState.appItems, headerBarState.profileItems))
    .flatMap(addDeepLinksForMaintenance)
    .flatMap(addDeepLinksForSettings);

export const searchStore$ = Observable
    .combineLatest(
        searchResultBoxStateStore$,
        appsMenuItems$,
        (searchResult, appsMenuItems) => {
            if (!searchResult.searchValue) {
                return {