Repository: brooklyn-ui Updated Branches: refs/heads/master 4093d1fd0 -> 60ddc6213
add UI support for {required,forbidden}UnlessAnyOf, and simplify constraint messages Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/12871384 Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/12871384 Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/12871384 Branch: refs/heads/master Commit: 12871384bd5b8d72e8467609abbf2d408a8dc225 Parents: 4093d1f Author: Alex Heneveld <alex.henev...@cloudsoftcorp.com> Authored: Tue Nov 20 02:16:28 2018 +0000 Committer: Alex Heneveld <alex.henev...@cloudsoftcorp.com> Committed: Tue Nov 20 02:16:28 2018 +0000 ---------------------------------------------------------------------- .../providers/blueprint-service.provider.js | 22 ++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/12871384/ui-modules/blueprint-composer/app/components/providers/blueprint-service.provider.js ---------------------------------------------------------------------- diff --git a/ui-modules/blueprint-composer/app/components/providers/blueprint-service.provider.js b/ui-modules/blueprint-composer/app/components/providers/blueprint-service.provider.js index 0140faf..a896aac 100644 --- a/ui-modules/blueprint-composer/app/components/providers/blueprint-service.provider.js +++ b/ui-modules/blueprint-composer/app/components/providers/blueprint-service.provider.js @@ -299,6 +299,10 @@ function BlueprintService($log, $q, $sce, paletteApi, iconGenerator, dslService) } let val = (k) => entity.config.get(k || config.name); let isSet = (k) => entity.config.has(k || config.name) && angular.isDefined(val(k)); + let isAnySet = (k) => { + if (!k || !Array.isArray(k)) return false; + return k.some(isSet); + } let hasDefault = () => angular.isDefined(config.defaultValue); switch (key) { case 'Predicates.notNull()': @@ -319,22 +323,32 @@ function BlueprintService($log, $q, $sce, paletteApi, iconGenerator, dslService) break; case 'forbiddenIf': if (isSet() && isSet(args)) { - message = `<samp>${config.name}</samp> cannot be set when <samp>${args}</samp> is set`; + message = `<samp>${config.name}</samp> and <samp>${args}</samp> cannot both be set`; } break; case 'forbiddenUnless': if (isSet() && !isSet(args)) { - message = `<samp>${config.name}</samp> cannot be set unless <samp>${args}</samp> is set`; + message = `<samp>${config.name}</samp> can only be set when <samp>${args}</samp> is set`; } break; case 'requiredIf': if (!isSet() && isSet(args)) { - message = `<samp>${config.name}</samp> is required when <samp>${args}</samp> is set`; + message = `<samp>${config.name}</samp> must be set if <samp>${args}</samp> is set`; } break; case 'requiredUnless': if (!isSet() && !isSet(args)) { - message = `<samp>${config.name}</samp> is required when <samp>${args}</samp> is not set`; + message = `<samp>${config.name}</samp> or <samp>${args}</samp> is required`; + } + break; + case 'requiredUnlessAnyOf': + if (!isSet() && !isAnySet(args)) { + message = `<samp>${config.name}</samp> or one of <samp>${args}</samp> is required`; + } + break; + case 'forbiddenUnlessAnyOf': + if (isSet() && !isAnySet(args)) { + message = `<samp>${config.name}</samp> cannot be set if any of <samp>${args}</samp> are set`; } break; default: