You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2018/09/13 16:21:49 UTC

[2/5] brooklyn-ui git commit: custom widgets should not copy scope values from parent

custom widgets should not copy scope values from parent

but rather reference them explicitly.  copying scope means if the parent changes that var, which it does e.g. for `config`, the child's scope value becomes disconnected.


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/cd2ac803
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/cd2ac803
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/cd2ac803

Branch: refs/heads/master
Commit: cd2ac803f1fab71505b7400f86e9de630ba48314
Parents: 0afa7e7
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Thu Sep 13 11:48:27 2018 +0100
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Thu Sep 13 11:48:27 2018 +0100

----------------------------------------------------------------------
 .../custom-config-widget/suggestion-dropdown.html   | 16 +++++++++-------
 .../custom-config-widget/suggestion-dropdown.js     |  2 +-
 .../components/spec-editor/spec-editor.directive.js |  8 --------
 3 files changed, 10 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/cd2ac803/ui-modules/blueprint-composer/app/components/custom-config-widget/suggestion-dropdown.html
----------------------------------------------------------------------
diff --git a/ui-modules/blueprint-composer/app/components/custom-config-widget/suggestion-dropdown.html b/ui-modules/blueprint-composer/app/components/custom-config-widget/suggestion-dropdown.html
index 82ecfea..6c4a807 100644
--- a/ui-modules/blueprint-composer/app/components/custom-config-widget/suggestion-dropdown.html
+++ b/ui-modules/blueprint-composer/app/components/custom-config-widget/suggestion-dropdown.html
@@ -30,30 +30,32 @@
     <span class="label-rhs-buttons">
         <span class="spacer"> </span>
         <span class="custom-widget-enable-button custom-widget-active">
-            <i class="fa fa-fw fa-sun-o" ng-click="toggleCustomConfigWidgetMode(item, false)" aria-hidden="true" title="{{getCustomConfigWidgetModeTitle(item)}} [{{item.name}}]"></i>
-            <span class="sr-only">{{getCustomConfigWidgetModeTitle(item)}} [{{item.name}}]</span>
+            <i class="fa fa-fw fa-sun-o" ng-click="specEditor.toggleCustomConfigWidgetMode(item, false)" aria-hidden="true" title="{{specEditor.getCustomConfigWidgetModeTitle(item)}} [{{item.name}}]"></i>
+            <span class="sr-only">{{specEditor.getCustomConfigWidgetModeTitle(item)}} [{{item.name}}]</span>
         </span>
     </span>
 
-    <div class="control-value" ng-class="{ 'inline-control': item.widgetMode==='boolean', 'unset': !defined(config[item.name]), 'has-default': defined(item.defaultValue) && item.defaultValue!=null }">
+    <div class="control-value" ng-class="{ 'inline-control': item.widgetMode==='boolean', 'unset': !specEditor.defined(specEditor.config[item.name]), 'has-default': specEditor.defined(item.defaultValue) && item.defaultValue!=null }">
         <div class="hide-when-collapsed extra-label" ng-if="params['label-expanded']">
             {{ params['label-expanded'] || "" }}
         </div>
         <div class="config-flex-row">
             <span class="hide-when-expanded inline-label extra-label" ng-if="params['label-collapsed']">{{ params['label-collapsed'] || "" }}</span>
             <div class="input-group">
-                <textarea ng-model="config[item.name]" class="form-control" name="{{item.name}}" id="{{item.name}}" auto-grow
-                          placeholder="{{defined(config[item.name]) ? null : item.defaultValue=='' || item.defaultValue==null ? '(empty)' : item.defaultValue}}"
-                          ng-focus="recordFocus(item)" on-enter="advanceOutToFormGroupInPanel"
+                <textarea ng-model="specEditor.config[item.name]" class="form-control" name="{{item.name}}" id="{{item.name}}" auto-grow
+                          placeholder="{{specEditor.defined(config[item.name]) ? null : item.defaultValue=='' || item.defaultValue==null ? '(empty)' : item.defaultValue}}"
+                          ng-focus="specEditor.recordFocus(item)" on-enter="specEditor.advanceOutToFormGroupInPanel"
                           uib-typeahead="suggestion.value for suggestion in getSuggestions() | filter:{value:$viewValue}"
                           typeahead-min-length=0
                           typeahead-template-url="SuggestionTemplate.html"></textarea>
-                <span class="input-group-btn dsl-wizard-button" ng-if="isDslWizardButtonAllowed(item.name)">
+                <span class="input-group-btn dsl-wizard-button" ng-if="specEditor.isDslWizardButtonAllowed(item.name)">
                     <a ui-sref="main.graphical.edit.dsl({entityId: model._id, for: item.name})" class="btn btn-default" title="Open in DSL editor"><i class="fa fa-bolt"></i></a>
                 </span>
             </div>
         </div>
     </div>
+    
+    <small ng-repeat="issue in specEditor.model.issues | filter:{ref: item.name}:true" class="help-block issue" ng-bind-html="issue.message"></small>
 
 </div>
 

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/cd2ac803/ui-modules/blueprint-composer/app/components/custom-config-widget/suggestion-dropdown.js
----------------------------------------------------------------------
diff --git a/ui-modules/blueprint-composer/app/components/custom-config-widget/suggestion-dropdown.js b/ui-modules/blueprint-composer/app/components/custom-config-widget/suggestion-dropdown.js
index 3dfa860..1667d98 100644
--- a/ui-modules/blueprint-composer/app/components/custom-config-widget/suggestion-dropdown.js
+++ b/ui-modules/blueprint-composer/app/components/custom-config-widget/suggestion-dropdown.js
@@ -39,7 +39,7 @@ export function suggestionDropdownDirective($rootScope) {
     };
 
     function link(scope) {
-        scope.$parent.copyScopeForCustomConfigWidget(scope);
+        scope.specEditor = scope.$parent;
         scope.getSuggestions = () => {
             var result = [];
             if (scope.params['suggestion-values']) {

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/cd2ac803/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 6f37077..870a472 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
@@ -558,14 +558,6 @@ export function specEditorDirective($rootScope, $templateCache, $injector, $sani
             }
             return widgetMetadata.enabled ? "Use standard widget" : "Use custom widget";
         };
-        scope.copyScopeForCustomConfigWidget = (descendantScope) => {
-            descendantScope.toggleCustomConfigWidgetMode = scope.toggleCustomConfigWidgetMode;
-            descendantScope.getCustomConfigWidgetModeTitle = scope.getCustomConfigWidgetModeTitle;
-            descendantScope.defined = scope.defined;
-            descendantScope.config = scope.config;
-            descendantScope.state = scope.state;
-            descendantScope.copyScopeForCustomConfigWidget = scope.copyScopeForCustomConfigWidget;
-        };
         scope.getCustomConfigWidgetTemplate = (item) => {
             var widgetMetadata = scope.state.config.customConfigWidgetMetadata[item.name];
             var widgetName = $sanitize(widgetMetadata.widget || '--no-widget--');