From e772c25a2e7270bb0bd0d191eba1d4f86979a02a Mon Sep 17 00:00:00 2001 From: Noel-Bastubbe <82881590+Noel-Bastubbe@users.noreply.github.com> Date: Tue, 28 Mar 2023 10:02:53 +0200 Subject: [PATCH] Bugfix/91 renaming button bar when no objective selected throws error (#96) * The Start State is now the selected Objective from the beginning * Fixes Bugs #91 #94 #95 * Adds links to error / warning messages in the dependency modeler --------- Co-authored-by: lottchen --- app/lib/guidelines/Guidelines.js | 15 +++++++++------ app/lib/objectivemodeler/BaseViewer.js | 3 ++- app/lib/objectivemodeler/OmModeler.js | 2 -- app/lib/objectivemodeler/buttonbar/OmButtonBar.js | 10 ++++++---- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/app/lib/guidelines/Guidelines.js b/app/lib/guidelines/Guidelines.js index dfd6596f..3fafb812 100644 --- a/app/lib/guidelines/Guidelines.js +++ b/app/lib/guidelines/Guidelines.js @@ -422,7 +422,7 @@ export default [ }, { title : 'Connect each Objective at least to one other Objective.', - id : 'DEP1', + id : 'DEP2', getViolations(mediator) { const dependencyModeler = mediator.dependencyModelerHook.modeler; const objectives = dependencyModeler.get('elementRegistry').getAll().filter(element => is(element, 'dep:Objective')); @@ -437,11 +437,12 @@ export default [ return []; } }, - severity : SEVERITY.WARNING + severity : SEVERITY.WARNING, + link : 'https://github.com/Noel-Bastubbe/for-Construction-Modeling/wiki/Dependency-Model#dep2---link-every-objectives-to-at-least-one-other-objective' }, { title : 'Connect the Start State to one other Objective.', - id : 'DEP2', + id : 'DEP3', getViolations(mediator) { const dependencyModeler = mediator.dependencyModelerHook.modeler; const dependencies = dependencyModeler.get('elementRegistry').getAll().filter(element => is(element, 'dep:Dependency')); @@ -456,11 +457,12 @@ export default [ return []; } }, - severity : SEVERITY.ERROR + severity : SEVERITY.ERROR, + link: 'https://github.com/Noel-Bastubbe/for-Construction-Modeling/wiki/Dependency-Model#dep3---include-the-start-state-into-the-dependency-graph' }, { title : 'Do not create cycles in the Dependency Modeler.', - id : 'DEP3', + id : 'DEP4', getViolations(mediator) { const dependencyModeler = mediator.dependencyModelerHook.modeler; const objectives = dependencyModeler.get('elementRegistry').getAll().filter(element => is(element, 'dep:Objective')); @@ -487,6 +489,7 @@ export default [ return []; } }, - severity : SEVERITY.ERROR + severity : SEVERITY.ERROR, + link: 'https://github.com/Noel-Bastubbe/for-Construction-Modeling/wiki/Dependency-Model#dep4---mind-cyclic-dependencies' }, ] \ No newline at end of file diff --git a/app/lib/objectivemodeler/BaseViewer.js b/app/lib/objectivemodeler/BaseViewer.js index 34824642..b24d2cf3 100644 --- a/app/lib/objectivemodeler/BaseViewer.js +++ b/app/lib/objectivemodeler/BaseViewer.js @@ -203,7 +203,7 @@ BaseViewer.prototype.importDefinitions = function(definitions, rootBoard) { self._setDefinitions(definitions); - self.open(rootBoard).then(function(result) { + self.open(self._objective).then(function(result) { var warnings = result.warnings; @@ -477,6 +477,7 @@ BaseViewer.prototype.saveSVG = function(options) { BaseViewer.prototype._setDefinitions = function(definitions) { this._definitions = definitions; + this._objective = definitions.get('rootBoards')[0]; }; BaseViewer.prototype.getModules = function() { diff --git a/app/lib/objectivemodeler/OmModeler.js b/app/lib/objectivemodeler/OmModeler.js index 08d6dc22..c3d92c2b 100644 --- a/app/lib/objectivemodeler/OmModeler.js +++ b/app/lib/objectivemodeler/OmModeler.js @@ -80,8 +80,6 @@ OmModeler.NavigatedViewer = NavigatedViewer; * */ OmModeler.prototype.createDiagram = function () { - const container = this.get('canvas').getContainer(); - container.style.visibility = 'hidden'; return this.importXML(initialDiagram); }; diff --git a/app/lib/objectivemodeler/buttonbar/OmButtonBar.js b/app/lib/objectivemodeler/buttonbar/OmButtonBar.js index dfed3de4..63246b63 100644 --- a/app/lib/objectivemodeler/buttonbar/OmButtonBar.js +++ b/app/lib/objectivemodeler/buttonbar/OmButtonBar.js @@ -80,10 +80,12 @@ export default function OmButtonBar(canvas, eventBus, omModeler) { deleteObjectiveButton.title = 'Delete Current Objective'; deleteObjectiveButton.addEventListener('click', () => { var objectiveToDelete = selectObjectiveComponent.value; - var shouldDelete = eventBus.fire(ObjectiveEvents.OBJECTIVE_DELETION_REQUESTED, { objective: objectiveToDelete}); - if (shouldDelete !== false) { - // Deletion was not rejected and not handled somewhere else; should not happen when mediator is involved - omModeler.deleteObjective(objectiveToDelete); + if( objectiveToDelete.id !== 'StartBoard') { + var shouldDelete = eventBus.fire(ObjectiveEvents.OBJECTIVE_DELETION_REQUESTED, {objective: objectiveToDelete}); + if (shouldDelete !== false) { + // Deletion was not rejected and not handled somewhere else; should not happen when mediator is involved + omModeler.deleteObjective(objectiveToDelete); + } } selectObjectiveComponent.showValue(omModeler.getCurrentObjective()); });