-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip example override messageRef component
Related to #737
- Loading branch information
Niklas Kiefer
committed
Sep 12, 2022
1 parent
289bf7f
commit 5223c75
Showing
3 changed files
with
132 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { MessageRef, CREATE_NEW_OPTION } from '../../../src/provider/bpmn/properties/MessageProps'; | ||
|
||
class GetterSetterValidateProvider { | ||
constructor(propertiesPanel) { | ||
propertiesPanel.registerProvider(500, this); | ||
} | ||
|
||
getGroups() { | ||
return (groups) => { | ||
|
||
const messageGroup = findGroup(groups, 'message'); | ||
|
||
if (!messageGroup) { | ||
return groups; | ||
} | ||
|
||
let messageRef = findEntry(messageGroup, 'messageRef'); | ||
|
||
if (!messageRef) { | ||
return groups; | ||
} | ||
|
||
messageRef.component = CustomMessageRef; | ||
|
||
return groups; | ||
}; | ||
} | ||
} | ||
|
||
function CustomMessageRef(props) { | ||
|
||
const getValue = () => { | ||
return () => { | ||
|
||
// override default getter | ||
return CREATE_NEW_OPTION; | ||
}; | ||
}; | ||
|
||
const setValue = (defaultSetter) => { | ||
return (value) => { | ||
|
||
// notify | ||
alert(`messageRef is set: ${value}!`); | ||
|
||
// execute default setter | ||
return defaultSetter(value); | ||
}; | ||
}; | ||
|
||
return MessageRef({ | ||
...props, | ||
getValue, | ||
setValue | ||
}); | ||
} | ||
|
||
GetterSetterValidateProvider.$inject = [ 'propertiesPanel' ]; | ||
|
||
export default { | ||
__init__: [ | ||
'getterSetterValidateProvider' | ||
], | ||
getterSetterValidateProvider: [ 'type', GetterSetterValidateProvider ] | ||
}; | ||
|
||
|
||
// helper ///////////// | ||
|
||
function findGroup(groups, id) { | ||
return groups.find(g => g.id === id); | ||
} | ||
|
||
function findEntry(group, id) { | ||
return group.entries.find(e => e.id === id); | ||
} |