imports/vx/client/code/ux.js
/**
     * Save all of information that the user has entered into the database.
     *
     * @param {object} form Form to save.
     * @param {function} callback Optional callback.
     * @param {boolean} nomessage True to suppress "saved successfully" message.
     * @param {function} userCallback Optional user callback for extra functions on successful save.
     */
Save all of information that the user has entered into the database.
@param {object} form Form to save.
@param {function} callback Optional callback.
@param {boolean} nomessage True to suppress "saved successfully" message.
@param {function} userCallback Optional user callback for extra functions on successful save.
Save all of information that the user has entered into the database . @param { object } form Form to save . @param { function } callback Optional callback . @param { boolean } nomessage True to suppress " saved successfully " message . @param { function } userCallback Optional user callback for extra functions on successful save .
saveForm(form, callback, nomessage, userCallback) {
        if (form.props.updateHandler) {
            form.props.updateHandler((error, result) => {
                UX.saveFormAlertAndCallback(error, result, callback, nomessage, userCallback)
                return
            })
            return
        }
        const modifier = UX.makeModifier(form)
        OLog.debug(`ux.js saveForm update ${form.props.collection._name} _id=${form.props._id} modifier=${OLog.debugString(modifier)}`)
        form.props.collection.update(form.props._id, modifier, (error, result) => {
            let suppressCallback = false
            if (error) {
                UX.saveFormAlertAndCallback(error, result, callback, nomessage, userCallback)
                return
            }
            _.each(form.components, (component) => {
                if (component.props.updateHandler) {
                    UX.updateDatabase(component)
                    return
                }
                if (component.constructor.displayName === "VXImage") {
                    suppressCallback = true
                    UX.updateImage(component, () => {
                        UX.saveFormAlertAndCallback(null, { success : true }, callback, nomessage, userCallback)
                    })
                }
            })
            if (!suppressCallback) {
                UX.saveFormAlertAndCallback(null, { success : true }, callback, nomessage, userCallback)
            }
        })
        return
    }
saveForm ( form , callback , nomessage , userCallback ) { if ( form . props . updateHandler ) { form . props . updateHandler ( ( error , result ) => { UX . saveFormAlertAndCallback ( error , result , callback , nomessage , userCallback ) return } ) return } const modifier = UX . makeModifier ( form ) OLog . debug ( ` ${ form . props . collection . _name } ${ form . props . _id } ${ OLog . debugString ( modifier ) } ` ) form . props . collection . update ( form . props . _id , modifier , ( error , result ) => { let suppressCallback = false if ( error ) { UX . saveFormAlertAndCallback ( error , result , callback , nomessage , userCallback ) return } _ . each ( form . components , ( component ) => { if ( component . props . updateHandler ) { UX . updateDatabase ( component ) return } if ( component . constructor . displayName === "VXImage" ) { suppressCallback = true UX . updateImage ( component , ( ) => { UX . saveFormAlertAndCallback ( null , { success : true } , callback , nomessage , userCallback ) } ) } } ) if ( ! suppressCallback ) { UX . saveFormAlertAndCallback ( null , { success : true } , callback , nomessage , userCallback ) } } ) return }
Save all of information that the user has entered into the database.
Save all of information that the user has entered into the database .
// If the form has a custom update handler, use it: // Run custom update handlers: