mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Switch things.
This commit is contained in:
parent
03a1601bf3
commit
afd4700758
@ -30,6 +30,7 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\View\View;
|
||||
use Log;
|
||||
@ -157,9 +158,10 @@ class LinkController extends Controller
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
public function switchLink(TransactionJournalLink $link)
|
||||
public function switchLink(Request $request)
|
||||
{
|
||||
$this->repository->switchLink($link);
|
||||
$linkId = (int)$request->get('id');
|
||||
$this->repository->switchLinkById($linkId);
|
||||
|
||||
return redirect(app('steam')->getSafePreviousUrl());
|
||||
}
|
||||
|
@ -389,4 +389,21 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
|
||||
|
||||
return TransactionJournalLink::whereDestinationId($two->id)->whereSourceId($one->id)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function switchLinkById(int $linkId): bool
|
||||
{
|
||||
/** @var TransactionJournalLink $link */
|
||||
$link = TransactionJournalLink::find($linkId);
|
||||
if (null !== $link) {
|
||||
|
||||
if ($link->source->user->id === $this->user->id) {
|
||||
$this->switchLink($link);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -154,6 +154,13 @@ interface LinkTypeRepositoryInterface
|
||||
*/
|
||||
public function switchLink(TransactionJournalLink $link): bool;
|
||||
|
||||
/**
|
||||
* @param int $linkId
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function switchLinkById(int $linkId): bool;
|
||||
|
||||
/**
|
||||
* @param LinkType $linkType
|
||||
* @param array $data
|
||||
|
@ -27,8 +27,8 @@
|
||||
<tr>
|
||||
<td>
|
||||
<div class="btn-group btn-group-xs">
|
||||
<a href="{{ route('transactions.link.delete', [link.id]) }}" class="btn btn-danger"><span class="fa fa-trash"></span></a>
|
||||
<a href="{{ route('transactions.link.switch', [link.id]) }}" class="btn btn-default"><span
|
||||
<a href="{{ route('transactions.link.delete', [link.id]) }}" class="btn btn-danger delete-link" data-id="{{ link.id }}"><span class="fa fa-trash"></span></a>
|
||||
<a href="#" class="btn btn-default switch-link" data-id="{{ link.id }}"><span
|
||||
class="fa fa-fw fa-arrows-h"></span></a>
|
||||
</div>
|
||||
</td>
|
||||
@ -58,6 +58,28 @@
|
||||
{% endblock %}
|
||||
{% block scripts %}
|
||||
<script type="text/javascript" src="v1/js/lib/bootstrap-sortable.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>
|
||||
<script nonce="{{ JS_NONCE }}">
|
||||
$('.switch-link').on('click', switchLink);
|
||||
var switchLinkUrl = '{{ route('transactions.link.switch') }}';
|
||||
function switchLink(e) {
|
||||
e.preventDefault();
|
||||
var obj = $(e.currentTarget);
|
||||
|
||||
$.post(switchLinkUrl, {
|
||||
_token: token,
|
||||
id: obj.data('id')
|
||||
}).done(function () {
|
||||
location.reload();
|
||||
}).fail(function () {
|
||||
console.error('I failed :(');
|
||||
});
|
||||
|
||||
//alert(obj.data('id'));
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block styles %}
|
||||
|
@ -126,13 +126,11 @@
|
||||
<input class="btn btn-default" style="margin-top:20px;" type="submit" name="submit" value="{{ 'pref_two_factor_new_backup_codes'|_ }}" />
|
||||
</form>
|
||||
{% else %}
|
||||
<p>
|
||||
<form action="{{ route('profile.enable2FA') }}" method="post">
|
||||
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
||||
<button type="submit" class="btn btn-info"><span
|
||||
class="fa fa-lock"></span> {{ 'pref_enable_two_factor_auth'|_ }}</button>
|
||||
</form>
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -357,7 +357,7 @@
|
||||
<tr>
|
||||
<td style="width:120px;">
|
||||
<div class="btn-group btn-group-xs">
|
||||
<a href="{{ route('transactions.link.switch', [link.id]) }}" class="btn btn-default"><span
|
||||
<a href="#" class="btn btn-default switch-link" data-id="{{ link.id }}"><span
|
||||
class="fa fa-fw fa-arrows-h"></span></a>
|
||||
<a href="{{ route('transactions.link.delete', [link.id]) }}" class="btn btn-danger"><span class="fa fa-trash"></span></a>
|
||||
</div>
|
||||
@ -423,6 +423,25 @@
|
||||
var acURI = '{{ route('api.v1.autocomplete.transactions-with-id') }}';
|
||||
var groupURI = '{{ route('transactions.show',['%GROUP%']) }}';
|
||||
var cloneGroupUrl = '{{ route('transactions.clone') }}';
|
||||
|
||||
$('.switch-link').on('click', switchLink);
|
||||
var switchLinkUrl = '{{ route('transactions.link.switch') }}';
|
||||
function switchLink(e) {
|
||||
e.preventDefault();
|
||||
var obj = $(e.currentTarget);
|
||||
$.post(switchLinkUrl, {
|
||||
_token: token,
|
||||
id: obj.data('id')
|
||||
}).done(function () {
|
||||
location.reload();
|
||||
}).fail(function () {
|
||||
console.error('I failed :(');
|
||||
});
|
||||
|
||||
//alert(obj.data('id'));
|
||||
|
||||
return false
|
||||
}
|
||||
</script>
|
||||
<script type="text/javascript" src="v1/js/lib/typeahead/typeahead.bundle.min.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>
|
||||
<script type="text/javascript" src="v1/js/ff/transactions/show.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>
|
||||
|
@ -1079,8 +1079,7 @@ Route::group(
|
||||
// See reference nr. 6
|
||||
Route::post('store/{tj}', ['uses' => 'LinkController@store', 'as' => 'store']);
|
||||
Route::get('delete/{journalLink}', ['uses' => 'LinkController@delete', 'as' => 'delete']);
|
||||
Route::post('switch/{journalLink}', ['uses' => 'LinkController@switchLink', 'as' => 'switch']);
|
||||
|
||||
Route::post('switch', ['uses' => 'LinkController@switchLink', 'as' => 'switch']);
|
||||
Route::post('destroy/{journalLink}', ['uses' => 'LinkController@destroy', 'as' => 'destroy']);
|
||||
}
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user