@@ -396,18 +396,34 @@ pub fn state_command(payload: Value) -> Result<Value, CoreError> {
396396 )
397397 } )
398398 . collect ( ) ;
399- let effective_displays: BTreeMap < _ , BTreeMap < _ , Value > > =snapshot. sources . iter ( ) . map ( |source|{
400- ( source. id . clone ( ) , source. fields . iter ( ) . filter ( |field|!field. value . is_null ( ) &&field. value !=field. effective_value ) . map ( |field|{
401- let value=& field. effective_value ;
402- let display=if value. is_null ( ) { json ! ( { "kind" : "unknown" } ) } else { match field. kind . as_str ( ) {
403- "enum" =>json ! ( { "kind" : "text" , "text" : field. options. iter( ) . find( |option|Some ( option. value. as_str( ) ) ==value. as_str( ) ) . map( |option|option. title. as_str( ) ) . unwrap_or_default( ) } ) ,
404- "boolean" =>json ! ( { "kind" : "boolean" , "on" : value. as_bool( ) . unwrap_or_default( ) } ) ,
405- "fileList" |"stringList" =>json ! ( { "kind" : "list" , "count" : value. as_array( ) . map_or( 0 , Vec :: len) } ) ,
406- _=>json ! ( { "kind" : "text" , "text" : value. as_str( ) . unwrap_or_default( ) } ) ,
407- } } ;
408- ( field. id . clone ( ) , display)
409- } ) . collect ( ) )
410- } ) . collect ( ) ;
399+ let effective_displays: BTreeMap < _ , BTreeMap < _ , Value > > = snapshot
400+ . sources
401+ . iter ( )
402+ . map ( |source| {
403+ let displays = source. fields . iter ( ) . filter ( |field| {
404+ ( field. value . is_null ( ) && field. kind != "enum" )
405+ || ( !field. value . is_null ( ) && field. value != field. effective_value )
406+ } ) . map ( |field| {
407+ let value = & field. effective_value ;
408+ let mut display = if value. is_null ( ) {
409+ json ! ( { "kind" : "unknown" } )
410+ } else {
411+ match field. kind . as_str ( ) {
412+ "enum" => {
413+ let title = field. options . iter ( ) . find ( |option| Some ( option. value . as_str ( ) ) == value. as_str ( ) )
414+ . map ( |option| option. title . as_str ( ) ) . unwrap_or_default ( ) ;
415+ json ! ( { "kind" : "text" , "text" : title} )
416+ }
417+ "boolean" => json ! ( { "kind" : "boolean" , "on" : value. as_bool( ) . unwrap_or_default( ) } ) ,
418+ "fileList" | "stringList" => json ! ( { "kind" : "list" , "count" : value. as_array( ) . map_or( 0 , Vec :: len) } ) ,
419+ _ => json ! ( { "kind" : "text" , "text" : value. as_str( ) . unwrap_or_default( ) } ) ,
420+ }
421+ } ;
422+ display[ "inherited" ] = json ! ( field. value. is_null( ) ) ;
423+ ( field. id . clone ( ) , display)
424+ } ) . collect ( ) ;
425+ ( source. id . clone ( ) , displays)
426+ } ) . collect ( ) ;
411427 let layout: Vec < _ > = snapshot
412428 . groups
413429 . iter ( )
0 commit comments