imports/vx/both/code/util.js
/**
     * Create an object consisting of the default values for parameter fields.
     *
     * @param {string} reportType Report type.
     * @param {?} userOrId User record or ID.
     * @return {object} Report default parameters object or undefined if no parameters.
     */
Create an object consisting of the default values for parameter fields.
@param {string} reportType Report type.
@param {?} userOrId User record or ID.
@return {object} Report default parameters object or undefined if no parameters.
Create an object consisting of the default values for parameter fields . @param { string } reportType Report type . @param { ? } userOrId User record or ID . @return { object } Report default parameters object or undefined if no parameters .
reportParameterDefaults(reportType, userOrId) {
        let reportParameterDefinitions = Util.reportParameterDefinitions(reportType)
        if (!reportParameterDefinitions) {
            return
        }
        let user = Util.user(userOrId)
        let timezone = Util.reportTimezone(reportType, user)
        let reportParameterDefaults = {}
        _.each(reportParameterDefinitions, (reportParameterDefinition) => {
            switch (reportParameterDefinition.type) {
            case "DATE" : {
                switch (reportParameterDefinition.default) {
                case "START_OF_MONTH" : {
                    reportParameterDefaults[reportParameterDefinition.fieldName] = moment().tz(timezone).startOf("month").toDate()
                    break
                }
                case "END_OF_MONTH" : {
                    reportParameterDefaults[reportParameterDefinition.fieldName] = moment().tz(timezone).endOf("month").toDate()
                    break
                }
                }
            }
            }
        })
        return reportParameterDefaults
    }
reportParameterDefaults ( reportType , userOrId ) { let reportParameterDefinitions = Util . reportParameterDefinitions ( reportType ) if ( ! reportParameterDefinitions ) { return } let user = Util . user ( userOrId ) let timezone = Util . reportTimezone ( reportType , user ) let reportParameterDefaults = { } _ . each ( reportParameterDefinitions , ( reportParameterDefinition ) => { switch ( reportParameterDefinition . type ) { case "DATE" : { switch ( reportParameterDefinition . default ) { case "START_OF_MONTH" : { reportParameterDefaults [ reportParameterDefinition . fieldName ] = moment ( ) . tz ( timezone ) . startOf ( "month" ) . toDate ( ) break } case "END_OF_MONTH" : { reportParameterDefaults [ reportParameterDefinition . fieldName ] = moment ( ) . tz ( timezone ) . endOf ( "month" ) . toDate ( ) break } } } } } ) return reportParameterDefaults }
Create an object consisting of the default values for parameter fields.
Create an object consisting of the default values for parameter fields .