imports/vx/both/code/util.js
/**
     * Return the list of authorized preference definitions filtered by available role.
     *
     * @param {object} user User to test.
     * @return {array} Array of preference definition objects.
     */
Return the list of authorized preference definitions filtered by available role.
@param {object} user User to test.
@return {array} Array of preference definition objects.
Return the list of authorized preference definitions filtered by available role . @param { object } user User to test . @return { array } Array of preference definition objects .
makePreferenceDefinitionObjects(user) {
        let preferenceDefinitions = []
        for (let preferenceDefinition in Meteor.i18nMessages.codes.preferenceDefinition) {
            let preferenceDefinitionValue = Meteor.i18nMessages.codes.preferenceDefinition[preferenceDefinition]
            if (preferenceDefinitionValue.roles) {
                let roleFound
                preferenceDefinitionValue.roles.every(roleName => {
                    if (Util.isUserRole(user._id, roleName)) {
                        roleFound = true
                        return false
                    }
                    return true
                })
                if (!roleFound) {
                    continue
                }
            }
            let preferenceDefinitionObject = {}
            preferenceDefinitionObject.preferenceDefinition = preferenceDefinition
            preferenceDefinitionObject.description = Util.i18n("codes.preferenceDefinition." + preferenceDefinition)
            preferenceDefinitions.push(preferenceDefinitionObject)
        }
        return preferenceDefinitions
    }
makePreferenceDefinitionObjects ( user ) { let preferenceDefinitions = [ ] for ( let preferenceDefinition in Meteor . i18nMessages . codes . preferenceDefinition ) { let preferenceDefinitionValue = Meteor . i18nMessages . codes . preferenceDefinition [ preferenceDefinition ] if ( preferenceDefinitionValue . roles ) { let roleFound preferenceDefinitionValue . roles . every ( roleName => { if ( Util . isUserRole ( user . _id , roleName ) ) { roleFound = true return false } return true } ) if ( ! roleFound ) { continue } } let preferenceDefinitionObject = { } preferenceDefinitionObject . preferenceDefinition = preferenceDefinition preferenceDefinitionObject . description = Util . i18n ( "codes.preferenceDefinition." + preferenceDefinition ) preferenceDefinitions . push ( preferenceDefinitionObject ) } return preferenceDefinitions }
Return the list of authorized preference definitions filtered by available role.
Return the list of authorized preference definitions filtered by available role .