tbouron commented on a change in pull request #129: UI for defining parameters
URL: https://github.com/apache/brooklyn-ui/pull/129#discussion_r270353756
##########
File path:
ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.directive.js
##########
@@ -654,48 +792,61 @@ export function specEditorDirective($rootScope,
$templateCache, $injector, $sani
return [];
}
let filteredConfig =
$filter('specEditorConfig')(scope.model.miscData.get('config'),
scope.state.config.filter.values, scope.model);
- return scope.model.miscData.get('config').map((config)=> {
+ return scope.model.miscData.get('config').map((config) => {
config.isHidden =
scope.model.miscData.get('config').indexOf(config) > -1 ?
filteredConfig.indexOf(config) === -1 : false;
return config;
});
}
+ specEditor.getConfig = getConfig;
+ function getConfig(name) {
+ return scope.model.miscData.get('config').find(p => p.name ===
name);
+ }
+
function loadCustomConfigWidgetMetadata(model) {
- var customConfigWidgets =
(scope.model.miscData.get('ui-composer-hints') || {})['config-widgets'] || [];
- customConfigWidgets.forEach( (wd) => {
- var keys = wd.keys || [ wd.key ];
- keys.forEach( (k) => {
- scope.state.config.customConfigWidgetMetadata[k] =
angular.extend({ enabled: true },
scope.state.config.customConfigWidgetMetadata[k], wd);
+ let customConfigWidgets =
(scope.model.miscData.get('ui-composer-hints') || {})['config-widgets'] || [];
+ customConfigWidgets.forEach((wd) => {
+ let keys = wd.keys || [wd.key];
+ keys.forEach((k) => {
+ scope.state.config.customConfigWidgetMetadata[k] =
angular.extend({enabled: true},
scope.state.config.customConfigWidgetMetadata[k], wd);
});
});
}
- /* config state for each item is stored in multiple places:
- * * scope.config = map of values used/set by editor (strings, map of
strings, json code if using code mode, etc);
- * this should be suitable for ng-model to work with, so e.g. if
using code mode we need to put JSON.stringify value in here,
- * and note any change here immediately (on next digest) updates
scope.model.config, which e.g. in code mode
- * will JSON.parse
- * * scope.model.config = map of values used in internal model
- * * scope.model.miscData.get('config') = list of config keys with
their metadata, including derived widgetMode
- * * scope.state.config.{codeModeActive,dslManualOverride} = maps of
booleans where edit modes are set and remembered for configs
+ /**
+ * The configuration data for each item is stored in multiple places:
+ *
+ * scope.config
+ * A map of values used/set by editor, which can be strings, a map
of strings, the JSON representation of the
+ * object if using code mode, etc. This should be suitable for
ng-model to work with, so e.g. if using code
+ * mode we need to put JSON.stringify value in here, and note any
change here immediately (on next digest)
+ * updates scope.model.config, which e.g. in code mode will
JSON.parse
+ *
+ * scope.model.config
+ * A map of values used in internal model
+ *
+ * scope.model.miscData.get('config')
+ * A list of config keys with their metadata, including derived
widgetMode
+ *
+ * scope.state.config.{codeModeActive,dslManualOverride}
+ * Maps of booleans where edit modes are set and remembered for
configs
*/
function loadLocalConfigFromModel() {
- let map = scope.model.config;
+ let modelConfig = scope.model.config;
let result = {};
- for (let [key, value] of map) {
+ for (let [key, value] of modelConfig) {
if (blueprintService.isReservedKey(key)) {
- // skip
- continue;
+ $log.warn("skipping reserved word used as config key",
key);
+ continue; // skip
}
-
result[key] = getLocalConfigValueFromModelValue(key, value);
}
scope.config = result;
}
function getLocalConfigValueFromModelValue(key, value) {
- if (!specEditor.defined(value) || value==null) {
+ if (!specEditor.defined(value) || value == null) {
Review comment:
```suggestion
if (!specEditor.defined(value) || value === null) {
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services