Skip to content

Add EIS badges to Person Canvas (CFM-417) #364

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions app/src/Controller/PeopleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,29 @@ public function beforeRender(\Cake\Event\EventInterface $event) {
$this->set('vv_default_name_type', $settings->default_name_type_id);
}

if(!$this->request->is('restful') && $this->request->getParam('action') == 'edit') {
// Get the external identity sources for this person
$externalIdentitySources = $this->fetchTable('ExternalIdentities')
Copy link
Contributor

@benno benno Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look above we use TableRegistry and then run the find on the table as a second action. This is a bit more general of a solution (less work in contexts where we run multiple actions on a table, more generic where fetchTable() isn't a thing) though some older code does still use fetchTable(). Minimally, adjacent code shouldn't do the same thing two different ways.

->find()
->where(['ExternalIdentities.person_id' => $this->request->getParam('pass.0')])
->contain([
'ExtIdentitySourceRecords' => [
'ExternalIdentitySources'
]
])
->all();

// Create a lookup table for badging EIS descriptions on Person Canvas MVEAS
$eisLookupTable = [];
foreach ($externalIdentitySources as $extIdentity) {
if (!empty($extIdentity->ext_identity_source_record) &&
!empty($extIdentity->ext_identity_source_record->external_identity_source)) {
$eisLookupTable[$extIdentity->id] = $extIdentity->ext_identity_source_record->external_identity_source->description;
}
}
Comment on lines +97 to +112
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your query will be simpler if you always pull all EIS for the CO, instead of walking from the Person to the EIS Records that the Person is associated with. ie: you're doing more work to get a more exact answer, but it's probably an over-optimization. Something like

$ExternalIdentitySources = TableRegistry::getTableLocator()->get('ExternalIdentitySources');

$eis = $ExternalIdentitySources->find()->where('co_id' => $this->getCOID();

You can then use Cake's Hash utility to create your lookup table. I believe combine() will do what you want, but you should figure it out yourself because it will be a good learning experience :)


$this->set('vv_external_identity_sources', $eisLookupTable);
}
return parent::beforeRender($event);
}
}
3 changes: 2 additions & 1 deletion app/templates/element/mveaJs.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
mveaController: '<?= Cake\Utility\Inflector::dasherize($mveaController) ?>',
mveaTitle: '<?= $title ?>',
webroot: '<?= $this->request->getAttribute('webroot') ?>',
action: '<?= $vv_action ?>'
action: '<?= $vv_action ?>',
externalIdentitySources: <?= json_encode($vv_external_identity_sources ?? null) ?>
},
txt: JSON.parse('<?= json_encode($vueHelper->locales()) ?>'),
isLoading: true,
Expand Down
1 change: 1 addition & 0 deletions app/webroot/css/co-base.css
Original file line number Diff line number Diff line change
Expand Up @@ -2703,6 +2703,7 @@ html.dark-mode .btn-default:active {
margin-top: auto;
margin-bottom: auto;
line-height: 1.2em;
border: 1px solid var(--cmg-color-bg-006);
}
.bg-light {
color: var(--cmg-color-highlight-005);
Expand Down
35 changes: 35 additions & 0 deletions app/webroot/js/comanage/components/mvea/mvea-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ export default {
var componentReference = 'mvea' + this.core.mveaType;
this.$parent.$parent.launchModal(this.core.mveaTitle, this.mveaLink, componentReference);
});
},
getEisDescription(externalIdentityId) {
return externalIdentityId ? this.core?.externalIdentitySources[externalIdentityId] : null;
}
},
mounted() {
Expand Down Expand Up @@ -106,6 +109,10 @@ export default {
<span v-if="this.mvea.primary_name" class="mr-1 badge bg-outline-secondary primary">{{ this.txt['field.primary'] }}</span>
<span class="mr-1 badge bg-light">{{ this.mvea.type.display_name }}</span>
<span v-if="this.mvea.language" class="mr-1 badge bg-light">{{ calcLangHR(this.mvea.language) }}</span>
<span v-if="getEisDescription(this.mvea?.source_name?.external_identity_id)"
class="mr-1 badge bg-light badge-eis">
{{ getEisDescription(this.mvea?.source_name?.external_identity_id) }}
</span>
</div>
<!-- row actions -->
<!-- TODO: Should this action be open to the unpriviledged CoMember? -->
Expand Down Expand Up @@ -133,6 +140,10 @@ export default {
<div class="field-data data-label">
<span v-if="!(this.mvea.verified)" class="mr-1 badge bg-warning unverified">{{ this.txt['field.unverified'] }}</span>
<span class="mr-1 badge bg-light">{{ this.mvea.type.display_name }}</span>
<span v-if="getEisDescription(this.mvea?.source_email_address?.external_identity_id)"
class="mr-1 badge bg-light badge-eis">
{{ getEisDescription(this.mvea?.source_email_address?.external_identity_id) }}
</span>
</div>
</li>
<!-- Identifiers -->
Expand All @@ -148,6 +159,10 @@ export default {
<span v-if="this.mvea.status == 'S'" class="mr-1 badge bg-danger">{{ this.txt['enumeration.SuspendableStatusEnum.S'] }}</span>
<span v-if="this.mvea.login" class="mr-1 badge bg-outline-secondary login">{{ this.txt['field.login'] }}</span>
<span class="mr-1 badge bg-light">{{ this.mvea.type.display_name }}</span>
<span v-if="getEisDescription(mvea?.source_identifier?.external_identity_id)"
class="mr-1 badge bg-light badge-eis">
{{ getEisDescription(mvea?.source_identifier?.external_identity_id) }}
</span>
</div>
</li>
<!-- Ad Hoc Attributes -->
Expand All @@ -162,6 +177,10 @@ export default {
</div>
<div v-if="this.mvea.tag != ''" class="field-data data-label">
<span class="mr-1 badge bg-light ad-hoc">{{ this.mvea.tag }}</span>
<span v-if="getEisDescription(this.mvea?.source_ad_hoc_attribute?.external_identity_id)"
class="mr-1 badge bg-light badge-eis">
{{ getEisDescription(this.mvea?.source_ad_hoc_attribute?.external_identity_id) }}
</span>
</div>
</li>
<!-- Addresses -->
Expand All @@ -185,6 +204,10 @@ export default {
</div>
<div class="field-data data-label">
<span class="mr-1 badge bg-light">{{ this.mvea.type.display_name }}</span>
<span v-if="getEisDescription(mvea?.source_address?.external_identity_id)"
class="mr-1 badge bg-light badge-eis">
{{ getEisDescription(mvea?.source_address?.external_identity_id) }}
</span>
</div>
</li>
<!-- Telephone Numbers -->
Expand All @@ -198,6 +221,10 @@ export default {
</div>
<div class="field-data data-label">
<span class="mr-1 badge bg-light">{{ this.mvea.type.display_name }}</span>
<span v-if="getEisDescription(mvea?.source_telephone_number?.external_identity_id)"
class="mr-1 badge bg-light badge-eis">
{{ getEisDescription(mvea?.source_telephone_number?.external_identity_id) }}
</span>
</div>
</li>
<!-- Urls -->
Expand All @@ -212,6 +239,10 @@ export default {
</div>
<div class="field-data data-label">
<span class="mr-1 badge bg-light">{{ this.mvea.type.display_name }}</span>
<span v-if="getEisDescription(mvea?.source_url?.external_identity_id)"
class="mr-1 badge bg-light badge-eis">
{{ getEisDescription(mvea?.source_url?.external_identity_id) }}
</span>
</div>
</li>
<!-- Pronouns -->
Expand All @@ -225,6 +256,10 @@ export default {
</div>
<div class="field-data data-label">
<span class="mr-1 badge bg-light">{{ this.mvea.type.display_name }}</span>
<span v-if="getEisDescription(mvea?.source_pronoun?.external_identity_id)"
class="mr-1 badge bg-light badge-eis">
{{ getEisDescription(mvea?.source_pronoun?.external_identity_id) }}
</span>
</div>
</li>
`
Expand Down