Skip to content

Commit

Permalink
Move petition Enrollment Flow steps preview to cells
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Feb 10, 2025
1 parent eb5c7e4 commit aca44c1
Show file tree
Hide file tree
Showing 19 changed files with 855 additions and 93 deletions.
90 changes: 90 additions & 0 deletions app/plugins/CoreEnroller/src/View/Cell/AttributeCollectorsCell.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php
/*
* COmanage Registry Attribute Collectors Cell
*
* 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.1.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*
* This generic modal dialog stub is used for confirmations, e.g. when deleting a record.
* The text of the box is overridden with JavaScript, and the confirm button is intended to
* click a CakePHP postLink or postButton in the DOM. Use jsConfirmGeneric() to call it.
*/


declare(strict_types=1);

namespace CoreEnroller\View\Cell;

use Cake\View\Cell;
use Cake\Database\Expression\QueryExpression;
use Cake\ORM\Query;
use Cake\Utility\Hash;

/**
* AttributeCollectors cell
*/
class AttributeCollectorsCell extends Cell
{
/**
* List of valid options that can be passed into this
* cell's constructor.
*
* @var array<string, mixed>
*/
protected $_validCellOptions = [
'vv_obj',
'vv_step',
'viewVars',
];

/**
* Initialization logic run at the end of object construction.
*
* @return void
*/
public function initialize(): void
{
}

/**
* Default display method.
*
* @param int $petitionId
* @return void
* @since COmanage Registry v5.1.0
*/
public function display(int $petitionId): void
{
$vv_enrollment_atttributes_ids = Hash::extract($this->vv_obj->petition_attributes, '{n}.enrollment_attribute_id');
$vv_enrollment_atttributes_ids = array_unique($vv_enrollment_atttributes_ids);

$vv_enrollment_attributes = $this->fetchTable('EnrollmentAttributes')
->find()
->where(fn(QueryExpression $exp, Query $q) => $exp->in('id', $vv_enrollment_atttributes_ids))
->order(['ordr' => 'ASC'])
->toArray();

$this->set('vv_enrollment_attributes', $vv_enrollment_attributes);
$this->set('vv_step', $this->vv_step);
$this->set('vv_obj', $this->vv_obj);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);

namespace CoreEnroller\View\Cell;

use Cake\View\Cell;

/**
* BasicAttributeCollectors cell
*/
class BasicAttributeCollectorsCell extends Cell
{
/**
* List of valid options that can be passed into this
* cell's constructor.
*
* @var array<string, mixed>
*/
protected $_validCellOptions = [
'vv_obj',
'vv_step',
'viewVars',
];

/**
* Initialization logic run at the end of object construction.
*
* @return void
*/
public function initialize(): void
{
}

/**
* Default display method.
*
* @param int $petitionId
* @return string
* @since COmanage Registry v5.1.0
*/
public function display(int $petitionId): void
{
$vv_petition_basic_attribute_set = $this->fetchTable('PetitionBasicAttributeSets')
->find()
->where(['PetitionBasicAttributeSets.petition_id' => $this->vv_obj->id])
->firstOrFail();

$this->set('vv_petition_basic_attribute_set', $vv_petition_basic_attribute_set);
$this->set('vv_obj', $this->vv_obj);
}
}
55 changes: 55 additions & 0 deletions app/plugins/CoreEnroller/src/View/Cell/EmailVerifiersCell.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
declare(strict_types=1);

namespace CoreEnroller\View\Cell;

use Cake\View\Cell;

/**
* EmailVerifiers cell
*/
class EmailVerifiersCell extends Cell
{
/**
* List of valid options that can be passed into this
* cell's constructor.
*
* @var array<string, mixed>
*/
protected $_validCellOptions = [
'vv_obj',
'vv_step',
'viewVars',
];

/**
* Initialization logic run at the end of object construction.
*
* @return void
*/
public function initialize(): void
{
}

/**
* Default display method.
*
* @param int $petitionId
* @return void
* @since COmanage Registry v5.1.0
*/
public function display(int $petitionId): void
{
// Because Petition Verifications are not tracked on a per-step basis, we just pull all
// associated with the Petition

$vv_pv = $this->fetchTable('CoreEnroller.PetitionVerifications')
->find()
->where(['PetitionVerifications.petition_id' => $this->vv_obj->id])
->contain(['Verifications'])
->all();

$this->set('vv_pv', $vv_pv);
$this->set('viewVars', $this->viewVars);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php
/*
* COmanage Registry Identifiers Collectors Cell
*
* 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.1.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*
* This generic modal dialog stub is used for confirmations, e.g. when deleting a record.
* The text of the box is overridden with JavaScript, and the confirm button is intended to
* click a CakePHP postLink or postButton in the DOM. Use jsConfirmGeneric() to call it.
*/

declare(strict_types=1);

namespace CoreEnroller\View\Cell;

use Cake\View\Cell;

/**
* IdentifierCollectors cell
*/
class IdentifierCollectorsCell extends Cell
{
/**
* List of valid options that can be passed into this
* cell's constructor.
*
* @var array<string, mixed>
*/
protected $_validCellOptions = [
'vv_obj',
'vv_step',
'viewVars',
];

/**
* Initialization logic run at the end of object construction.
*
* @return void
*/
public function initialize(): void
{
}

/**
* Default display method.
*
* @param int $petitionId
* @return void
* @since COmanage Registry v5.1.0
*/
public function display(int $petitionId): void
{
$vv_pi = $this->fetchTable('CoreEnroller.PetitionIdentifiers')
->find()
->where(['petition_id' => $this->vv_obj->id])
->first();

$this->set('vv_pi', $vv_pi);
}
}
80 changes: 80 additions & 0 deletions app/plugins/CoreEnroller/src/View/Cell/InvitationAcceptersCell.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php
/*
* COmanage Registry Invitation Accepters Cell
*
* 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.1.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*
* This generic modal dialog stub is used for confirmations, e.g. when deleting a record.
* The text of the box is overridden with JavaScript, and the confirm button is intended to
* click a CakePHP postLink or postButton in the DOM. Use jsConfirmGeneric() to call it.
*/

declare(strict_types=1);

namespace CoreEnroller\View\Cell;

use Cake\View\Cell;

/**
* InvitationAccepters cell
*/
class InvitationAcceptersCell extends Cell
{
/**
* List of valid options that can be passed into this
* cell's constructor.
*
* @var array<string, mixed>
*/
protected $_validCellOptions = [
'vv_obj',
'vv_step',
'viewVars',
];

/**
* Initialization logic run at the end of object construction.
*
* @return void
*/
public function initialize(): void
{
}

/**
* Default display method.
*
* @param int $petitionId
* @return void
* @since COmanage Registry v5.1.0
*/
public function display(int $petitionId): void
{
$vv_pa = $this->fetchTable('CoreEnroller.PetitionAcceptances')
->find()
->where(['petition_id' => $this->vv_obj->id])
->first();

$this->set('vv_pa', $vv_pa);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
* COmanage Registry Attibutte Collectors Step
* COmanage Registry Attribute Collectors display
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
Expand Down Expand Up @@ -31,20 +31,6 @@

declare(strict_types = 1);

use Cake\Database\Expression\QueryExpression;
use Cake\ORM\Query;
use Cake\Utility\Hash;

// Extract unique enrollment attribute IDs
$vv_enrollment_atttributes_ids = Hash::extract($vv_obj->petition_attributes, '{n}.enrollment_attribute_id');
$vv_enrollment_atttributes_ids = array_unique($vv_enrollment_atttributes_ids);

$enrollmentAttributesTable = $this->Petition->getTable('EnrollmentAttributes');
$vv_enrollment_attributes = $enrollmentAttributesTable->find()
->where(fn(QueryExpression $exp, Query $q) => $exp->in('id', $vv_enrollment_atttributes_ids))
->order(['ordr' => 'ASC'])
->toArray();

?>

<ul>
Expand Down
Loading

0 comments on commit aca44c1

Please sign in to comment.