imports/vx/both/code/util.js
/**
     * Return an array of all users with the specified role suitable for populating a <select> list.
     *
     * @param {string} roleName Role name (e.g., MANAGER).
     * @param {string} chosenUserId User ID chosen.
     * @return {array} Array of users bearing given role (prepared for <select>).
     */
Return an array of all users with the specified role suitable for populating a  list.
@param {string} roleName Role name .
@param {string} chosenUserId User ID chosen.
@return {array} Array of users bearing given role (prepared for ).
Return an array of all users with the specified role suitable for populating a list . @param { string } roleName Role name . @param { string } chosenUserId User ID chosen . @return { array } Array of users bearing given role ( prepared for ) .
fetchUsersByRole(roleName, chosenUserId) {
        let criteria = {}
        criteria["profile.dateRetired"] = { $exists: false }
        if (Util.isTenantRole(roleName)) {
            criteria["profile.domains"] = { $elemMatch: { domainId : { $in: Util.getDomainIdsOfCurrentTenant() } } }
        }
        else {
            criteria["profile.domains"] = { $elemMatch: { domainId : Util.getCurrentDomainId(Meteor.userId()) } }
        }
        let userArray = []
        Meteor.users.find(criteria).forEach(user => {
            if (Util.isUserRole(user._id, roleName)) {
                let fullName = Util.fetchFullName(user._id)
                let selected = (user._id === chosenUserId)
                userArray.push( { userId : user._id, lastName: user.profile.lastName, fullName : fullName, selected : selected } )
            }
        })
        userArray.sort((userA, userB) => {
            return Util.safeCompare(userA.fullName, userB.fullName)
        })
        return userArray
    }
fetchUsersByRole ( roleName , chosenUserId ) { let criteria = { } criteria [ "profile.dateRetired" ] = { $exists : false } if ( Util . isTenantRole ( roleName ) ) { criteria [ "profile.domains" ] = { $elemMatch : { domainId : { $in : Util . getDomainIdsOfCurrentTenant ( ) } } } } else { criteria [ "profile.domains" ] = { $elemMatch : { domainId : Util . getCurrentDomainId ( Meteor . userId ( ) ) } } } let userArray = [ ] Meteor . users . find ( criteria ) . forEach ( user => { if ( Util . isUserRole ( user . _id , roleName ) ) { let fullName = Util . fetchFullName ( user . _id ) let selected = ( user . _id === chosenUserId ) userArray . push ( { userId : user . _id , lastName : user . profile . lastName , fullName : fullName , selected : selected } ) } } ) userArray . sort ( ( userA , userB ) => { return Util . safeCompare ( userA . fullName , userB . fullName ) } ) return userArray }
Return an array of all users with the specified role suitable for populating a <select> list.
Return an array of all users with the specified role suitable for populating a <select > list .