@@ -12,6 +12,7 @@ import { type Column, ColumnService } from '@seed/api/column'
12
12
import { type Organization , OrganizationService } from '@seed/api/organization'
13
13
import { PageComponent } from '@seed/components'
14
14
import { SharedImports } from '@seed/directives'
15
+ import { naturalSort } from '@seed/utils'
15
16
16
17
@Component ( {
17
18
selector : 'seed-organizations-settings-default-display-fields' ,
@@ -26,6 +27,8 @@ export class DefaultDisplayFieldComponent implements OnDestroy, OnInit {
26
27
organization : Organization
27
28
propertyColumns : Column [ ]
28
29
taxLotColumns : Column [ ]
30
+ xAxisColumns : Column [ ]
31
+ yAxisColumns : Column [ ]
29
32
defaultDisplayFieldsForm = new FormGroup ( {
30
33
property_display_field : new FormControl ( 'address_line_1' ) ,
31
34
taxlot_display_field : new FormControl ( 'address_line_1' ) ,
@@ -38,9 +41,13 @@ export class DefaultDisplayFieldComponent implements OnDestroy, OnInit {
38
41
this . organization = organization
39
42
this . defaultDisplayFieldsForm . get ( 'property_display_field' ) . setValue ( this . organization . property_display_field )
40
43
this . defaultDisplayFieldsForm . get ( 'taxlot_display_field' ) . setValue ( this . organization . taxlot_display_field )
44
+ this . defaultDisplayFieldsForm . get ( 'default_reports_x_axis_options' ) . setValue ( this . organization . default_reports_x_axis_options . map ( ( c ) => c . id ) )
45
+ this . defaultDisplayFieldsForm . get ( 'default_reports_y_axis_options' ) . setValue ( this . organization . default_reports_y_axis_options . map ( ( c ) => c . id ) )
41
46
} )
42
47
this . _columnService . propertyColumns$ . pipe ( takeUntil ( this . _unsubscribeAll$ ) ) . subscribe ( ( propertyColumns ) => {
43
48
this . propertyColumns = propertyColumns
49
+ this . xAxisColumns = propertyColumns . filter ( ( c ) => ! c . related && ! c . pinnedLeft ) . sort ( ( a , b ) => naturalSort ( a . display_name , b . display_name ) )
50
+ this . yAxisColumns = this . xAxisColumns . filter ( ( c ) => [ 'area' , 'eui' , 'float' , 'integer' , 'number' ] . includes ( c . data_type ) || c . derived_column ) . sort ( ( a , b ) => naturalSort ( a . display_name , b . display_name ) )
44
51
} )
45
52
this . _columnService . taxLotColumns$ . pipe ( takeUntil ( this . _unsubscribeAll$ ) ) . subscribe ( ( taxLotColumns ) => {
46
53
this . taxLotColumns = taxLotColumns
@@ -56,6 +63,8 @@ export class DefaultDisplayFieldComponent implements OnDestroy, OnInit {
56
63
if ( this . defaultDisplayFieldsForm . valid ) {
57
64
this . organization . property_display_field = this . defaultDisplayFieldsForm . get ( 'property_display_field' ) . value
58
65
this . organization . taxlot_display_field = this . defaultDisplayFieldsForm . get ( 'taxlot_display_field' ) . value
66
+ this . organization . default_reports_x_axis_options = this . propertyColumns . filter ( ( c ) => this . defaultDisplayFieldsForm . get ( 'default_reports_x_axis_options' ) . value . includes ( c . id ) )
67
+ this . organization . default_reports_y_axis_options = this . propertyColumns . filter ( ( c ) => this . defaultDisplayFieldsForm . get ( 'default_reports_y_axis_options' ) . value . includes ( c . id ) )
59
68
this . _organizationService . updateSettings ( this . organization ) . subscribe ( )
60
69
}
61
70
}
0 commit comments