Skip to content

Commit

Permalink
add CoSettings PeoplePicker Configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Mar 12, 2024
1 parent cb0e699 commit 69dec32
Show file tree
Hide file tree
Showing 12 changed files with 356 additions and 94 deletions.
5 changes: 4 additions & 1 deletion app/config/schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@
"required_fields_address": { "type": "string", "size": 160 },
"required_fields_name": { "type": "string", "size": 160 },
"search_global_limit": { "type": "integer" },
"search_global_limited_models": { "type": "boolean" }
"search_global_limited_models": { "type": "boolean" },
"person_picker_email_type": { "type": "integer" },
"person_picker_identifier_type": { "type": "integer" },
"person_picker_display_types": { "type": "boolean" }
},
"indexes": {
"co_settings_i1": { "columns": [ "co_id" ]},
Expand Down
12 changes: 12 additions & 0 deletions app/resources/locales/en_US/field.po
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ msgstr "Given Name"
msgid "group_membership"
msgstr "{0} Membership in {1}"

msgid "hidden"
msgstr "Hidden"

msgid "honorific"
msgstr "Honorific"

Expand Down Expand Up @@ -342,6 +345,15 @@ msgstr "Name Permitted Fields"
msgid "CoSettings.permitted_fields_telephone_number"
msgstr "Telephone Number Permitted Fields"

msgid "CoSettings.person_picker_display_fields"
msgstr "Person Picker Display Fields"

msgid "CoSettings.person_picker_display_fields.desc"
msgstr "This determines what fields to display alongside the person name when using the autocomplete Person Picker (e.g. for selecting Group members)."

msgid "CoSettings.person_picker_display_types"
msgstr "Display field types in the picker"

msgid "CoSettings.required_fields_address"
msgstr "Address Required Fields"

Expand Down
2 changes: 1 addition & 1 deletion app/src/Controller/ApiV2Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public function index() {
$this->set($this->tableName, $this->paginate($query));

// Let the view render
$this->render($this->request->is('ajax') ? '/Standard/api/ajax/v2/json/index' : '/Standard/api/v2/json/index');
$this->render('/Standard/api/v2/json/index');
}

/**
Expand Down
10 changes: 7 additions & 3 deletions app/src/Controller/GroupMembersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
namespace App\Controller;

// XXX not doing anything with Log yet
use Cake\Event\EventInterface;
use Cake\Http\Response;
use Cake\Log\Log;

class GroupMembersController extends StandardController {
Expand All @@ -38,15 +40,17 @@ class GroupMembersController extends StandardController {
'People.primary_name.name' => 'asc'
]
];

/**
* Callback run prior to the request render.
*
* @param EventInterface $event Cake Event
*
* @return Response|void
* @since COmanage Registry v5.0.0
* @param EventInterface $event Cake Event
*/

public function beforeRender(\Cake\Event\EventInterface $event) {
public function beforeRender(EventInterface $event) {
// Pull the Group name for breadcrumb rendering

$link = $this->getPrimaryLink(true);
Expand Down
6 changes: 3 additions & 3 deletions app/src/Controller/StandardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
namespace App\Controller;

use Cake\Database\Expression\QueryExpression;
use Cake\ORM\TableRegistry;
use InvalidArgumentException;
use \Cake\Http\Exception\BadRequestException;
use \App\Lib\Enum\ProvisioningContextEnum;
Expand Down Expand Up @@ -648,10 +649,9 @@ protected function populateAutoViewVars(object $obj=null) {
case 'auxiliary':
// XXX add list as in match?
case 'select':
// We assume $modelName has a direct relationship to $avv['model']
$avvmodel = $avv['model'];
$this->$avvmodel = $this->fetchTable($avvmodel);
$this->$avvmodel = TableRegistry::getTableLocator()->get($avvmodel);

if($avv['type'] == 'auxiliary') {
$query = $this->$avvmodel->find();
} else {
Expand Down
40 changes: 38 additions & 2 deletions app/src/Model/Table/CoSettingsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class CoSettingsTable extends Table {
use \App\Lib\Traits\PermissionsTrait;
use \App\Lib\Traits\PrimaryLinkTrait;
use \App\Lib\Traits\TableMetaTrait;
use \App\Lib\Traits\ValidationTrait;

/**
* Perform Cake Model initialization.
Expand Down Expand Up @@ -82,10 +83,18 @@ public function initialize(array $config): void {
->setClassName('Types')
->setForeignKey('default_email_address_type_id')
->setProperty('default_email_address_type');
$this->belongsTo('PersonPickerEmailAddressType')
->setClassName('Types')
->setForeignKey('person_picker_email_address_type_id')
->setProperty('person_picker_email_address_type');
$this->belongsTo('DefaultIdentifierTypes')
->setClassName('Types')
->setForeignKey('default_identifier_type_id')
->setProperty('default_identifier_type');
$this->belongsTo('PersonPickerIdentifierTypes')
->setClassName('Types')
->setForeignKey('person_picker_identifier_type_id')
->setProperty('person_picker_identifier_type');
$this->belongsTo('DefaultNameTypes')
->setClassName('Types')
->setForeignKey('default_name_type_id')
Expand All @@ -102,7 +111,7 @@ public function initialize(array $config): void {
->setClassName('Types')
->setForeignKey('default_url_type_id')
->setProperty('default_url_type');

$this->setDisplayField('co_id');

$this->setPrimaryLink('co_id');
Expand All @@ -123,6 +132,14 @@ public function initialize(array $config): void {
'type' => 'type',
'attribute' => 'Identifiers.type'
],
'personPickerEmailAddressTypes' => [
'type' => 'type',
'attribute' => 'EmailAddresses.type'
],
'personPickerIdentifierTypes' => [
'type' => 'type',
'attribute' => 'Identifiers.type'
],
'defaultNameTypes' => [
'type' => 'type',
'attribute' => 'Names.type'
Expand Down Expand Up @@ -197,6 +214,9 @@ public function addDefaults(int $coId): int {
'default_url_type_id' => null,
'permitted_fields_name' => PermittedNameFieldsEnum::HGMFS,
'permitted_fields_telephone_number' => PermittedTelephoneNumberFieldsEnum::CANE,
'person_picker_email_type' => null,
'person_picker_identifier_type' => null,
'person_picker_display_types' => true,
'required_fields_address' => RequiredAddressFieldsEnum::Street,
'required_fields_name' => RequiredNameFieldsEnum::Given,
'search_global_limit' => DEF_GLOBAL_SEARCH_LIMIT,
Expand Down Expand Up @@ -347,6 +367,22 @@ public function validationDefault(Validator $validator): Validator {
]);
$validator->notEmptyString('search_global_limit');

return $validator;
$validator->add('person_picker_email_type', [
'content' => ['rule' => 'isInteger']
]);
$validator->allowEmptyString('person_picker_email_type');

$validator->add('person_picker_identifier_type', [
'content' => ['rule' => 'isInteger']
]);
$validator->allowEmptyString('person_picker_identifier_type');


$validator->add('person_picker_display_types', [
'content' => ['rule' => 'boolean']
]);
$validator->allowEmptyString('person_picker_display_types');

return $validator;
}
}
16 changes: 14 additions & 2 deletions app/src/Model/Table/GroupMembersTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,25 @@ public function initialize(array $config): void {
$this->setRequiresCO(true);

$this->setEditContains(['Groups', 'People.PrimaryName']);

$this->setViewContains(['Groups', 'People.PrimaryName']);

$this->setIndexContains([
'GroupNestings' => 'Groups',
'Groups',
'People.PrimaryName'
]);


$this->setAutoViewVars([
'cosettings' => [
'type' => 'auxiliary',
'model' => 'CoSettings'
],
'types' => [
'type' => 'auxiliary',
'model' => 'Types'
]
]);

$this->setPermissions([
// XXX update for couAdmins, group owners, etc
// Actions that operate over an entity (ie: require an $id)
Expand Down
Loading

0 comments on commit 69dec32

Please sign in to comment.