How to use the @dhis2/d2-ui-core.withPropsFromObservable 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 / OrganisationUnitGroupSelector.js View on Github external
import { getAllObjectsWithFields } from './data-helpers';

const organisationUnitGroupSelectorProps$ = Observable.fromPromise(getAllObjectsWithFields('organisationUnitGroup'))
    .map(organisationUnitGroups => ({
        source: organisationUnitGroups.map(model => ({ value: model.id, label: model.displayName })),
        onItemDoubleClick(value) {
            const ougFormula = ['OUG{', value, '}'].join('');

            // `this` is the react component props object
            if (isFunction(this.onSelect)) {
                this.onSelect(ougFormula);
            }
        },
    }));

export default withPropsFromObservable(organisationUnitGroupSelectorProps$, ListSelectWithLocalSearch);
github dhis2 / d2-ui / packages / expression-manager / src / ConstantSelector.js View on Github external
import { getAllObjectsWithFields } from './data-helpers';

const constantSelectorProps$ = Observable.fromPromise(getAllObjectsWithFields('constant'))
    .map(constants => ({
        source: constants.map(model => ({ value: model.id, label: model.displayName })),
        onItemDoubleClick(value) {
            const constFormula = ['C{', value, '}'].join('');

            // `this` is the react component props object
            if (isFunction(this.onSelect)) {
                this.onSelect(constFormula);
            }
        },
    }));

export default withPropsFromObservable(constantSelectorProps$, ListSelectWithLocalSearch);