Skip to content

Commit

Permalink
Bugfix/91 renaming button bar when no objective selected throws error (
Browse files Browse the repository at this point in the history
…#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 <[email protected]>
  • Loading branch information
Noel-Bastubbe authored Mar 28, 2023
1 parent 50cb2a4 commit e772c25
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
15 changes: 9 additions & 6 deletions app/lib/guidelines/Guidelines.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand All @@ -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'));
Expand All @@ -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'));
Expand All @@ -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'
},
]
3 changes: 2 additions & 1 deletion app/lib/objectivemodeler/BaseViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 0 additions & 2 deletions app/lib/objectivemodeler/OmModeler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down
10 changes: 6 additions & 4 deletions app/lib/objectivemodeler/buttonbar/OmButtonBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
});
Expand Down

0 comments on commit e772c25

Please sign in to comment.