-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(demo): have a single bpmn container in the prediction demo (#…
…558)
- Loading branch information
Showing
3 changed files
with
26 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,32 @@ | ||
// Initialize UseCases | ||
const predictedLateUseCase = new PredicatedLateUseCase('late'); | ||
const onTimeUseCase = new PredictedOnTimeUseCase('onTime'); | ||
function buildUseCase(type) { | ||
switch (type) { | ||
case 'late': | ||
return new PredicatedLateUseCase('Predicted Late'); | ||
case 'onTime': | ||
default: | ||
return new PredictedOnTimeUseCase('Predicted on Time'); | ||
} | ||
} | ||
|
||
function changeUseCase() { | ||
state.useCase = buildUseCase(state.dataType); | ||
state.useCase.display(state.dataType); | ||
} | ||
|
||
const state = { | ||
useCase: predictedLateUseCase, | ||
useCase: undefined, | ||
dataType: 'late' | ||
} | ||
|
||
// Update state of radio buttons | ||
document.getElementById('btn-late').checked = true; | ||
document.getElementById(`btn-${state.dataType}`).checked = true; | ||
|
||
document.addEventListener('DOMContentLoaded', function () { | ||
// Waiting for the displayed page before to load diagram & display data | ||
state.useCase.display(state.dataType); | ||
changeUseCase(); | ||
}) | ||
|
||
document.getElementById('choose-use-case-panel').onchange = () => { | ||
const useCaseType = document.querySelector("input[type='radio'][name='use-case-type']:checked").value; | ||
state.useCase = useCaseType === 'onTime' ? onTimeUseCase : predictedLateUseCase; | ||
|
||
state.useCase.display(state.dataType); | ||
state.dataType = document.querySelector("input[type='radio'][name='use-case-type']:checked").value; | ||
changeUseCase(); | ||
} |
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