@@ -73,7 +73,7 @@ export function uiFieldCombo(field, context) {
7373 function tagValue ( dval ) {
7474 dval = clean ( dval || '' ) ;
7575
76- var found = getOptions ( ) . find ( function ( o ) {
76+ var found = getOptions ( true ) . find ( function ( o ) {
7777 return o . key && clean ( o . value ) === dval ;
7878 } ) ;
7979 if ( found ) return found . key ;
@@ -171,11 +171,17 @@ export function uiFieldCombo(field, context) {
171171 }
172172 }
173173
174- function getOptions ( ) {
174+ function getOptions ( allOptions ) {
175175 var stringsField = field . resolveReference ( 'stringsCrossReference' ) ;
176176 if ( ! ( field . options || stringsField . options ) ) return [ ] ;
177177
178- return ( field . options || stringsField . options ) . map ( function ( v ) {
178+ let options ;
179+ if ( ! allOptions ) {
180+ options = field . options || stringsField . options ;
181+ } else {
182+ options = [ ] . concat ( field . options , stringsField . options ) . filter ( Boolean ) ;
183+ }
184+ return options . map ( function ( v ) {
179185 const labelId = getLabelId ( stringsField , v ) ;
180186 return {
181187 key : v ,
@@ -410,6 +416,17 @@ export function uiFieldCombo(field, context) {
410416 }
411417
412418
419+ function invertMultikey ( d3_event , d ) {
420+ d3_event . preventDefault ( ) ;
421+ d3_event . stopPropagation ( ) ;
422+ var t = { } ;
423+ if ( _isMulti ) {
424+ t [ d . key ] = _tags [ d . key ] === 'no' ? 'yes' : 'no' ;
425+ }
426+ dispatch . call ( 'change' , this , t ) ;
427+ }
428+
429+
413430 function combo ( selection ) {
414431 _container = selection . selectAll ( '.form-field-input-wrap' )
415432 . data ( [ 0 ] ) ;
@@ -449,6 +466,11 @@ export function uiFieldCombo(field, context) {
449466 . attr ( 'class' , 'input-wrap' )
450467 . merge ( _inputWrap ) ;
451468
469+ // Hide 'Add' button if this field uses fixed set of
470+ // options and they're all currently used
471+ var hideAdd = ( ! _allowCustomValues && ! _comboData . length ) ;
472+ _inputWrap . style ( 'display' , hideAdd ? 'none' : null ) ;
473+
452474 _input = _inputWrap . selectAll ( 'input' )
453475 . data ( [ 0 ] ) ;
454476 } else {
@@ -551,13 +573,14 @@ export function uiFieldCombo(field, context) {
551573 if ( ! field . key && field . keys . indexOf ( k ) === - 1 ) continue ;
552574
553575 var v = tags [ k ] ;
554- if ( ! v || ( typeof v === 'string' && v . toLowerCase ( ) === 'no' ) ) continue ;
576+ // if (!v || (typeof v === 'string' && v.toLowerCase() === 'no')) continue;
555577
556578 var suffix = field . key ? k . slice ( field . key . length ) : k ;
557579 _multiData . push ( {
558580 key : k ,
559581 value : displayValue ( suffix ) ,
560582 display : renderValue ( suffix ) ,
583+ negated : typeof v === 'string' && v . toLowerCase ( ) === 'no' ,
561584 isMixed : Array . isArray ( v )
562585 } ) ;
563586 }
@@ -617,7 +640,7 @@ export function uiFieldCombo(field, context) {
617640 maxLength = Math . max ( 0 , maxLength ) ;
618641
619642 // Hide 'Add' button if this field is already at its character limit
620- var hideAdd = maxLength <= 0 ;
643+ var hideAdd = maxLength <= 0 || ( ! _allowCustomValues && ! _comboData . length ) ;
621644 _container . selectAll ( '.chiplist .input-wrap' )
622645 . style ( 'display' , hideAdd ? 'none' : null ) ;
623646
@@ -651,7 +674,16 @@ export function uiFieldCombo(field, context) {
651674 } )
652675 . attr ( 'title' , function ( d ) {
653676 return d . isMixed ? t ( 'inspector.unshared_value_tooltip' ) : null ;
654- } ) ;
677+ } )
678+ . classed ( 'negated' , d => d . negated ) ;
679+
680+ if ( ! _isSemi ) {
681+ chips . selectAll ( 'input[type=checkbox]' ) . remove ( ) ;
682+ chips . insert ( 'input' , 'span' )
683+ . attr ( 'type' , 'checkbox' )
684+ . property ( 'checked' , d => ! d . negated )
685+ . on ( 'click' , invertMultikey ) ;
686+ }
655687
656688 if ( allowDragAndDrop ) {
657689 registerDragAndDrop ( chips ) ;
0 commit comments