@@ -17,6 +17,7 @@ export interface TreeGuids {
1717export interface NodeStoreConstructorOptions {
1818 contextObject ?: mendix . lib . MxObject ;
1919 loadFull : boolean ;
20+ holdSelection ?: boolean ;
2021 subscriptionHandler ?: ( guids : TreeGuids ) => void ;
2122 onSelectionChange ?: ( guids : TreeGuids ) => void ;
2223 validationMessages : ValidationMessage [ ] ;
@@ -61,12 +62,14 @@ export class NodeStore {
6162 @observable public validationMessages : ValidationMessage [ ] = [ ] ;
6263
6364 private loadFull = false ;
65+ private holdSelection = false ;
6466 private expandedMapping : { [ key : string ] : string [ ] } = { } ;
6567
6668 constructor ( opts : NodeStoreConstructorOptions ) {
6769 const {
6870 contextObject,
6971 loadFull,
72+ holdSelection,
7073 subscriptionHandler,
7174 onSelectionChange,
7275 validationMessages,
@@ -78,6 +81,7 @@ export class NodeStore {
7881
7982 this . isLoading = false ;
8083 this . loadFull = typeof loadFull !== "undefined" ? loadFull : false ;
84+ this . holdSelection = typeof holdSelection !== "undefined" ? holdSelection : false ;
8185 this . contextObject = contextObject || null ;
8286 this . subscriptionHandler = subscriptionHandler || ( ( ) : void => { } ) ;
8387 this . onSelectionChangeHandler = onSelectionChange || ( ( ) : void => { } ) ;
@@ -240,6 +244,27 @@ export class NodeStore {
240244 return this . entries . filter ( entry => entry . selected ) . map ( entry => entry . guid ) ;
241245 }
242246
247+ @action
248+ selectEntry ( guid : string ) {
249+ if ( ! this . holdSelection ) {
250+ return ;
251+ }
252+ let selectedFound = false ;
253+ this . selectedEntries . forEach ( entry => {
254+ if ( entry . guid !== guid ) {
255+ entry . setSelected ( false ) ;
256+ } else {
257+ selectedFound = true ;
258+ }
259+ } ) ;
260+ if ( ! selectedFound ) {
261+ const entry = this . findEntry ( guid ) ;
262+ if ( entry ) {
263+ entry . setSelected ( true ) ;
264+ }
265+ }
266+ }
267+
243268 // Expanded
244269
245270 get expandedKeys ( ) : string [ ] {
0 commit comments