This is an automated email from the ASF dual-hosted git repository.

heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-ui.git


The following commit(s) were added to refs/heads/master by this push:
     new fee9e72  Add ID field to Issues model to distinguish issues for 
multiple properties with the same name
     new 88a8df6  This closes #215
fee9e72 is described below

commit fee9e72a575cbc29e12db32e6c9b09a77da21979
Author: Mykola Mandra <[email protected]>
AuthorDate: Wed Jun 9 11:29:53 2021 +0100

    Add ID field to Issues model to distinguish issues for multiple properties 
with the same name
    
    Signed-off-by: Mykola Mandra <[email protected]>
---
 .../spec-editor/spec-editor.directive.js           | 27 ++++++++++++++--------
 .../spec-editor/spec-editor.template.html          |  4 ++--
 .../app/components/util/model/issue.model.js       | 15 ++++++++++++
 3 files changed, 34 insertions(+), 12 deletions(-)

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 bd95437..0104696 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
@@ -483,20 +483,23 @@ export function specEditorDirective($rootScope, 
$templateCache, $injector, $sani
             $state.go(graphicalState.name);
         };
 
-        specEditor.getParameterIssues = () => {
-            return scope.model.issues
-                .filter((issue) => (issue.group === 'parameters'))
-                
.concat(Object.values(scope.model.getClusterMemberspecEntities())
-                    .filter((spec) => (spec && spec.hasIssues()))
-                    .reduce((acc, spec) => (acc.concat(spec.issues)), []));
-        };
-        scope.getConfigIssues = specEditor.getConfigIssues = () => {
+        /**
+         * Gets collection of issues filtered by group.
+         *
+         * @param {String} groupName The group name to filter issues by.
+         * @returns {[]} The collection of issues found.
+         */
+        scope.getIssuesByGroup = (groupName) => {
             return scope.model.issues
-                .filter((issue) => (issue.group === 'config'))
+                .filter((issue) => (issue.group === groupName))
                 
.concat(Object.values(scope.model.getClusterMemberspecEntities())
                     .filter((spec) => (spec && spec.hasIssues()))
                     .reduce((acc, spec) => (acc.concat(spec.issues)), []));
-        };
+        }
+
+        /**
+         * @returns {[]} The collection of issues specific to Policies.
+         */
         scope.getPoliciesIssues = () => {
             return scope.model.getPoliciesAsArray().reduce((acc, policy) => {
                 if (policy.hasIssues()) {
@@ -505,6 +508,10 @@ export function specEditorDirective($rootScope, 
$templateCache, $injector, $sani
                 return acc;
             }, []);
         };
+
+        /**
+         * @returns {[]} The collection of issues specific to Enrichers.
+         */
         scope.getEnrichersIssues = () => {
             return scope.model.getEnrichersAsArray().reduce((acc, enricher) => 
{
                 if (enricher.hasIssues()) {
diff --git 
a/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.template.html
 
b/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.template.html
index c3a28b9..b59dfb7 100644
--- 
a/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.template.html
+++ 
b/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.template.html
@@ -72,7 +72,7 @@
 <br-collapsible state="state.parameters.open" ng-if="!model.parent">  <!-- the 
ng-if is needed to make state update?! -->
     <heading>
         Parameters
-        <span ng-if="specEditor.getParameterIssues().length> 0" class="badge" 
ng-class="getBadgeClass(specEditor.getParameterIssues())">{{specEditor.getParameterIssues().length}}</span>
+        <span ng-if="getIssuesByGroup('parameters').length> 0" class="badge" 
ng-class="getBadgeClass(getIssuesByGroup('parameters'))">{{getIssuesByGroup('parameters').length}}</span>
         <span class="pull-right" ng-show="$parent.stateWrapped.state">
             <span class="spec-toolbar-action" ng-class="{'active': 
state.parameters.filter.open}"><i class="fa fa-search-plus collapsible-action" 
title="Search or add a parameter" ng-click="$event.stopPropagation(); 
$event.preventDefault(); state.parameters.filter.open = 
!state.parameters.filter.open" ng-class="{'text-info': 
state.parameters.search.length > 0}"></i></span>
         </span>
@@ -282,7 +282,7 @@
 <br-collapsible ng-if="true" state="state.config.open">  <!-- the ng-if is 
needed to make state update?! -->
     <heading>
         Configuration
-        <span ng-if="getConfigIssues().length> 0" class="badge" 
ng-class="getBadgeClass(getConfigIssues())">{{getConfigIssues().length}}</span>
+        <span ng-if="getIssuesByGroup('config').length> 0" class="badge" 
ng-class="getBadgeClass(getIssuesByGroup('config'))">{{getIssuesByGroup('config').length}}</span>
         <span class="pull-right" ng-show="$parent.stateWrapped.state">
             <span class="spec-toolbar-action" ng-class="{'active': 
state.config.filter.open}"><i class="fa fa-search-plus collapsible-action" 
title="Filter configuration" ng-click="$event.stopPropagation(); 
$event.preventDefault(); state.config.filter.open = !state.config.filter.open" 
ng-class="{'text-info': state.config.search.length > 0}"></i></span>
         </span>
diff --git 
a/ui-modules/blueprint-composer/app/components/util/model/issue.model.js 
b/ui-modules/blueprint-composer/app/components/util/model/issue.model.js
index 0d87dd1..880cf52 100644
--- a/ui-modules/blueprint-composer/app/components/util/model/issue.model.js
+++ b/ui-modules/blueprint-composer/app/components/util/model/issue.model.js
@@ -20,6 +20,7 @@ const MESSAGE = new WeakMap();
 const GROUP = new WeakMap();
 const PHASE = new WeakMap();
 const REF = new WeakMap();
+const ID = new WeakMap();
 const LEVEL = new WeakMap();
 
 export const ISSUE_LEVEL = {
@@ -39,6 +40,7 @@ export class Issue {
         GROUP.set(this, '');
         PHASE.set(this, '');
         REF.set(this, '');
+        ID.set(this, '');
         LEVEL.set(this, ISSUE_LEVEL.ERROR);
     }
 
@@ -74,6 +76,14 @@ export class Issue {
         return REF.get(this);
     }
 
+    set id(ref) {
+        ID.set(this, ref);
+    }
+
+    get id() {
+        return ID.get(this);
+    }
+
     set level(level) {
         LEVEL.set(this, level);
     }
@@ -112,6 +122,11 @@ class Builder {
         return this;
     }
 
+    id(id) {
+        this.issue.id = id;
+        return this;
+    }
+
     level(level) {
         this.issue.level = level;
         return this;

Reply via email to