Compare commits

...

5 Commits

7 changed files with 55 additions and 5 deletions

View File

@ -97,6 +97,8 @@ class CRUDComponent extends Component
if ($sort[0] != $this->Table->getAlias()) {
$sort[0] = Inflector::camelize(Inflector::pluralize($sort[0]));
}
} else {
array_unshift($sort, $this->Table->getAlias());
}
$sort = implode('.', $sort);
$query->order($sort . ' ' . $direction);

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

@ -11,7 +11,15 @@ use Cake\Http\Exception\NotFoundException;
class UsersController extends AppController
{
public $filterFields = ['Individuals.uuid', 'username', 'Individuals.email', 'Individuals.first_name', 'Individuals.last_name', 'Organisations.name', 'Organisations.nationality'];
public $filterFields = [
'Individuals.uuid',
'username',
'Individuals.email',
'Individuals.first_name',
'Individuals.last_name',
['name' => 'Organisations.id', 'multiple' => true, 'options' => 'getAllOrganisations', 'select2' => true],
'Organisations.nationality'
];
public $quickFilterFields = ['Individuals.uuid', ['username' => true], ['Individuals.first_name' => true], ['Individuals.last_name' => true], 'Individuals.email'];
public $containFields = ['Individuals', 'Roles', 'UserSettings', 'Organisations', 'OrgGroups'];

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');
}
}

View File

@ -292,4 +292,9 @@ class UsersTable extends AppTable
}
return true;
}
public function getAllOrganisations($currentUser) {
$this->Individuals = TableRegistry::get('Individuals');
return $this->Individuals->getAllOrganisations($currentUser);
}
}

View File

@ -54,7 +54,27 @@ echo $this->element('genericElements/IndexTable/index_table', [
return true;
},
],
'skip_full_reload' => true
'skip_full_reload' => true,
'confirm' => [
'enable' => [
'titleHtml' => __('Confirm disabling the user?'),
'type' => 'confirm-warning',
'bodyHtml' => __('You\'re about to change the state of the user {{0}}.'),
'confirmText' => __('Disable user'),
'arguments' => [
'bodyHtml' => ['individual.email'],
]
],
'disable' => [
'titleHtml' => __('Confirm enabling the user?'),
'type' => 'confirm-success',
'bodyHtml' => __('You\'re about to change the state of the user {{0}}.'),
'confirmText' => __('Enable user'),
'arguments' => [
'bodyHtml' => ['individual.email'],
]
]
]
]
],
[
@ -168,5 +188,4 @@ echo $this->element('genericElements/IndexTable/index_table', [
]
]
]);
echo '</div>';
?>

View File

@ -102,7 +102,7 @@ $filteringTags = '';
if ($taggingEnabled) {
$helpText = $this->Bootstrap->node('sup', [
'class' => ['ms-1 fa fa-info'],
'title' => __('Supports negation matches (with the `!` character) and LIKE matches (with the `%` character).&#10;Example: `!exportable`, `%able`'),
'title' => __('Supports negation matches (with the `!` character) and LIKE matches (with the `%` character). Example: `!exportable`, `%able`'),
'data-bs-toggle' => 'tooltip',
]);
$filteringTags = $this->Bootstrap->node('h5', [