Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into 2.x
  • Loading branch information
jvangestel committed Dec 3, 2024
2 parents 6bb7f4d + df075fc commit d091928
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 2 deletions.
21 changes: 21 additions & 0 deletions src/Handlers/LogHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,19 @@
use Gems\Snippets\Log\LogSearchSnippet;
use Gems\Snippets\Log\LogShowSnippet;
use Gems\Snippets\Log\LogTableSnippet;
use Gems\SnippetsActions\Browse\BrowseFilteredAction;
use Gems\SnippetsActions\Browse\BrowseSearchAction;
use Gems\SnippetsActions\Browse\FastBrowseSearchAction;
use Gems\SnippetsActions\Export\ExportAction;
use Gems\SnippetsActions\Form\CreateAction;
use Gems\SnippetsActions\Form\EditAction;
use Gems\SnippetsActions\Show\ShowAction;
use Psr\Cache\CacheItemPoolInterface;
use Zalt\Base\TranslatorInterface;
use Zalt\Model\MetaModellerInterface;
use Zalt\Model\MetaModelLoader;
use Zalt\SnippetsActions\Browse\BrowseTableAction;
use Zalt\SnippetsActions\Delete\DeleteAction;
use Zalt\SnippetsActions\SnippetActionInterface;
use Zalt\SnippetsLoader\SnippetResponderInterface;

Expand All @@ -40,6 +46,21 @@
*/
class LogHandler extends BrowseChangeHandler
{
/**
* Defined in Gems\Handlers\BrowseChangeHandler.
*
* @inheritdoc
*/
public static $actions = [
'autofilter' => BrowseFilteredAction::class,
'index' => FastBrowseSearchAction::class, // Override to disable totals
'create' => CreateAction::class,
'export' => ExportAction::class,
'edit' => EditAction::class,
'delete' => DeleteAction::class,
'show' => ShowAction::class,
];

/**
* The snippets used for the autofilter action.
*
Expand Down
6 changes: 4 additions & 2 deletions src/Handlers/Respondent/TokenHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,11 @@ public function createModel(bool $detailed, string $action): DataReaderInterface
*/
public function correctAction()
{
$this->deleteParameters = $this->correctParameters + $this->deleteParameters;
$this->deleteParameters = $this->correctParameters + $this->deleteParameters + $this->defaultTokenParameters;
$this->deleteSnippets = $this->getToken()->getCorrectSnippetNames();
$this->deleteParameters['requestUndelete'] = false;

$this->deleteAction();
parent::deleteAction();
}

/**
Expand Down
36 changes: 36 additions & 0 deletions src/Snippets/Token/TokenNotCompletedSnippet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Gems\Snippets\Token;

use Zalt\Snippets\MessageableSnippetAbstract;

/**
* Token snippet to return when a completed token is required but the selected
* token is not completed.
*/
class TokenNotCompletedSnippet extends MessageableSnippetAbstract
{
/**
* Optional: id of the selected token to show
*
* Can be derived from $request or $token
*
* @var string
*/
protected $tokenId;

/**
* Create the snippets content.
*
* @return mixed Something that can be rendered
*/
public function getHtmlOutput()
{
$messenger = $this->getMessenger();
if ($this->tokenId) {
$messenger->addMessage(sprintf($this->_('Token %s not completed.'), $this->tokenId));
} else {
$messenger->addMessage($this->_('No token specified.'));
}
}
}
16 changes: 16 additions & 0 deletions src/Tracker/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,22 @@ public function getDeleteSnippetNames(): array
}
}

/**
* Returns an array of snippet names that can be used to delete this token.
*
* @return array of strings
*/
public function getCorrectSnippetNames(): array
{
if (!$this->exists) {
return ['Token\\TokenNotFoundSnippet'];
}
if (!$this->isCompleted()) {
return ['Token\\TokenNotCompletedSnippet'];
}
return $this->getTrackEngine()->getTokenDeleteSnippetNames($this);
}

/**
*
* @return ?int Duration
Expand Down

0 comments on commit d091928

Please sign in to comment.