generated from process-analytics/bpmn-visualization-demo-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: let hide 2nd process and disable subprocess navigation (#9)
The second process is only displayed in the 'none' use case. It will later be displayed in the "case monitoring" on demand. The same applies to the sub-process navigation. The diagram fits the container in the "process monitoring" to enlarge it at maximum.
- Loading branch information
Showing
6 changed files
with
146 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import {type BpmnVisualization} from 'bpmn-visualization'; | ||
import {hideCaseMonitoringData, showCaseMonitoringData} from './case-monitoring.js'; | ||
import {hideHappyPath, showHappyPath} from './process-monitoring.js'; | ||
import {ProcessVisualizer, SubProcessNavigator} from './diagram.js'; | ||
|
||
export function configureUseCaseSelectors(bpmnVisualization: BpmnVisualization) { | ||
const processVisualizer = new ProcessVisualizer(bpmnVisualization); | ||
const subProcessNavigator = new SubProcessNavigator(bpmnVisualization); | ||
|
||
// eslint-disable-next-line no-warning-comments -- cannot be managed now | ||
// TODO try to having calling constructor for side effects | ||
// eslint-disable-next-line no-new | ||
new UseCaseSelector('radio-process-monitoring', () => { | ||
processVisualizer.hideManuallyTriggeredProcess(true); | ||
showHappyPath(bpmnVisualization); | ||
}, () => { | ||
hideHappyPath(bpmnVisualization); | ||
}); | ||
// eslint-disable-next-line no-new | ||
new UseCaseSelector('radio-case-monitoring', () => { | ||
processVisualizer.hideManuallyTriggeredProcess(); | ||
showCaseMonitoringData(bpmnVisualization); | ||
}, () => { | ||
hideCaseMonitoringData(bpmnVisualization); | ||
}); | ||
|
||
const initialUseCase = new UseCaseSelector('radio-reset-all', () => { | ||
processVisualizer.showManuallyTriggeredProcess(); | ||
subProcessNavigator.enable(); | ||
}, () => { | ||
subProcessNavigator.disable(); | ||
}); | ||
initialUseCase.select(); | ||
} | ||
|
||
let currentUseCase: UseCaseSelector | undefined; | ||
class UseCaseSelector { | ||
constructor(private readonly id: string, selectCallback: () => void, private readonly unselectCallback: () => void) { | ||
document.querySelector(`#${id}`)?.addEventListener('click', () => { | ||
if (currentUseCase !== this) { | ||
currentUseCase?.unselect(); | ||
selectCallback(); | ||
// eslint-disable-next-line @typescript-eslint/no-this-alias,unicorn/no-this-assignment -- need to store this in a variable | ||
currentUseCase = this; | ||
} | ||
}); | ||
} | ||
|
||
select() { | ||
const elt = document.querySelector(`#${(this.id)}`) ?? undefined; | ||
(elt as HTMLInputElement)?.click(); | ||
} | ||
|
||
private unselect() { | ||
if (currentUseCase === this) { | ||
this.unselectCallback(); | ||
currentUseCase = undefined; | ||
} | ||
} | ||
} |