Skip to content

Commit

Permalink
[OM] add dropdown for class-state-name, Conformance of Changes (#81)
Browse files Browse the repository at this point in the history
* implement dropdown for omObjects
* the labels of the objective modeler are now updated after renaming and deleting a state, an OLC or a data class

---------

Co-authored-by: Pierre Burghardt <[email protected]>
Co-authored-by: Noel <[email protected]>
Co-authored-by: Simon Nowack <[email protected]>
  • Loading branch information
4 people authored Mar 22, 2023
1 parent eda66c0 commit c165fc4
Show file tree
Hide file tree
Showing 13 changed files with 621 additions and 248 deletions.
2 changes: 1 addition & 1 deletion app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import newDatamodel from '../resources/emptyBoard.bpmn';
import OlcModeler from './lib/olcmodeler/OlcModeler';
import GoalStateModeler from './lib/goalstatemodeler/GoalStateModeler';
import DataModelModeler from './lib/datamodelmodeler/Modeler';
import ObjectiveModeler from './lib/objectivemodeler/Modeler';
import ObjectiveModeler from './lib/objectivemodeler/OmModeler';
import DependencyModeler from './lib/dependencymodeler/DependencyModeler';

import $ from 'jquery';
Expand Down
3 changes: 2 additions & 1 deletion app/lib/common/CommonEvents.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default {
DATACLASS_CREATION_REQUESTED: 'dataclass.create.requested',
STATE_CREATION_REQUESTED: 'state.create.requested'
STATE_CREATION_REQUESTED: 'state.create.requested',
NAME_CREATION_REQUESTED: 'name.create.requested'
}
24 changes: 20 additions & 4 deletions app/lib/mediator/Mediator.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ export default function Mediator() {
this.on(CommonEvents.STATE_CREATION_REQUESTED, event => {
return this.createState(event.name, event.olc);
});

this.on(CommonEvents.NAME_CREATION_REQUESTED, event => {
return this.createName(event.name, event.clazz);
});
}

Mediator.prototype.getHooks = function () {
Expand Down Expand Up @@ -140,19 +144,22 @@ Mediator.prototype.confirmClassDeletion = function (clazz) {
const affectedLiterals = this.goalStateModelerHook.modeler.getLiteralsWithClassId(clazz.id);
const affectedStates = this.olcModelerHook.modeler.getOlcByClass(clazz).get('Elements').filter(element => is(element, 'olc:State'));
const affectedDataObjectReferences = this.fragmentModelerHook.modeler.getDataObjectReferencesOfClass(clazz);
const affectedObjects = this.objectiveModelerHook.modeler.getObjectsOfClass(clazz);
return confirm('Do you really want to delete class \"' + clazz.name + '\" ?'
+ '\n' + affectedLiterals.length + ' literal(s), ' + affectedStates.length + ' olc state(s), and '
+ affectedDataObjectReferences.length + ' data object reference(s) would be deleted as well.');
+ affectedDataObjectReferences.length + ' data object reference(s), and ' + affectedObjects.length + ' object(s) would be deleted as well.');
}

Mediator.prototype.deletedClass = function (clazz) {
this.fragmentModelerHook.modeler.handleClassDeleted(clazz);
this.olcModelerHook.modeler.deleteOlc(clazz);
this.fragmentModelerHook.modeler.handleClassDeleted(clazz);
this.objectiveModelerHook.modeler.handleClassDeleted(clazz);
}

Mediator.prototype.renamedClass = function (clazz) {
this.olcModelerHook.modeler.renameOlc(clazz.name, clazz);
this.fragmentModelerHook.modeler.handleClassRenamed(clazz);
this.objectiveModelerHook.modeler.handleClassRenamed(clazz);
}

// === Dependency model helpers
Expand Down Expand Up @@ -188,11 +195,17 @@ Mediator.prototype.objectiveRenamingRequested = function (objective, objectiveNa
this.dependencyModelerHook.modeler.renameObjective(objective, objectiveName)
}

Mediator.prototype.createName = function (name, clazz) {
const instanceName = this.objectiveModelerHook.modeler.createName(name, clazz);
return instanceName;
}

// === OLC helpers

Mediator.prototype.olcListChanged = function (olcs) {
this.goalStateModelerHook.modeler.handleOlcListChanged(olcs);
this.fragmentModelerHook.modeler.handleOlcListChanged(olcs);
this.objectiveModelerHook.modeler.handleOlcListChanged(olcs);
}

Mediator.prototype.olcDeletionRequested = function (olc) {
Expand All @@ -217,18 +230,21 @@ Mediator.prototype.createState = function (name, olc) {
Mediator.prototype.confirmStateDeletion = function (olcState) {
const affectedLiterals = this.goalStateModelerHook.modeler.getLiteralsWithState(olcState);
const affectedDataObjectReferences = this.fragmentModelerHook.modeler.getDataObjectReferencesInState(olcState);
const affectedObjects = this.objectiveModelerHook.modeler.getObjectsInState(olcState);
return confirm('Do you really want to delete state \"' + olcState.name + '\" ?'
+ '\n' + 'It would be removed from ' + affectedLiterals.length + ' literal(s) and '+ affectedDataObjectReferences.length + ' data object reference(s).');
+ '\n' + 'It would be removed from ' + affectedLiterals.length + ' literal(s) and '+ affectedDataObjectReferences.length + ' data object reference(s) and '+ affectedObjects.length + ' object(s).');
}

Mediator.prototype.deletedState = function (olcState) {
this.goalStateModelerHook.modeler.handleStateDeleted(olcState);
this.fragmentModelerHook.modeler.handleStateDeleted(olcState);
this.objectiveModelerHook.modeler.handleStateDeleted(olcState);
}

Mediator.prototype.renamedState = function (olcState) {
this.goalStateModelerHook.modeler.handleStateRenamed(olcState);
this.fragmentModelerHook.modeler.handleStateRenamed(olcState);
this.objectiveModelerHook.modeler.handleStateRenamed(olcState);
}

// === Data Modeler Hook
Expand Down Expand Up @@ -487,7 +503,7 @@ Mediator.prototype.ObjectiveModelerHook = function (eventBus, objectiveModeler)
], event => {
event.context.elements = event.context.elements.filter(element => {
if (is(element, 'om:Object')) {
//return this.modeler.deleteObject(element);
return this.modeler.deleteObject(element);
} else {
return true;
}
Expand Down
218 changes: 0 additions & 218 deletions app/lib/objectivemodeler/Modeler.js

This file was deleted.

Loading

0 comments on commit c165fc4

Please sign in to comment.