mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-05 20:22:07 +00:00
Switch things.
This commit is contained in:
@@ -30,6 +30,7 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
|||||||
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
|
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
|
||||||
use Illuminate\Contracts\View\Factory;
|
use Illuminate\Contracts\View\Factory;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Routing\Redirector;
|
use Illuminate\Routing\Redirector;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
use Log;
|
use Log;
|
||||||
@@ -157,9 +158,10 @@ class LinkController extends Controller
|
|||||||
*
|
*
|
||||||
* @return RedirectResponse|Redirector
|
* @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());
|
return redirect(app('steam')->getSafePreviousUrl());
|
||||||
}
|
}
|
||||||
|
@@ -389,4 +389,21 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
|
|||||||
|
|
||||||
return TransactionJournalLink::whereDestinationId($two->id)->whereSourceId($one->id)->first();
|
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;
|
public function switchLink(TransactionJournalLink $link): bool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $linkId
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function switchLinkById(int $linkId): bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param LinkType $linkType
|
* @param LinkType $linkType
|
||||||
* @param array $data
|
* @param array $data
|
||||||
|
@@ -27,8 +27,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<div class="btn-group btn-group-xs">
|
<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.delete', [link.id]) }}" class="btn btn-danger delete-link" data-id="{{ link.id }}"><span class="fa fa-trash"></span></a>
|
||||||
<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>
|
class="fa fa-fw fa-arrows-h"></span></a>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
@@ -58,6 +58,28 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script type="text/javascript" src="v1/js/lib/bootstrap-sortable.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>
|
<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 %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block styles %}
|
{% 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'|_ }}" />
|
<input class="btn btn-default" style="margin-top:20px;" type="submit" name="submit" value="{{ 'pref_two_factor_new_backup_codes'|_ }}" />
|
||||||
</form>
|
</form>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>
|
|
||||||
<form action="{{ route('profile.enable2FA') }}" method="post">
|
<form action="{{ route('profile.enable2FA') }}" method="post">
|
||||||
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
||||||
<button type="submit" class="btn btn-info"><span
|
<button type="submit" class="btn btn-info"><span
|
||||||
class="fa fa-lock"></span> {{ 'pref_enable_two_factor_auth'|_ }}</button>
|
class="fa fa-lock"></span> {{ 'pref_enable_two_factor_auth'|_ }}</button>
|
||||||
</form>
|
</form>
|
||||||
</p>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -357,7 +357,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td style="width:120px;">
|
<td style="width:120px;">
|
||||||
<div class="btn-group btn-group-xs">
|
<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>
|
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>
|
<a href="{{ route('transactions.link.delete', [link.id]) }}" class="btn btn-danger"><span class="fa fa-trash"></span></a>
|
||||||
</div>
|
</div>
|
||||||
@@ -423,6 +423,25 @@
|
|||||||
var acURI = '{{ route('api.v1.autocomplete.transactions-with-id') }}';
|
var acURI = '{{ route('api.v1.autocomplete.transactions-with-id') }}';
|
||||||
var groupURI = '{{ route('transactions.show',['%GROUP%']) }}';
|
var groupURI = '{{ route('transactions.show',['%GROUP%']) }}';
|
||||||
var cloneGroupUrl = '{{ route('transactions.clone') }}';
|
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>
|
||||||
<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/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>
|
<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
|
// See reference nr. 6
|
||||||
Route::post('store/{tj}', ['uses' => 'LinkController@store', 'as' => 'store']);
|
Route::post('store/{tj}', ['uses' => 'LinkController@store', 'as' => 'store']);
|
||||||
Route::get('delete/{journalLink}', ['uses' => 'LinkController@delete', 'as' => 'delete']);
|
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']);
|
Route::post('destroy/{journalLink}', ['uses' => 'LinkController@destroy', 'as' => 'destroy']);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user