2020-05-29 13:41:58 +02:00
< ? php
echo $this -> element ( 'genericElements/IndexTable/index_table' , [
'data' => [
'data' => $data ,
'top_bar' => [
'children' => [
2020-06-21 21:33:08 +02:00
[
'type' => 'simple' ,
'children' => [
'data' => [
'type' => 'simple' ,
'text' => __ ( 'Add individual' ),
'popover_url' => '/individuals/add'
]
]
],
2021-01-11 12:48:58 +01:00
[
'type' => 'context_filters' ,
'context_filters' => $filteringContexts
],
2020-05-29 13:41:58 +02:00
[
'type' => 'search' ,
2021-11-10 15:31:09 +01:00
'button' => __ ( 'Search' ),
2020-05-29 13:41:58 +02:00
'placeholder' => __ ( 'Enter value to search' ),
'data' => '' ,
2021-08-30 15:11:21 +02:00
'searchKey' => 'value' ,
'allowFilering' => true
2021-10-20 09:39:12 +02:00
],
[
'type' => 'table_action' ,
2020-05-29 13:41:58 +02:00
]
]
],
'fields' => [
[
'name' => '#' ,
'sort' => 'id' ,
'data_path' => 'id' ,
],
[
'name' => __ ( 'Email' ),
'sort' => 'email' ,
'data_path' => 'email' ,
],
[
'name' => __ ( 'First Name' ),
'sort' => 'first_name' ,
'data_path' => 'first_name' ,
],
[
'name' => __ ( 'Last Name' ),
'sort' => 'last_name' ,
'data_path' => 'last_name' ,
],
2022-11-13 11:09:34 +01:00
[
'name' => __ ( 'Associated User(s)' ),
'sort' => 'user' ,
'data_path' => 'user' ,
'element' => 'user'
],
2020-05-29 13:41:58 +02:00
[
'name' => __ ( 'Alignments' ),
'data_path' => 'alignments' ,
'element' => 'alignments' ,
'scope' => $alignmentScope
],
2021-08-30 15:11:21 +02:00
[
'name' => __ ( 'Tags' ),
'data_path' => 'tags' ,
'element' => 'tags' ,
],
2020-05-29 13:41:58 +02:00
[
'name' => __ ( 'UUID' ),
'sort' => 'uuid' ,
'data_path' => 'uuid' ,
'placeholder' => __ ( 'Leave empty to auto generate' )
],
],
'title' => __ ( 'ContactDB Individuals Index' ),
'description' => __ ( 'A list of individuals known by your Cerebrate instance. This list can get populated either directly, by adding new individuals or by fetching them from trusted remote sources. Additionally, users created for the platform will always have an individual identity.' ),
'actions' => [
[
'url' => '/individuals/view' ,
'url_params_data_paths' => [ 'id' ],
'icon' => 'eye'
],
[
2021-01-11 16:28:07 +01:00
'open_modal' => '/individuals/edit/[onclick_params_data_path]' ,
'modal_params_data_path' => 'id' ,
2022-10-31 14:42:58 +01:00
'icon' => 'edit' ,
'complex_requirement' => [
'function' => function ( $row , $options ) use ( $loggedUser , $editableIds ) {
if ( $loggedUser [ 'role' ][ 'perm_admin' ] || ( $editableIds && in_array ( $row [ 'id' ], $editableIds ))) {
return true ;
}
return false ;
}
]
2020-05-29 13:41:58 +02:00
],
[
2021-01-11 16:28:07 +01:00
'open_modal' => '/individuals/delete/[onclick_params_data_path]' ,
'modal_params_data_path' => 'id' ,
2022-10-31 14:42:58 +01:00
'icon' => 'trash' ,
'complex_requirement' => [
'function' => function ( $row , $options ) use ( $loggedUser ) {
2023-03-13 08:05:32 +01:00
if ( ! empty ( $row [ 'user' ])) { // cannot delete individuals with associated user(s)
return false ;
}
2022-10-31 14:42:58 +01:00
return ( bool ) $loggedUser [ 'role' ][ 'perm_admin' ];
}
]
2021-01-11 16:28:07 +01:00
],
2020-05-29 13:41:58 +02:00
]
]
]);
echo '</div>' ;
2021-10-20 09:39:12 +02:00
?>