You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2018/11/20 21:45:55 UTC
[1/2] brooklyn-ui git commit: fix json editor state
Repository: brooklyn-ui
Updated Branches:
refs/heads/master a9fcd5276 -> 13c56f078
fix json editor state
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/8a82585b
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/8a82585b
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/8a82585b
Branch: refs/heads/master
Commit: 8a82585bcf4a402f6b935aca351880dd65819ead
Parents: 4093d1f
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Tue Nov 20 13:35:07 2018 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Tue Nov 20 13:35:07 2018 +0000
----------------------------------------------------------------------
.../spec-editor/spec-editor.directive.js | 23 +++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/8a82585b/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.directive.js
----------------------------------------------------------------------
diff --git a/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.directive.js b/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.directive.js
index 9c18129..ecfa249 100644
--- a/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.directive.js
+++ b/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.directive.js
@@ -699,7 +699,24 @@ export function specEditorDirective($rootScope, $templateCache, $injector, $sani
// errors don't get stringified because model value was not parsed
return value;
}
- return JSON.stringify(value);
+ // if current local value gives same result then don't change it
+ // (don't interrupt user's flow, and respect their spacing, at least until
+ // they click away; ultimately we would like access to the parse tree,
+ // so we could take the text as entered exactly (maybe stripping initial whitespace),
+ // also supporting yaml and comments, but that is a bigger task!)
+ if (scope.config && typeof scope.config[key] === 'string') {
+ try {
+ if (JSON.stringify(JSON.parse(scope.config[key]))===JSON.stringify(value)) {
+ return scope.config[key];
+ }
+ } catch (ignoredError) {
+ console.log("Couldn't handle entered JSON", scope.config[key], ignoredError);
+ }
+ }
+ // otherwise pretty print it, so they get decent multiline on first load and
+ // if they click off the entity then back on to the entity and this field
+ // (we'd like to respect what they actually typed but that needs the parse tree, as above)
+ return JSON.stringify(value, null, " ");
}
// else treat as value, with array/map special
@@ -737,8 +754,8 @@ export function specEditorDirective($rootScope, $templateCache, $injector, $sani
scope.state.config.codeModeActive[key] = true;
// and the widget mode updated to be 'manual'
scope.getConfigWidgetMode(definition, value);
-
- return JSON.stringify(value);
+ // and rerun this method so we get it prettified if appropriate
+ return getLocalConfigValueFromModelValue(key, value);
}
// if boolean, return as primitive type
[2/2] brooklyn-ui git commit: This closes #111
Posted by al...@apache.org.
This closes #111
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/13c56f07
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/13c56f07
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/13c56f07
Branch: refs/heads/master
Commit: 13c56f078e599734ba50312e55ff452e083bb259
Parents: a9fcd52 8a82585
Author: Aled Sage <al...@gmail.com>
Authored: Tue Nov 20 21:45:43 2018 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Nov 20 21:45:43 2018 +0000
----------------------------------------------------------------------
.../spec-editor/spec-editor.directive.js | 23 +++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------