Files
Superalgos/Projects/Governance/UI/Utilities/Validations.js
T
2021-07-15 11:41:56 +02:00

23 lines
729 B
JavaScript

function newGovernanceUtilitiesValidations () {
let thisObject = {
onlyOneProgram: onlyOneProgram
}
return thisObject
function onlyOneProgram(userProfile, programNodeType) {
/*
Find all the nodes representing the current program.
*/
let programs = UI.projects.foundations.utilities.branches.nodeBranchToArray(userProfile, programNodeType)
if (programs !== undefined) {
if (programs.length > 1) {
userProfile.payload.uiObject.setErrorMessage('Only one ' + programNodeType + ' is allowed.')
return
}
if (programs.length === 1) {
return programs[0]
}
}
}
}