Skip to content

Commit

Permalink
Miscellaneous Enrollment fixes (CFM-31)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin authored and arlen committed Sep 24, 2024
1 parent 9fec427 commit a1ea421
Show file tree
Hide file tree
Showing 5 changed files with 246 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

// This view does currently not support read-only
if($vv_action == 'add' || $vv_action == 'edit') {
// This view is intended to work with dispatch
if($vv_action == 'dispatch') {
foreach($vv_enrollment_attributes as $attr) {
$options = [];

Expand Down
1 change: 1 addition & 0 deletions app/src/Model/Table/PetitionStepResultsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class PetitionStepResultsTable 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
94 changes: 94 additions & 0 deletions app/templates/Petitions/columns.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php
/**
* COmanage Registry Petitions Index Columns
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership.
*
* UCAID licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @link https://www.internet2.edu/comanage COmanage Project
* @package registry
* @since COmanage Registry v5.0.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

$indexColumns = [
// We start with id to ensure there is a clickable field in the row
'id' => [
'type' => 'link'
],
'enrollee_person_id' => [
'type' => 'relatedLink',
'action' => 'edit',
'label' => __d('field', 'Petitions.enrollee_person_id'),
'model' => 'enrollee_person',
'submodel' => 'primary_name',
'field' => 'full_name',
'default' => __d('field', 'Petitions.enrollee.new')
],
'status' => [
'type' => 'enum',
'class' => 'PetitionStatusEnum',
'sortable' => true
],
'enrollment_flow_id' => [
'type' => 'relatedLink',
'model' => 'enrollment_flow',
'field' => 'name'
],
'cou_id' => [
'type' => 'relatedLink',
'model' => 'cou',
'field' => 'name'
],
/* XXX this apparently isn't in the data model yet?
'petitioner_person_id' => [
'type' => 'relatedLink',
'action' => 'edit',
// 'label' => __d('field', 'actor'),
'model' => 'petitioner_person',
'submodel' => 'primary_name',
'field' => 'full_name'
],*/
// sponsor
// approver - there can be multiple approvers going forward, maybe omit this column
'created' => [
'type' => 'datetime'
],
'modified' => [
'type' => 'datetime'
]
];

// $rowActions appear as row-level menu items in the index view gear icon
$rowActions = [
[
'controller' => 'petitions',
'action' => 'view',
'class' => '',
'icon' => 'visibility',
'label' => __d('operation', 'view')
],
[
'controller' => 'petitions',
'action' => 'resume',
'class' => '',
// XXX this icon is supposed to be "resume" but that doesn't appear to render
'icon' => 'start',
'label' => __d('operation', 'resume'),
'if' => 'isResumable'
]
];
87 changes: 87 additions & 0 deletions app/templates/Petitions/fields.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php
/**
* COmanage Registry Petitions Fields
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership.
*
* UCAID licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @link https://www.internet2.edu/comanage COmanage Project
* @package registry
* @since COmanage Registry v5.0.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

// Petitions are read-only, though they can link to other actions
if($vv_action == 'view') {
// Start with the petition metadata
print $this->Field->control('status');

print $this->Field->statusControl(
fieldName: 'enrollee_person_id',
status: !empty($vv_obj->enrollee_person->primary_name)
? $vv_obj->enrollee_person->primary_name->full_name
: __d('field', 'Petitions.enrollee.new'),
link: (!empty($vv_obj->enrollee_person->id)
? ['url' => [
'controller' => 'people',
'action' => 'edit',
$vv_obj->enrollee_person_id
]]
: [])
);

print $this->Field->statusControl(
fieldName: 'petitioner_person_id',
status: !empty($vv_obj->petitioner_person->primary_name)
? $vv_obj->petitioner_person->primary_name->full_name
: "",
link: (!empty($vv_obj->petitioner_person->id)
? ['url' => [
'controller' => 'people',
'action' => 'edit',
$vv_obj->enrollee_person_id
]]
: [])
);

// XXX petitioner_identifier if set?
print "<ol>\n";

// XXX merge this with resume?
foreach($vv_obj->enrollment_flow->enrollment_flow_steps as $step) {
$stepId = $step->id;

print "<li>" . $step->description;

$result = \Cake\Utility\Hash::extract($vv_obj->petition_step_results, "{n}[enrollment_flow_step_id=$stepId]");

if(!empty($result)) {
print ", Result: " . $result[0]->comment
. $this->Html->link(' (View)', [
'controller' => 'petitions',
'action' => 'result',
$vv_obj->id,
'?' => ['enrollment_flow_step_id' => $step->id]
]);
}

print "</li>\n";
}

print "</ol>\n";
}
62 changes: 62 additions & 0 deletions app/templates/Petitions/resume.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
/**
* COmanage Registry Petitions Resume View
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership.
*
* UCAID licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @link https://www.internet2.edu/comanage COmanage Project
* @package registry
* @since COmanage Registry v5.0.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

declare(strict_types = 1);

// Track when we've rendered the current/next step so we know when to stop rendering links
$seenNextStep = false;
?>
<table>
<tr>
<th><?= __d('field', 'ordr') ?></th>
<th><?= __d('controller', 'EnrollmentFlowSteps', [1]) ?></th>
<th><?= __d('result', 'result') ?></th>
<th><?= __d('field', 'EnrollmentFlows.authz_type') ?></th>
<th><?= __d('field', 'action') ?></th>
</tr>
<?php foreach($vv_steps as $step): ?>
<tr>
<td><?= $step->ordr ?? "" ?></td>
<td><?= $step->description ?></td>
<!-- this could be a link to the detailed step result -->
<td><?= $step->petition_step_results[0]->comment ?? "" ?></td>
<td><?= __d('enumeration', 'EnrollmentActorEnum.'.$step->actor_type) ?></td>
<td><?php
if(!$seenNextStep && !empty($vv_dispatch_urls[ $step->id ])) {
print $this->Html->link(
($step->id == $vv_next_step_id) ? __d('operation', 'continue') : __d('operation', 'Petitions.rerun'),
$vv_dispatch_urls[ $step->id ]
);

if($step->id == $vv_next_step_id) {
$seenNextStep = true;
}
}
?></td>
</tr>
<?php endforeach; // $vv_steps ?>
</table>

0 comments on commit a1ea421

Please sign in to comment.