Skip to content

Feature cfm150 autocomplete #167

merged 38 commits into from Mar 21, 2024
Merged
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1999c79
Autocomplete widget added for selecting a Group member (CFM-150) (#164)
arlen Mar 6, 2024
fc0fdc4
add primevue autocomplete library dependency
Ioannis Mar 10, 2024
b0068fe
Improve/cleanup backend block search functionality
Ioannis Mar 10, 2024
66839d8
Decloupe where clause construction from join clause construction
Ioannis Mar 10, 2024
2dbc1a2
Improve filtering.Dynamically construct where clause using QueryExpre…
Ioannis Mar 10, 2024
060dfe6
Introduce IndexQueryTrait
Ioannis Mar 10, 2024
aa73e23
fix broken mveaType query.Improve Changelog.
Ioannis Mar 10, 2024
1311315
first get request
Ioannis Mar 10, 2024
a8ba9c9
add CoSettings PeoplePicker Configuration
Ioannis Mar 11, 2024
c0305b9
fix condition
Ioannis Mar 12, 2024
8b061f1
Improve FieldHelper
Ioannis Mar 12, 2024
17f32c7
Properly align grouped html controls
Ioannis Mar 12, 2024
4a805f8
Add type to emails and identifiers
Ioannis Mar 12, 2024
72171d4
Add loader.Improve fetch response handling
Ioannis Mar 13, 2024
bf41aa5
Added loader. Fixed duplicates.
Ioannis Mar 13, 2024
0d06b3d
typo fix
Ioannis Mar 13, 2024
a18c993
add filtering with given and family name. Fetch only active users.
Ioannis Mar 13, 2024
0954ba4
refactor frontend error handling
Ioannis Mar 13, 2024
941ffd2
add subfield-col css rule
Ioannis Mar 13, 2024
86fe75b
Peoplepikcer enum
Ioannis Mar 14, 2024
c8a0104
Provide access to configurations locally and globally.Improve fetch i…
Ioannis Mar 15, 2024
238de1a
fix url string
Ioannis Mar 15, 2024
0b3dec0
fix provide/inject functionality
Ioannis Mar 15, 2024
4acb787
Add a subcomponent for item-with-type and style things for easier vis…
arlen Mar 15, 2024
567d656
highlight query string
Ioannis Mar 15, 2024
f4009bb
highlighting fix
Ioannis Mar 15, 2024
a0ab929
sort methods by name
Ioannis Mar 15, 2024
af96643
Add item-id to autocomplete label and update color file (CFM-150)
arlen Mar 15, 2024
f885ca9
Add pager link "show more" to autocomplete (CFM-150)
arlen Mar 15, 2024
f02eaee
Fix label id reference for autocomplete field (CFM-150)
arlen Mar 15, 2024
134c18f
Implement pagination
Ioannis Mar 15, 2024
04a8bb2
filter the active GroupMembers
Ioannis Mar 16, 2024
e5f710a
Refactor GroupMembersTable::isMember Query construction
Ioannis Mar 16, 2024
d8eae4f
Update Group Member listing to expose add / edit / view in a modal wi…
arlen Mar 19, 2024
a8c32b0
Move the person picker to the index of the Group Member list and laun…
arlen Mar 21, 2024
123702d
Add scrolling to the autocomplete people picker (CFM-150)
arlen Mar 21, 2024
2ee562c
removed trailing semi colon
Ioannis Mar 21, 2024
c1c0f69
Change default modal title (CFM-150)
arlen Mar 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
fix broken mveaType query.Improve Changelog.
Ioannis committed Mar 13, 2024
commit aa73e232b7e6d4f2a9c3120d758c83c17305c6d6
7 changes: 6 additions & 1 deletion app/src/Controller/ApiV2Controller.php
@@ -305,8 +305,13 @@ public function index() {
// $table = the actual table object
$table = $this->$modelsName;

$pickerMode = false;
if($this->request->getQuery('picker') !== null
&& $this->request->is('restful')) {
$pickerMode = filter_var($this->request->getQuery('picker'), FILTER_VALIDATE_BOOLEAN);
}
// Construct the Query
$query = $this->getIndexQuery();
$query = $this->getIndexQuery($pickerMode);

// This magically makes REST calls paginated... can use eg direction=,
// sort=, limit=, page=
25 changes: 19 additions & 6 deletions app/src/Lib/Traits/IndexQueryTrait.php
@@ -57,6 +57,7 @@ public function constructGetIndexContains(Query $query): object {
// Examples:
// 1. GET https://example.com/registry-pe/api/v2/people?co_id=2&limit=10&extended=PrimaryName,EmailAddresses,Identifiers
// 2. GET https://example.com/registry-pe/api/v2/people?co_id=2&limit=10&extended=on
// 2. GET https://example.com/registry-pe/api/v2/people?co_id=2&limit=10&extended=all
// 1. GET https://example.com/registry-pe/api/v2/people?co_id=2&limit=10
if($this->request->is('restful')|| $this->request->is('ajax')) {
// Restfull and ajax do not include the IndexContains by default.
@@ -67,9 +68,20 @@ public function constructGetIndexContains(Query $query): object {
filter_var($this->request->getQuery('extended'), FILTER_VALIDATE_BOOLEAN)
) {
$containClause = $table->getIndexContains();
} elseif($this->request->getQuery('extended')
&& \is_string($this->request->getQuery('extended'))) {
// This is a string. We will parse the csv and continue
} elseif(
$this->request->getQuery('extended') &&
$this->request->getQuery('extended') === 'all'
) {
// Get all the associated models
$associations = $table->associations();
foreach($associations->getIterator() as $a) {
$containClause[] = $a->getName();
}
} elseif (
$this->request->getQuery('extended')
&& \is_string($this->request->getQuery('extended'))
) {
// Get ONLY the associated models requested
$associations = $table->associations();
$containQueryList = str_getcsv($this->request->getQuery('extended'));
foreach($associations->getIterator() as $a) {
@@ -86,11 +98,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
*
* @return object Cake ORM Query object
* @since COmanage Registry v5.0.0
*/
public function getIndexQuery(): object {
public function getIndexQuery(bool $mode = false): object {
// $this->name = Models
$modelsName = $this->name;
// $table = the actual table object
@@ -101,9 +114,9 @@ public function getIndexQuery(): object {
$query = $table->find($this->paginate['finder'] ?? 'all');
// Get a pointer to my expressions list
$newexp = $query->newExpr();
// The searchable attributes can have an AND or an OR conjuction. The first one is used from the filtering block
// 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(true ? 'AND' : 'OR');
$newexp = $newexp->setConjunction($mode ? 'OR' : 'AND');

if(!empty($link->attr) && !empty($link->value)) {
// If a link attribute is defined but no value is provided, then query
5 changes: 3 additions & 2 deletions app/src/Lib/Traits/SearchFilterTrait.php
@@ -68,8 +68,9 @@ public function addJoins(Query $query, string $attribute, ServerRequest $request
'table' => $mtable_name,
'conditions' => [
$mtable_alias . '.' . $fk . '=' . $this->_alias . '.id',
$mtable_alias . '.' . 'deleted IS NOT TRUE',
$mtable_alias . '.' . $changelog_fk . ' IS NULL'
// XXX Moved to changelong Behavior
// $mtable_alias . '.' . 'deleted IS NOT TRUE',
// $mtable_alias . '.' . $changelog_fk . ' IS NULL'
],
'type' => 'INNER'
]]);
21 changes: 16 additions & 5 deletions app/src/Model/Behavior/ChangelogBehavior.php
@@ -29,7 +29,10 @@

namespace App\Model\Behavior;

use Cake\Datasource\EntityInterface;
use Cake\Event\Event;
use Cake\ORM\Behavior;
use Cake\ORM\Query;
use Cake\Utility\Inflector;

class ChangelogBehavior extends Behavior
@@ -44,7 +47,7 @@ class ChangelogBehavior extends Behavior
* @return boolean True on success
*/

public function beforeDelete(\Cake\Event\Event $event, $entity, \ArrayObject $options) {
public function beforeDelete(Event $event, $entity, \ArrayObject $options) {
if(isset($options['useHardDelete']) && $options['useHardDelete']) {
// Hard delete requested, so just return
return true;
@@ -74,7 +77,7 @@ public function beforeDelete(\Cake\Event\Event $event, $entity, \ArrayObject $op
// But return success
return true;
}

/**
* Adjust find query conditions for changelog.
*
@@ -85,7 +88,7 @@ public function beforeDelete(\Cake\Event\Event $event, $entity, \ArrayObject $op
* @param boolean $primary Whether or not this is the root query (vs an associated query)
*/

public function beforeFind(\Cake\Event\Event $event, \Cake\ORM\Query $query, \ArrayObject $options, bool $primary) {
public function beforeFind(Event $event, Query $query, \ArrayObject $options, bool $primary) {
if(isset($options['archived']) && $options['archived']) {
// Archived records requested (including possiblf expunge), so just return
return true;
@@ -100,7 +103,15 @@ public function beforeFind(\Cake\Event\Event $event, \Cake\ORM\Query $query, \Ar

// XXX add support for archived, revision, etc
// XXX if specific id is requested, do not modify query


if(!empty($query->clause('join'))) {
foreach($query->clause('join') as $mdl => $opts) {
$ascParentfk = Inflector::singularize($opts['table']) . "_id";

$query->where([$opts['alias'] . '.deleted IS NOT true'])
->where([$opts['alias'] . '.' . $ascParentfk . ' IS NULL']);
}
}
// We use IS NOT TRUE to check for null || false, since pre-Changelog data
// may have null instead of false.
// (Alternately we could join two clauses for false || IS NULL.)
@@ -121,7 +132,7 @@ public function beforeFind(\Cake\Event\Event $event, \Cake\ORM\Query $query, \Ar
* @param ArrayObject $options Options
*/

public function beforeSave(\Cake\Event\Event $event, \Cake\Datasource\EntityInterface $entity, \ArrayObject $options) {
public function beforeSave(Event $event, EntityInterface $entity, \ArrayObject $options) {
// XXX prevent updates to deleted and archived records
// Cake Book suggests doing this with Application Rules... can we define those in the Behavior?
// or perhaps in beforeMarshal? https://book.cakephp.org/3.0/en/orm/saving-data.html#modifying-request-data-before-building-entities
20 changes: 12 additions & 8 deletions app/templates/element/autocompletePeople.php
@@ -26,9 +26,9 @@
*/

// Get parameters
$fieldName = $fieldName ?? "";
$type = $type ?? "";
$htmlId = $htmlId ?? "";
$fieldName = $fieldName ?? '';
$type = $type ?? '';
$htmlId = $htmlId ?? '';

// Get the CSRF Token in JavaScript
$token = $this->request->getAttribute('csrfToken');
@@ -54,13 +54,17 @@
minLength: 2, // XXX probably should be set by config and default to 3
htmlId: '<?= $htmlId ?>'
},
error: '',
core: {
webroot: '<?= $this->request->getAttribute('webroot') ?>'
},
txt: JSON.parse('<?= json_encode($vueHelper->locales()) ?>')
error: ''
coId: <?=$vv_cur_co ?>
}
},
provide: {
txt: JSON.parse('<?= json_encode($vueHelper->locales()) ?>')
api: {
webroot: '<?= $this->request->getAttribute('webroot') ?>',
searchPeople: `<?= $this->request->getAttribute('webroot') ?>/api/ajax/v2/people?co_id=<?= $vv_cur_co ?>?PrimaryName,Identifiers,EmailAddresses&picker=on`,
}
}
components: {
AutocompletePeople
},
2 changes: 1 addition & 1 deletion app/templates/element/filter.php
@@ -246,7 +246,7 @@
<div class="filter-boolean <?= empty($options['active']) ? 'filter-inactive' : 'filter-active' ?>">
<div class="form-check form-check-inline">
<?php
print $this->Form->label(!empty($columns[$key]['label']) ? $columns[$key]['label'] : $key);
print $this->Form->label($options['label'] ?? $key);
print $this->Form->checkbox($key, [
'id' => str_replace("_", "-", $key),
'class' => 'form-check-input',
2 changes: 1 addition & 1 deletion app/templates/element/mveaJs.php
@@ -78,7 +78,7 @@
var entityTypeIdRef = entityType + '_id';
let url = '<?=
$this->Url->build(['controller' => 'api/ajax', 'action' => 'v2'])
?>/' + mveaType + '?' + entityTypeIdRef + '=<?php print $parentId ?>&extended';
?>/' + mveaType + '?' + entityTypeIdRef + '=<?php print $parentId ?>&extended=all';
let xhr = callRegistryAPI(
url,
'GET',