Skip to content

Commit

Permalink
Hotfix for issue with edit modal of Recommendations on Member and Event
Browse files Browse the repository at this point in the history
  • Loading branch information
jhandel committed Nov 1, 2024
1 parent 545cc67 commit fbfd93d
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 43 deletions.
Binary file modified app/config/Migrations/schema-dump-default.lock
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class AwardsRecommendationQuickEditForm extends Controller {


submit(event) {
document.getElementById("recommendation_edit_close").click();
}
setAward(event) {
let awardId = event.target.dataset.awardId;
Expand Down
18 changes: 13 additions & 5 deletions app/plugins/Awards/src/Controller/RecommendationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,9 @@ public function edit($id = null)
$this->Recommendations->getConnection()->begin();
if (!$this->Recommendations->save($recommendation)) {
$this->Recommendations->getConnection()->rollback();
$this->Flash->error(__('The recommendation could not be saved. Please, try again.'));
if (!$this->request->getHeader('Turbo-Frame')) {
$this->Flash->error(__('The recommendation could not be saved. Please, try again.'));
}
if ($this->request->getData("current_page")) {
return $this->redirect($this->request->getData("current_page"));
}
Expand All @@ -442,15 +444,19 @@ public function edit($id = null)
$newNote->author_id = $this->request->getAttribute("identity")->id;
if (!$this->Recommendations->Notes->save($newNote)) {
$this->Recommendations->getConnection()->rollback();
$this->Flash->error(__('The note could not be saved. Please, try again.'));
if (!$this->request->getHeader('Turbo-Frame')) {
$this->Flash->error(__('The note could not be saved. Please, try again.'));
}
if ($this->request->getData("current_page")) {
return $this->redirect($this->request->getData("current_page"));
}
return $this->redirect(['action' => 'view', $id]);
}
}
$this->Recommendations->getConnection()->commit();
$this->Flash->success(__('The recommendation has been saved.'));
if (!$this->request->getHeader('Turbo-Frame')) {
$this->Flash->success(__('The recommendation has been saved.'));
}
}
if ($this->request->getData("current_page")) {
return $this->redirect($this->request->getData("current_page"));
Expand Down Expand Up @@ -554,8 +560,9 @@ public function turboEditForm($id = null)
->contain(['Branches' => function ($q) {
return $q->select(['id', 'name']);
}])
->where(["start_date >" => DateTime::now(), 'OR' => ['closed' => false, 'closed IS' => null]])
->where(['OR' => ['closed' => false, 'closed IS' => null]])
->select(['id', 'name', 'start_date', 'end_date', 'Branches.name'])
->orderBy(['start_date' => 'ASC'])
->all();
$statusList = Recommendation::getStatuses();
foreach ($statusList as $key => $value) {
Expand Down Expand Up @@ -594,8 +601,9 @@ public function turboQuickEditForm($id = null)
->contain(['Branches' => function ($q) {
return $q->select(['id', 'name']);
}])
->where(["start_date >" => DateTime::now(), 'OR' => ['closed' => false, 'closed IS' => null]])
->where(['OR' => ['closed' => false, 'closed IS' => null]])
->select(['id', 'name', 'start_date', 'end_date', 'Branches.name'])
->orderBy(['start_date' => 'ASC'])
->all();
$statusList = Recommendation::getStatuses();
foreach ($statusList as $key => $value) {
Expand Down
65 changes: 33 additions & 32 deletions app/plugins/Awards/templates/Recommendations/board.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,78 +5,79 @@
if ($hiddenStates != ""):
if (!$showHidden): ?>

<?= $this->Html->link(
<?= $this->Html->link(
"Show $hiddenStates In last $range days",
[$view, '?' => ['showHidden' => 'true']],
['class' => 'btn btn-primary btn-sm end m-3']
) ?>
<?php else : ?>
<?= $this->Html->link(
<?php else : ?>
<?= $this->Html->link(
"Hide $hiddenStates In last $range days",
[$view],
['class' => 'btn btn-primary btn-sm end m-3']
) ?>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
</div>
<div class="overflow-x-auto table-responsive" data-controller='recommendation-kanban'
data-recommendation-kanban-kanban-outlet=".rec-kanban">
<script type="application/json" data-awards-rec-edit-target="stateRulesBlock" class="d-none">
<?= json_encode($rules) ?>
<?= json_encode($rules) ?>
</script>
<table class="table table-striped-columns rec-kanban" width="100%" style="min-width:1020px"
data-controller="kanban" data-kanban-csrf-token-value="<?= $this->request->getAttribute('csrfToken') ?>"
data-kanban-url-value="<?= $this->Url->build(['action' => 'kanbanUpdate']) ?>">
<thead>
<tr>
<?php foreach ($states as $state => $recommendations) : ?>
<th scope="col" width="14.28%"><?= h($state) ?></th>
<th scope="col" width="14.28%"><?= h($state) ?></th>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
<tr>
<?php
foreach ($states as $state => $recommendations) : ?>
<td class="sortable" width="14.28%" data-kanban-target="column" data-col="<?= h($state) ?>"
data-action="dragstart->kanban#grabCard dragover->kanban#cardDrag drop->kanban#dropCard">
<td class="sortable" width="14.28%" data-kanban-target="column" data-col="<?= h($state) ?>"
data-action="dragstart->kanban#grabCard dragover->kanban#cardDrag drop->kanban#dropCard">

<?php
<?php
if (is_array($recommendations)) :
foreach ($recommendations as $recommendation) : ?>
<div class="card m-1" style="cursor: pointer;" draggable="true"
data-stack-rank="<?= $recommendation->stack_rank ?>"
data-rec-id="<?= $recommendation->id ?>" id="card_<?= $recommendation->id ?>"
data-kanban-target="card">
<div class="card-body">
<div class="card-title"> <?php
<div class="card m-1" style="cursor: pointer;" draggable="true"
data-stack-rank="<?= $recommendation->stack_rank ?>"
data-rec-id="<?= $recommendation->id ?>" id="card_<?= $recommendation->id ?>"
data-kanban-target="card">
<div class="card-body">
<div class="card-title"> <?php
$awardTitle = $recommendation->award->abbreviation;
if ($recommendation->specialty != null && $recommendation->specialty != "" && $recommendation->specialty != "No Specialty Selected") :
$awardTitle = $awardTitle . " (" . $recommendation->specialty . ")";
endif;
?>
<?= $this->Html->link($awardTitle, ['action' => 'view', $recommendation->id]) ?>
<button type="button" class="btn btn-primary btn-sm float-end edit-rec"
data-bs-toggle="modal" data-bs-target="#editModal"
data-controller="grid-btn" data-action="click->grid-btn#fireNotice"
data-grid-btn-row-data-value='{ "id":<?= $recommendation->id ?>}'>
Edit</button>
</div>
<h6 class="card-subtitle mb-2 text-body-secondary">
<?= $recommendation->member_sca_name ?>
</h6>
<p class="card-text"><?= $this->Text->autoParagraph(
<?= $this->Html->link($awardTitle, ['action' => 'view', $recommendation->id]) ?>
<button type="button" class="btn btn-primary btn-sm float-end edit-rec"
data-bs-toggle="modal" data-bs-target="#boardEditModal"
data-controller="grid-btn" data-action="click->grid-btn#fireNotice"
data-grid-btn-row-data-value='{ "id":<?= $recommendation->id ?>}'>
Edit</button>
</div>
<h6 class="card-subtitle mb-2 text-body-secondary">
<?= $recommendation->member_sca_name ?>
</h6>
<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;
<b>Last Modified: </b><?= $recommendation->modified->format('m/d/Y') ?> by
<?= $recommendation->ModifiedByMembers['sca_name'] ?>
</div>
</div>
<?php endforeach;
endif; ?>
</td>
</td>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?= $this->element('recommendationQuickEditModal', ['modalId' => 'boardEditModal']) ?>
</turbo-frame>
2 changes: 0 additions & 2 deletions app/plugins/Awards/templates/Recommendations/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,5 @@
'updateUrl' => false,
]);
echo $this->KMP->startBlock("modals"); ?>

<?= $this->element('recommendationQuickEditModal') ?>
<?php //finish writing to modal block in layout
$this->KMP->endBlock(); ?>
4 changes: 3 additions & 1 deletion app/plugins/Awards/templates/Recommendations/table.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@
<td class="actions">
<?php if ($user->checkCan("edit", $recommendation)) : ?>
<button type="button" class="btn btn-primary btn-sm edit-rec" data-bs-toggle="modal"
data-bs-target="#editModal" data-controller="grid-btn" data-action="click->grid-btn#fireNotice"
data-bs-target="#tableEditModal" data-controller="grid-btn"
data-action="click->grid-btn#fireNotice"
data-grid-btn-row-data-value='{ "id":<?= $recommendation->id ?>}' ,>Edit</button>
<?php endif; ?>
<?php if ($user->checkCan("view", $recommendation)) : ?>
Expand Down Expand Up @@ -448,4 +449,5 @@
),
) ?></p>
</div>
<?= $this->element('recommendationQuickEditModal', ['modalId' => 'tableEditModal']) ?>
</turbo-frame>
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

);
echo $this->Modal->create("Edit Recommendation", [
"id" => "editModal",
"id" => $modalId,
"close" => true,
]);
?>
Expand All @@ -48,6 +48,7 @@
$this->Form->button("Close", [
"data-bs-dismiss" => "modal",
"type" => "button",
"id" => "recommendation_edit_close"
]),
]);

Expand Down
4 changes: 3 additions & 1 deletion app/webroot/js/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2636,7 +2636,9 @@ class AwardsRecommendationQuickEditForm extends _hotwired_stimulus__WEBPACK_IMPO
gridBtnOutletDisconnected(outlet) {
outlet.removeListener(this.setId.bind(this));
}
submit(event) {}
submit(event) {
document.getElementById("recommendation_edit_close").click();
}
setAward(event) {
let awardId = event.target.dataset.awardId;
this.awardTarget.value = awardId;
Expand Down
2 changes: 1 addition & 1 deletion app/webroot/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"/js/controllers.js": "/js/controllers.js?id=7cf5fb1065794e53e17f2adb34c24ebf",
"/js/controllers.js": "/js/controllers.js?id=6e03142dec8d72597ab1d34e5037c8a8",
"/js/index.js": "/js/index.js?id=05830d35bc6fe6a349e66365323c6a6a",
"/js/manifest.js": "/js/manifest.js?id=8cb20bf9ab0e0431d222718610e09416",
"/js/core.js": "/js/core.js?id=b1125d54a85324a90cdae0b0b8f4dac8",
Expand Down

0 comments on commit fbfd93d

Please sign in to comment.