Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files Browse the repository at this point in the history
add filtering with given and family name. Fetch only active users.
Ioannis committed Mar 13, 2024
1 parent 0d06b3d commit a18c993
Showing 2 changed files with 13 additions and 4 deletions.
14 changes: 11 additions & 3 deletions app/src/Lib/Traits/IndexQueryTrait.php
@@ -29,6 +29,8 @@

namespace App\Lib\Traits;

use App\Lib\Enum\StatusEnum;
use Cake\Database\Expression\QueryExpression;
use Cake\ORM\Query;

trait IndexQueryTrait {
@@ -98,12 +100,12 @@ public function constructGetIndexContains(Query $query): object {
/**
* Build the Index Query
*
* @params boolean $mode True for OR and False for AND. AND is the default behavior
* @params boolean $picker_mode True for OR and False for AND. AND is the default behavior
*
* @return object Cake ORM Query object
* @since COmanage Registry v5.0.0
*/
public function getIndexQuery(bool $mode = false): object {
public function getIndexQuery(bool $picker_mode = false): object {
// $this->name = Models
$modelsName = $this->name;
// $table = the actual table object
@@ -116,7 +118,7 @@ public function getIndexQuery(bool $mode = false): object {
$newexp = $query->newExpr();
// The searchable attributes can have an AND or an OR conjunction. The first one is used from the filtering block
// while the second one from the picker vue module.
$newexp = $newexp->setConjunction($mode ? 'OR' : 'AND');
$newexp = $newexp->setConjunction($picker_mode ? 'OR' : 'AND');

if(!empty($link->attr) && !empty($link->value)) {
// If a link attribute is defined but no value is provided, then query
@@ -155,6 +157,12 @@ public function getIndexQuery(bool $mode = false): object {
}
}

if($picker_mode) {
// Get only the active People
// XXX Perhaps we need to make this a configuration
$query = $query->where(fn(QueryExpression $exp, Query $query) => $exp->in($table->getAlias().'.status', [StatusEnum::Active, StatusEnum::GracePeriod]));
}

// Append the new conditions
$query = $query->where($newexp);
}
@@ -95,7 +95,8 @@ export default {
const queryParams =
`identifier=${event.query}` +
`&mail=${event.query}` +
`&name=${event.query}` +
`&family=${event.query}` +
`&given=${event.query}` +
`&limit=10`

// AJAX Request

0 comments on commit a18c993

Please sign in to comment.