chg: [individuals:filtering] Added dropdown for organisation filtering
parent
acb8fa21d3
commit
1111290cea
|
@ -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'];
|
||||
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue