chg: [individuals:filtering] Added dropdown for organisation filtering

perm_community_admin
Sami Mokaddem 2024-04-02 14:02:03 +02:00
parent acb8fa21d3
commit 1111290cea
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
2 changed files with 17 additions and 1 deletions

View File

@ -14,7 +14,15 @@ use Cake\ORM\TableRegistry;
class IndividualsController extends AppController
{
public $quickFilterFields = ['uuid', ['email' => true], ['first_name' => true], ['last_name' => true], 'position'];
public $filterFields = ['uuid', 'email', 'first_name', 'last_name', 'position', 'Organisations.id', 'Alignments.type'];
public $filterFields = [
'uuid',
'email',
'first_name',
'last_name',
'position',
'Alignments.type',
['name' => 'Organisations.id', 'multiple' => true, 'options' => 'getAllOrganisations', 'select2' => true],
];
public $containFields = ['Alignments' => 'Organisations'];
public $statisticsFields = ['position'];

View File

@ -3,6 +3,7 @@
namespace App\Model\Table;
use App\Model\Table\AppTable;
use Cake\Utility\Hash;
use Cake\ORM\Table;
use Cake\Validation\Validator;
use Cake\ORM\Query;
@ -137,4 +138,11 @@ class IndividualsTable extends AppTable
)->all()->extract('individual_id')->toArray();
return $validIndividualIds;
}
public function getAllOrganisations($currentUser): array
{
$this->Organisations = \Cake\ORM\TableRegistry::getTableLocator()->get('Organisations');
$orgs = $this->Organisations->find()->select(['id', 'name'])->all()->toList();
return Hash::combine($orgs, '{n}.id', '{n}.name');
}
}