Skip to content

Commit

Permalink
add a cancel button in pagedelete view close #473
Browse files Browse the repository at this point in the history
+ pagedelete route accept optionnal GET param "route" used for the cancel button
+ added icons
+ search for page links is now a button too
  • Loading branch information
vincent-peugnet committed Nov 2, 2024
1 parent 510c46f commit 84872a3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions app/class/Controllerpage.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,12 @@ public function delete(string $page): void
$linksto = new Opt();
$linksto->setlinkto($this->page->id());
$pageslinkingto = $this->pagemanager->pagetable($this->pagemanager->pagelist(), $linksto);
$cancelroute = isset($_GET['route']) ? $_GET['route'] : 'pageread';
$this->showtemplate('delete', [
'page' => $this->page,
'pageexist' => true,
'pageslinkingtocount' => count($pageslinkingto),
'cancelroute' => $cancelroute,
]);
} else {
$this->routedirect('pageread', ['page' => $this->page->id()]);
Expand Down
17 changes: 15 additions & 2 deletions app/view/templates/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,28 @@
<p>
Page linking to this one : <?= $pageslinkingtocount ?>
<?php if ($pageslinkingtocount > 0) : ?>
<a href="<?= $this->url('home', [], '?linkto=' . $page->id() . '&submit=filter') ?>" title="search for pages linking to this one in home view">
<a class="button" href="<?= $this->url('home', [], '?linkto=' . $page->id() . '&submit=filter') ?>" title="search for pages linking to this one in home view">
<i class="fa fa-search"></i>
</a>
<?php endif ?>
</p>

<form action="<?= $this->upage('pagedelete', $page->id()) ?>" method="post">
<input type="hidden" name="deleteconfirm" value="true">
<input type="submit" value="Confirm delete">
<button type="submit">
<i class="fa fa-trash"></i>
<span class="text">Confirm delete</span>
</button>

<?php if ($cancelroute === 'pageread') : ?>
<a href="<?= $this->upage('pageread', $page->id()) ?>" class="button">
<i class="fa fa-times"></i> Cancel
</a>
<?php elseif ($cancelroute === 'home') : ?>
<a href="<?= $this->url('home') ?>" class="button">
<i class="fa fa-times"></i> Cancel
</a>
<?php endif ?>
</form>

</div>
Expand Down
2 changes: 1 addition & 1 deletion app/view/templates/home.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class="redirection"
</td>
<td class="delete">
<?php if($this->candeletepage($item)) : ?>
<a href="<?= $this->upage('pagedelete', $item->id()) ?>" class="button">
<a href="<?= $this->upage('pagedelete', $item->id()) ?>?route=home" class="button">
<i class="fa fa-trash"></i>
</a>
<?php endif ?>
Expand Down

0 comments on commit 84872a3

Please sign in to comment.