Merging and renaming tags yields status messages

Previously, it just redirected back to tag list without any kind of
notification about success.
This commit is contained in:
Marcin Kurczewski 2014-02-20 17:38:32 +01:00
parent 1624fd5f63
commit db8e13ec35
5 changed files with 13 additions and 6 deletions

View file

@ -62,14 +62,14 @@ class Bootstrap
{
if ($e instanceof SimpleNotFoundException)
http_response_code(404);
StatusHelper::failure(rtrim($e->getMessage(), '.') . '.');
StatusHelper::failure($e->getMessage());
if (!$this->context->handleExceptions)
$this->context->viewName = 'message';
$this->render();
}
catch (Exception $e)
{
StatusHelper::failure(rtrim($e->getMessage(), '.') . '.');
StatusHelper::failure($e->getMessage());
$this->context->transport->exception = $e;
$this->context->transport->queries = Database::getLogs();
$this->context->viewName = 'error-exception';

View file

@ -47,6 +47,7 @@ class TagController
public function mergeAction()
{
$this->context->viewName = 'tag-list-wrapper';
$this->context->handleExceptions = true;
PrivilegesHelper::confirmWithException(Privilege::MergeTags);
if (InputHelper::get('submit'))
@ -61,9 +62,8 @@ class TagController
TagModel::merge($suppliedSourceTag, $suppliedTargetTag);
\Chibi\UrlHelper::forward(\Chibi\UrlHelper::route('tag', 'list'));
LogHelper::log('{user} merged {source} with {target}', ['source' => TextHelper::reprTag($suppliedSourceTag), 'target' => TextHelper::reprTag($suppliedTargetTag)]);
StatusHelper::success();
StatusHelper::success('Tags merged successfully.');
}
}
@ -73,6 +73,7 @@ class TagController
public function renameAction()
{
$this->context->viewName = 'tag-list-wrapper';
$this->context->handleExceptions = true;
PrivilegesHelper::confirmWithException(Privilege::MergeTags);
if (InputHelper::get('submit'))
@ -87,9 +88,8 @@ class TagController
TagModel::rename($suppliedSourceTag, $suppliedTargetTag);
\Chibi\UrlHelper::forward(\Chibi\UrlHelper::route('tag', 'list'));
LogHelper::log('{user} renamed {source} to {target}', ['source' => TextHelper::reprTag($suppliedSourceTag), 'target' => TextHelper::reprTag($suppliedTargetTag)]);
StatusHelper::success();
StatusHelper::success('Tag renamed successfully.');
}
}

View file

@ -6,6 +6,9 @@ class StatusHelper
$context = \Chibi\Registry::getContext();
if (!empty($message))
{
if (!preg_match('/[.?!]$/', $message))
$message .= '.';
$context->transport->message = $message;
$context->transport->messageHtml = TextHelper::parseMarkdown($message, true);
}

View file

@ -14,6 +14,8 @@
<input type="hidden" name="submit" value="1"/>
<?php $this->renderFile('message') ?>
<div class="form-row">
<label></label>
<button class="submit" type="submit">Merge!</button>

View file

@ -14,6 +14,8 @@
<input type="hidden" name="submit" value="1"/>
<?php $this->renderFile('message') ?>
<div class="form-row">
<label></label>
<button class="submit" type="submit">Rename!</button>