@@ -42,7 +42,7 @@ import {
4242 InviteMutationComponent ,
4343 PaginationFilterBaseComponent ,
4444 PictureNameTagsComponent ,
45- ToggleFilterComponent
45+ SmartToggleFilterComponent
4646} from '@gauzy/ui-core/shared' ;
4747import { EmployeeTimeTrackingStatusComponent , EmployeeWorkStatusComponent } from './table-components' ;
4848
@@ -182,8 +182,13 @@ export class EmployeesComponent extends PaginationFilterBaseComponent implements
182182 . componentLayout$ ( this . viewComponentName )
183183 . pipe (
184184 distinctUntilChange ( ) ,
185- tap ( ( componentLayout ) => ( this . dataLayoutStyle = componentLayout ) ) ,
186- tap ( ( ) => this . refreshPagination ( ) ) ,
185+ tap ( ( componentLayout : ComponentLayoutStyleEnum ) => {
186+ this . dataLayoutStyle = componentLayout ;
187+ this . _loadSmartTableSettings ( ) ;
188+ this . _additionalColumns ( ) ;
189+ this . _registerDataTableColumns ( ) ;
190+ this . refreshPagination ( ) ;
191+ } ) ,
187192 filter ( ( componentLayout ) => componentLayout === ComponentLayoutStyleEnum . CARDS_GRID ) ,
188193 tap ( ( ) => ( this . employees = [ ] ) ) ,
189194 tap ( ( ) => this . employees$ . next ( true ) ) ,
@@ -685,7 +690,10 @@ export class EmployeesComponent extends PaginationFilterBaseComponent implements
685690 } ,
686691 filter : {
687692 type : 'custom' ,
688- component : InputFilterComponent
693+ component : InputFilterComponent ,
694+ config : {
695+ initialValueInput : this . filters ?. where ?. user ?. name ?? null
696+ }
689697 } ,
690698 filterFunction : this . _getFilterFunction ( 'user.name' )
691699 } ,
@@ -700,7 +708,10 @@ export class EmployeesComponent extends PaginationFilterBaseComponent implements
700708 isFilterable : true ,
701709 filter : {
702710 type : 'custom' ,
703- component : InputFilterComponent
711+ component : InputFilterComponent ,
712+ config : {
713+ initialValueInput : this . filters ?. where ?. user ?. email ?? null
714+ }
704715 } ,
705716 filterFunction : this . _getFilterFunction ( 'user.email' )
706717 } ,
@@ -762,9 +773,28 @@ export class EmployeesComponent extends PaginationFilterBaseComponent implements
762773 width : '5%' ,
763774 filter : {
764775 type : 'custom' ,
765- component : ToggleFilterComponent
776+ component : SmartToggleFilterComponent ,
777+ config : {
778+ initialChoice :
779+ this . filters ?. where ?. isTrackingEnabled === true
780+ ? 'accept'
781+ : this . filters ?. where ?. isTrackingEnabled === false
782+ ? 'deny'
783+ : null ,
784+ acceptValue : { field : 'isTrackingEnabled' , value : true } ,
785+ denyValue : { field : 'isTrackingEnabled' , value : false }
786+ }
787+ } ,
788+ filterFunction : ( data : { field : string ; value : boolean } | null ) => {
789+ if ( ! data ) {
790+ // Reset filter
791+ this . setFilterWithServiceFalse ( { field : 'isTrackingEnabled' , search : null } ) ;
792+ return false ;
793+ }
794+
795+ this . setFilterWithServiceFalse ( { field : data . field , search : data . value } ) ;
796+ return false ;
766797 } ,
767- filterFunction : this . _getFilterFunction ( 'isTrackingEnabled' ) ,
768798 renderComponent : EmployeeTimeTrackingStatusComponent ,
769799 componentInitFunction : ( instance : EmployeeTimeTrackingStatusComponent , cell : Cell ) => {
770800 instance . rowData = cell . getRow ( ) . getData ( ) ;
@@ -781,7 +811,10 @@ export class EmployeesComponent extends PaginationFilterBaseComponent implements
781811 isSortable : false ,
782812 filter : {
783813 type : 'custom' ,
784- component : EmploymentTypeFilterComponent
814+ component : EmploymentTypeFilterComponent ,
815+ config : {
816+ initialValueInput : this . filters ?. where ?. organizationEmploymentTypes ?? null
817+ }
785818 } ,
786819 filterFunction : ( employmentTypes : IOrganizationEmploymentType [ ] ) => {
787820 const typeIds = employmentTypes . map ( ( t ) => t . id ) ;
@@ -806,11 +839,27 @@ export class EmployeesComponent extends PaginationFilterBaseComponent implements
806839 isSortable : false ,
807840 filter : {
808841 type : 'custom' ,
809- component : ToggleFilterComponent
842+ component : SmartToggleFilterComponent ,
843+ config : {
844+ initialChoice : this . filters ?. where ?. isActive
845+ ? 'accept'
846+ : this . filters ?. where ?. isArchived
847+ ? 'deny'
848+ : null ,
849+ acceptValue : { isActive : true , isArchived : false } ,
850+ denyValue : { isActive : false , isArchived : true }
851+ }
810852 } ,
811- filterFunction : ( isActive : boolean ) => {
812- this . setFilter ( { field : 'isActive' , search : isActive } ) ;
813- return isActive ;
853+ filterFunction : ( value : { isActive ?: boolean ; isArchived ?: boolean } | null ) => {
854+ if ( ! value ) {
855+ // Reset filter
856+ this . setFilter ( { field : 'isActive' , search : null } ) ;
857+ this . setFilter ( { field : 'isArchived' , search : null } ) ;
858+ return false ;
859+ }
860+ if ( 'isActive' in value ) this . setFilter ( { field : 'isActive' , search : value . isActive } ) ;
861+ if ( 'isArchived' in value ) this . setFilter ( { field : 'isArchived' , search : value . isArchived } ) ;
862+ return false ;
814863 } ,
815864 renderComponent : EmployeeWorkStatusComponent ,
816865 componentInitFunction : ( instance : EmployeeWorkStatusComponent , cell : Cell ) => {
@@ -897,11 +946,27 @@ export class EmployeesComponent extends PaginationFilterBaseComponent implements
897946 hide : allowScreenshotCapture === false ,
898947 filter : {
899948 type : 'custom' ,
900- component : ToggleFilterComponent
949+ component : SmartToggleFilterComponent ,
950+ config : {
951+ initialChoice :
952+ this . filters ?. where ?. allowScreenshotCapture === true
953+ ? 'accept'
954+ : this . filters ?. where ?. allowScreenshotCapture === false
955+ ? 'deny'
956+ : null ,
957+ acceptValue : { field : 'allowScreenshotCapture' , value : true } ,
958+ denyValue : { field : 'allowScreenshotCapture' , value : false }
959+ }
901960 } ,
902- filterFunction : ( isEnable : boolean ) => {
903- this . setFilter ( { field : 'allowScreenshotCapture' , search : isEnable } ) ;
904- return isEnable ;
961+ filterFunction : ( data : { field : string ; value : boolean } | null ) => {
962+ if ( ! data ) {
963+ // Reset filter
964+ this . setFilterWithServiceFalse ( { field : 'allowScreenshotCapture' , search : null } ) ;
965+ return false ;
966+ }
967+
968+ this . setFilterWithServiceFalse ( { field : data . field , search : data . value } ) ;
969+ return false ;
905970 } ,
906971 renderComponent : AllowScreenshotCaptureComponent , // The component to render the column
907972 componentInitFunction : ( instance : AllowScreenshotCaptureComponent , cell : Cell ) => {
0 commit comments