@@ -667,10 +667,10 @@ function orEmptyArray(v) {
667
667
668
668
} ;
669
669
670
- function applyIncludeExclude ( metadata , outputModel , observable , initialConstraints ) {
670
+ function applyIncludeExclude ( metadata , outputModel , dataModelItem , initialConstraints ) {
671
671
var path = metadata . constraints . excludePath || metadata . constraints . includePath ;
672
672
673
- var currentValue = observable ( ) ;
673
+ var currentValue = dataModelItem ( ) ;
674
674
var selectedSoFar = [ ] ;
675
675
outputModel . eachValueForPath ( path , function ( val ) {
676
676
if ( _ . isArray ( val ) ) {
@@ -681,11 +681,17 @@ function orEmptyArray(v) {
681
681
} ) ;
682
682
683
683
if ( metadata . constraints . excludePath ) {
684
- return _ . filter ( initialConstraints , function ( value ) {
684
+ var filteredConstraints = _ . filter ( initialConstraints , function ( value ) {
685
+ // Handle object valued constraints - however the functions are attached after the first call to
686
+ // the computed observable, so we need to guard against that.
687
+ value = _ . isFunction ( dataModelItem . constraints . value ) ? dataModelItem . constraints . value ( value ) : value ;
685
688
var isCurrentSelection = _ . isArray ( currentValue ) ? currentValue . indexOf ( value ) >= 0 : value == currentValue ;
686
689
return ( isCurrentSelection || selectedSoFar . indexOf ( value ) < 0 ) ;
687
690
} ) ;
691
+ return filteredConstraints ;
688
692
} else {
693
+ // Note that the "includePath" option does not support object (key/value) typed constraints as
694
+ // it needs to collect values from other form selections which won't be object typed.
689
695
var constraints = initialConstraints . concat ( selectedSoFar ) ;
690
696
var currentSelection = _ . isArray ( currentValue ) ? currentValue : [ currentValue ] ;
691
697
for ( var i = 0 ; i < currentSelection . length ; i ++ ) {
0 commit comments