How to use the enketo-core/src/js/preload.init function in enketo-core

To help you get started, we’ve selected a few enketo-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 kobotoolbox / enketo-express / public / js / src / enketo-webform-view.js View on Github external
instanceId: settings.instanceId
};

// Completely disable calculations in Enketo Core
import calcModule from 'enketo-core/src/js/calculate';
calcModule.update = () => {
    console.log( 'Calculations disabled.' );
};
// Completely disable instanceID and deprecatedID population in Enketo Core
import { FormModel } from 'enketo-core/src/js/form-model';
FormModel.prototype.setInstanceIdAndDeprecatedId = () => {
    console.log( 'InstanceID and deprecatedID population disabled.' );
};
// Completely disable preload items
import preloadModule from 'enketo-core/src/js/preload';
preloadModule.init = () => {
    console.log( 'Preloaders disabled.' );
};

initTranslator( survey )
    .then( survey => connection.getFormParts( survey ) )
    .then( formParts => {
        if ( survey.instanceId ) {
            return connection.getExistingInstance( survey )
                .then( response => {
                    formParts.instance = response.instance;
                    formParts.instanceAttachments = response.instanceAttachments;
                    return formParts;
                } );
        }
        return formParts;
    } )