Skip to content

Commit

Permalink
Fix superuser requirement for Award Recommendations (#121), added Mod…
Browse files Browse the repository at this point in the history
…ify by and date to kanban Z(#116), new reports for "to be processed" (#104), "To be Scheduled", and "To be GIven" (#105)
  • Loading branch information
jhandel committed Aug 28, 2024
1 parent d65caaa commit 37be253
Show file tree
Hide file tree
Showing 12 changed files with 669 additions and 124 deletions.
4 changes: 2 additions & 2 deletions app/plugins/Awards/src/Controller/EventsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public function view($id = null)
'Branches' => function ($q) {
return $q->select(['id', 'name']);
},
'Recommendations' => function ($q) {
return $q->contain(['Awards'])->select(['id', 'member_sca_name', 'award_id', 'specialty', 'call_into_court', 'court_availability', 'status', 'Awards.name'])->orderBy(['member_sca_name' => 'ASC']);
'RecommendationsToGive' => function ($q) {
return $q->contain(['Awards'])->select(['id', 'event_id', 'member_sca_name', 'award_id', 'specialty', 'call_into_court', 'court_availability', 'status', 'Awards.abbreviation'])->orderBy(['member_sca_name' => 'ASC']);
}
])
->first();
Expand Down
320 changes: 216 additions & 104 deletions app/plugins/Awards/src/Controller/RecommendationsController.php

Large diffs are not rendered by default.

73 changes: 66 additions & 7 deletions app/plugins/Awards/src/Event/CallForNavHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,84 @@ public function callForNav($event)
],
[
"type" => "link",
"mergePath" => ["Award Recs."],
"label" => "Kanban Board",
"order" => 30,
"mergePath" => ["Award Recs.", "Recommendations"],
"label" => "To Be Processed Board",
"order" => 1,
"url" => [
"controller" => "Recommendations",
"plugin" => "Awards",
"action" => "board",
"action" => "toBeProcessedBoard",
"model" => "Awards.Recommendations",
],
"icon" => "bi-kanban",
"activePaths" => [
"awards/Recommendations/view/*",
]
],
[
"type" => "link",
"mergePath" => ["Award Recs.", "Recommendations"],
"label" => "To Be Scheduled Board",
"order" => 5,
"url" => [
"controller" => "Recommendations",
"plugin" => "Awards",
"action" => "toBeScheduledBoard",
"model" => "Awards.Recommendations",
],
"icon" => "bi-kanban-fill",
"activePaths" => [
"awards/Recommendations/view/*",
]
],
[
"type" => "link",
"mergePath" => ["Award Recs.", "Recommendations"],
"label" => "To Be Processed List",
"order" => 10,
"url" => [
"controller" => "Recommendations",
"plugin" => "Awards",
"action" => "ToBeProcessed",
"model" => "Awards.Recommendations",
],
"icon" => "bi-file-earmark-check",


],
[
"type" => "link",
"mergePath" => ["Award Recs.", "Recommendations"],
"label" => "To Be Scheduled List",
"order" => 11,
"url" => [
"controller" => "Recommendations",
"plugin" => "Awards",
"action" => "ToBeScheduled",
"model" => "Awards.Recommendations",
],
"icon" => "bi-clipboard-heart",


],
[
"type" => "link",
"mergePath" => ["Award Recs.", "Recommendations"],
"label" => "To Be Given",
"order" => 12,
"url" => [
"controller" => "Recommendations",
"plugin" => "Awards",
"action" => "ToBeGiven",
"model" => "Awards.Recommendations",
],
"icon" => "bi-emoji-heart-eyes",
],
[
"type" => "link",
"mergePath" => ["Award Recs.", "Recommendations"],
"label" => "New Recommendation",
"order" => 0,
"order" => 20,
"url" => [
"controller" => "Recommendations",
"plugin" => "Awards",
Expand Down Expand Up @@ -166,7 +225,7 @@ public function callForNav($event)
],
[
"type" => "link",
"mergePath" => ["Config"],
"mergePath" => ["Award Recs."],
"label" => "Award Events",
"order" => 33,
"url" => [
Expand All @@ -182,7 +241,7 @@ public function callForNav($event)
],
[
"type" => "link",
"mergePath" => ["Config", "Award Events"],
"mergePath" => ["Award Recs.", "Award Events"],
"label" => "New Award Events",
"order" => 0,
"url" => [
Expand Down
25 changes: 25 additions & 0 deletions app/plugins/Awards/src/Model/Entity/Recommendation.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,31 @@ public static function getStatues(): array
];
}

public static function getToBeProcessedStatues(): array
{
return [
self::STATUS_SUBMITTED => "Submitted",
self::STATUS_IN_CONSIDERATION => "In Consideration",
self::STATUS_AWAITING_FEEDBACK => "Awaiting Feedback",
];
}

public static function getToBeScheduledStatues(): array
{
return [
self::STATUS_NEED_TO_SCHEDULE => "Need to Schedule",
self::STATUS_SCHEDULED => "Scheduled",
];
}

public static function getTerminalStatues(): array
{
return [
self::STATUS_DECLINED => "Declined",
self::STATUS_GIVEN => "Given",
];
}

/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
Expand Down
8 changes: 8 additions & 0 deletions app/plugins/Awards/src/Model/Table/EventsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,21 @@ public function initialize(array $config): void
'className' => 'Branches',
]);

$this->hasMany('RecommendationsToGive', [
'foreignKey' => 'event_id',
'joinType' => 'LEFT',
'className' => 'Awards.Recommendations',
]);

$this->belongsToMany("Recommendations", [
"joinTable" => "awards_recommendations_events",
"foreignKey" => "event_id",
"targetForeignKey" => "recommendation_id",
"className" => "Awards.Recommendations",
]);



$this->addBehavior("Timestamp");
$this->addBehavior('Muffin/Footprint.Footprint');
$this->addBehavior("Muffin/Trash.Trash");
Expand Down
5 changes: 5 additions & 0 deletions app/plugins/Awards/src/Model/Table/RecommendationsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ public function initialize(array $config): void
"targetForeignKey" => "event_id",
"className" => "Awards.Events",
]);
$this->belongsTo("AssignedEvent", [
'foreignKey' => 'event_id',
'joinType' => 'LEFT',
"className" => "Awards.Events",
]);
$this->hasMany("Notes", [
"foreignKey" => "topic_id",
"className" => "Notes",
Expand Down
26 changes: 24 additions & 2 deletions app/plugins/Awards/src/Policy/RecommendationPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,35 @@
*/
class RecommendationPolicy extends BasePolicy
{
protected string $REQUIRED_PERMISSION = "Can Manage Recommendations";
protected string $REQUIRED_PERMISSION = "Can View Recommendations";

public function canBoard(IdentityInterface $user, $entity)
public function canToBeProcessedBoard(IdentityInterface $user, $entity)
{
return $this->_hasNamedPermission($user, $this->REQUIRED_PERMISSION);
}

public function canToBeScheduledBoard(IdentityInterface $user, $entity)
{
return $this->_hasNamedPermission($user, $this->REQUIRED_PERMISSION);
}


public function canToBeProcessed(IdentityInterface $user, $entity)
{
return $this->_hasNamedPermission($user, $this->REQUIRED_PERMISSION);
}

public function canToBeScheduled(IdentityInterface $user, $entity)
{
return $this->_hasNamedPermission($user, $this->REQUIRED_PERMISSION);
}

public function canToBeGiven(IdentityInterface $user, $entity)
{
return $this->_hasNamedPermission($user, $this->REQUIRED_PERMISSION);
}


public function canAdd(IdentityInterface $user, $entity)
{
return true;
Expand Down
12 changes: 6 additions & 6 deletions app/plugins/Awards/templates/Events/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@
<?php $this->KMP->startBlock("tabContent") ?>
<div class="related tab-pane fade m-3" id="nav-scheduledAwards" role="tabpanel"
aria-labelledby="nav-scheduledAwards-tab" data-detail-tabs-target="tabContent">
<?php if (!empty($event->recommendations)) :
<?php if (!empty($event->recommendations_to_give)) :
$csv = [];
$csv[] = ["Name", "Award", "Court Availability", "Call Into Court", "Status"];
foreach ($event->recommendations as $rec) {
foreach ($event->recommendations_to_give as $rec) {
$csv[] = [
$rec->member_sca_name,
$rec->award->name . ($rec->specialty ? " (" . $rec->specialty . ")" : ""),
$rec->award->abbreviation . ($rec->specialty ? " (" . $rec->specialty . ")" : ""),
$rec->court_availability,
$rec->call_into_court,
$rec->status,
Expand Down Expand Up @@ -96,12 +96,12 @@ class="btn btn-primary btn-sm">Export CSV</a>
</thead>
<tbody>
<?php foreach (
$event->recommendations
$event->recommendations_to_give
as $rec
) : ?>
<tr>
<td><?= h($rec->member_sca_name) ?></td>
<td><?= h($rec->award->name) ?>
<td><?= h($rec->award->abbreviation) ?>
<?php if ($rec->specialty) : ?>
(<?= h($rec->specialty) ?>)
<?php endif; ?>
Expand All @@ -115,7 +115,7 @@ class="btn btn-primary btn-sm">Export CSV</a>
</table>
</div>
<?php else: ?>
<p>No Recommendations</p>
<p>No Awards Scheduled</p>
<?php endif; ?>
</div>
<?php $this->KMP->endBlock() ?>
Expand Down
9 changes: 8 additions & 1 deletion app/plugins/Awards/templates/Recommendations/board.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use Cake\Utility\Inflector;

/**
* @var \App\View\AppView $this
* @var \App\Model\Entity\ActivityGroup[]|\Cake\Collection\CollectionInterface $activityGroup
Expand All @@ -13,6 +15,9 @@
$this->KMP->endBlock(); ?>
<h3>
Award Recommendations
<?php if ($viewAction != "Index") : ?>
: <?= Inflector::humanize($viewAction) ?>
<?php endif; ?>
</h3>
<div class="overflow-x-auto table-responsive">
<table class="table table-striped-columns" width="100%" style="min-width:1020px" data-controller="kanban"
Expand All @@ -21,7 +26,7 @@
<thead>
<tr>
<?php foreach ($statuses as $statusName => $status) : ?>
<th scope="col" width="14.28%"><?= h($statusName) ?></th>
<th scope="col" width="14.28%"><?= h($statusNames[$statusName]) ?></th>
<?php endforeach; ?>
</tr>
</thead>
Expand Down Expand Up @@ -52,6 +57,8 @@
<p class="card-text"><?= $this->Text->autoParagraph(
h($this->Text->truncate($recommendation->reason, 100)),
) ?></p>
<b>Last Modified: </b><?= $recommendation->modified->format('m/d/Y') ?> by
<?= $recommendation->ModifiedByMembers['sca_name'] ?>
</div>
</div>
<?php endforeach;
Expand Down
10 changes: 8 additions & 2 deletions app/plugins/Awards/templates/Recommendations/index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use Cake\Utility\Inflector;

/**
* @var \App\View\AppView $this
* @var \App\Model\Entity\ActivityGroup[]|\Cake\Collection\CollectionInterface $activityGroup
Expand All @@ -17,10 +19,13 @@
<?php if (!$isTurboFrame) : ?>
<h3>
Award Recommendations
<?php if ($viewAction != "Index") : ?>
: <?= Inflector::humanize($viewAction) ?>
<?php endif; ?>
</h3>
<?php endif; ?>
<turbo-frame id="recommendationList" data-turbo='true'>
<?= $this->Form->create(null, ["url" => ["action" => "index"], "type" => "get", "data-turbo-frame" => "recommendationList", "data-controller" => "filter-grid"]) ?>
<?= $this->Form->create(null, ["url" => ["action" => $viewAction], "type" => "get", "data-turbo-frame" => "recommendationList", "data-controller" => "filter-grid"]) ?>
<?= $this->Form->hidden("sort", ["value" => $this->request->getQuery("sort")]) ?>
<?= $this->Form->hidden("direction", ["value" => $this->request->getQuery("direction")]) ?>
<table class="table table-striped">
Expand Down Expand Up @@ -169,7 +174,8 @@
<td><?= h($recommendation->contact_email) ?></td>
<td><?= h($recommendation->contact_phone) ?></td>
<td><?= h($recommendation->award->domain->name) ?></td>
<td><?= h($recommendation->award->abbreviation) ?></td>
<td><?= h($recommendation->award->abbreviation) . ($recommendation->specialty ? " (" . $recommendation->specialty . ")" : "") ?>
</td>
<td><?= $this->Text->autoParagraph($recommendation->reason) ?></td>
<td>
<ul>
Expand Down
Loading

0 comments on commit 37be253

Please sign in to comment.