Rename parameter

This commit is contained in:
James Cole 2021-04-05 10:56:41 +02:00
parent b812c2e09f
commit f5983f08fd
No known key found for this signature in database
GPG Key ID: B5669F9493CDE38D
4 changed files with 50 additions and 13 deletions

View File

@ -77,7 +77,7 @@ class CreateController extends Controller
$title = $newGroup->title ?? $newGroup->transactionJournals->first()->description; $title = $newGroup->title ?? $newGroup->transactionJournals->first()->description;
$link = route('transactions.show', [$newGroup->id]); $link = route('transactions.show', [$newGroup->id]);
session()->flash('success', trans('firefly.stored_journal', ['description' => $title])); session()->flash('success', trans('firefly.stored_journal', ['description' => $title]));
session()->flash('success_uri', $link); session()->flash('success_url', $link);
return redirect(route('transactions.show', [$newGroup->id])); return redirect(route('transactions.show', [$newGroup->id]));
} }

View File

@ -53,6 +53,10 @@ class InterestingMessage
Preferences::mark(); Preferences::mark();
$this->handleGroupMessage($request); $this->handleGroupMessage($request);
} }
if ($this->accountMessage($request)) {
Preferences::mark();
$this->handleAccountMessage($request);
}
return $next($request); return $next($request);
} }
@ -80,6 +84,25 @@ class InterestingMessage
return null !== $transactionGroupId && null !== $message; return null !== $transactionGroupId && null !== $message;
} }
/**
* @param Request $request
*/
private function handleAccountMessage(Request $request): void {
// get parameters from request.
$accountId = $request->get('account_id');
$message = $request->get('message');
/** @var TransactionGroup $group */
$account = auth()->user()->accounts()->withTrashed()->find($accountId);
if (null === $account) {
return;
}
if ('deleted' === $message) {
session()->flash('success', (string)trans('firefly.account_deleted', ['name' => $account->name]));
}
}
/** /**
* @param Request $request * @param Request $request
*/ */
@ -107,18 +130,32 @@ class InterestingMessage
} }
$title = $count > 1 ? $group->title : $journal->description; $title = $count > 1 ? $group->title : $journal->description;
if ('created' === $message) { if ('created' === $message) {
session()->flash('success_uri', route('transactions.show', [$transactionGroupId])); session()->flash('success_url', route('transactions.show', [$transactionGroupId]));
session()->flash('success', (string)trans('firefly.stored_journal', ['description' => $title])); session()->flash('success', (string)trans('firefly.stored_journal', ['description' => $title]));
} }
if ('updated' === $message) { if ('updated' === $message) {
$type = strtolower($journal->transactionType->type); $type = strtolower($journal->transactionType->type);
session()->flash('success_uri', route('transactions.show', [$transactionGroupId])); session()->flash('success_url', route('transactions.show', [$transactionGroupId]));
session()->flash('success', (string)trans(sprintf('firefly.updated_%s', $type), ['description' => $title])); session()->flash('success', (string)trans(sprintf('firefly.updated_%s', $type), ['description' => $title]));
} }
if ('no_change' === $message) { if ('no_change' === $message) {
$type = strtolower($journal->transactionType->type); $type = strtolower($journal->transactionType->type);
session()->flash('warning_uri', route('transactions.show', [$transactionGroupId])); session()->flash('warning_url', route('transactions.show', [$transactionGroupId]));
session()->flash('warning', (string)trans(sprintf('firefly.no_changes_%s', $type), ['description' => $title])); session()->flash('warning', (string)trans(sprintf('firefly.no_changes_%s', $type), ['description' => $title]));
} }
} }
/**
* @param Request $request
*
* @return bool
*/
private function accountMessage(Request $request): bool
{
// get parameters from request.
$accountId = $request->get('account_id');
$message = $request->get('message');
return null !== $accountId && null !== $message;
}
} }

View File

@ -15,11 +15,11 @@
<span>&times;</span><span class="sr-only">{{ 'close'|_ }}</span> <span>&times;</span><span class="sr-only">{{ 'close'|_ }}</span>
</button> </button>
<strong>{{ 'flash_success'|_ }}</strong> <strong>{{ 'flash_success'|_ }}</strong>
{% if session_has('success_uri') %} {% if session_has('success_url') %}
<a href="{{ session('success_uri') }}"> <a href="{{ session('success_url') }}">
{% endif %} {% endif %}
{{ session('success') }} {{ session('success') }}
{% if session_has('success_uri') %} {% if session_has('success_url') %}
</a> </a>
{% endif %} {% endif %}

View File

@ -7,11 +7,11 @@
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<h5><i class="icon fas fa-thumbs-up"></i> {{ 'flash_success'|_ }}</h5> <h5><i class="icon fas fa-thumbs-up"></i> {{ 'flash_success'|_ }}</h5>
<span> <span>
{% if session_has('success_uri') %} {% if session_has('success_url') %}
<a href="{{ session('success_uri') }}"> <a href="{{ session('success_url') }}">
{% endif %} {% endif %}
{{ session('success') }} {{ session('success') }}
{% if session_has('success_uri') %} {% if session_has('success_url') %}
</a> </a>
{% endif %} {% endif %}
</span> </span>
@ -28,11 +28,11 @@
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<h5><i class="icon fas fa-exclamation-triangle"></i> {{ 'flash_warning'|_ }}</h5> <h5><i class="icon fas fa-exclamation-triangle"></i> {{ 'flash_warning'|_ }}</h5>
<span> <span>
{% if session_has('warning_uri') %} {% if session_has('warning_url') %}
<a href="{{ session('warning_uri') }}" style="color:rgb(31, 45, 61);"> <a href="{{ session('warning_url') }}" style="color:rgb(31, 45, 61);">
{% endif %} {% endif %}
{{ session('warning') }} {{ session('warning') }}
{% if session_has('warning_uri') %} {% if session_has('warning_url') %}
</a> </a>
{% endif %} {% endif %}
</span> </span>