11import { BooleanValueComponent } from './boolean-value/boolean-value.component' ;
2+ import { LabelValue } from './label-value/label-value.component' ;
23import { LinkValueComponent } from './link-value/link-value.component' ;
34import {
45 ChangeDetectionStrategy ,
78 input ,
89} from '@angular/core' ;
910import { LabelDisplay } from '@platform-mesh/portal-ui-lib/models/models' ;
10- import { LabelValue } from "./label-value/label-value.component" ;
1111
1212@Component ( {
1313 selector : 'value-cell' ,
@@ -18,14 +18,17 @@ import { LabelValue } from "./label-value/label-value.component";
1818} )
1919export class ValueCellComponent {
2020 value = input < unknown > ( ) ;
21- labelDisplay = input < LabelDisplay > ( ) ;
21+ labelDisplay = input < LabelDisplay | boolean > ( ) ;
2222
23- isLabelValue = computed ( ( ) => this . labelDisplay ( ) !== undefined ) ;
23+ isLabelValue = computed ( ( ) => this . labelDisplayValue ( ) !== undefined ) ;
2424 isBoolLike = computed ( ( ) => this . boolValue ( ) !== undefined ) ;
2525 isUrlValue = computed ( ( ) => this . checkValidUrl ( this . stringValue ( ) ) ) ;
2626
2727 boolValue = computed ( ( ) => this . normalizeBoolean ( this . value ( ) ) ) ;
2828 stringValue = computed ( ( ) => this . normalizeString ( this . value ( ) ) ) ;
29+ labelDisplayValue = computed ( ( ) =>
30+ this . normalizeLabelDisplay ( this . labelDisplay ( ) ) ,
31+ ) ;
2932
3033 private normalizeBoolean ( value : unknown ) : boolean | undefined {
3134 const normalizedValue = value ?. toString ( ) ?. toLowerCase ( ) ;
@@ -58,4 +61,16 @@ export class ValueCellComponent {
5861 return false ;
5962 }
6063 }
64+
65+ private normalizeLabelDisplay ( value : unknown ) : LabelDisplay | undefined {
66+ if ( typeof value === 'object' && value !== null ) {
67+ return value ;
68+ }
69+
70+ if ( value ) {
71+ return { } ;
72+ }
73+
74+ return undefined ;
75+ }
6176}
0 commit comments