mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-23 04:18:50 +00:00
Implemented new link thing.
This commit is contained in:
@@ -149,7 +149,42 @@ class AutoCompleteController extends Controller
|
||||
|
||||
|
||||
return response()->json($array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches in the titles of all transaction journals.
|
||||
* The result is limited to the top 15 unique results.
|
||||
*
|
||||
* If the query is numeric, it will append the journal with that particular ID.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function allJournalsWithID(Request $request): JsonResponse
|
||||
{
|
||||
$search = (string)$request->get('search');
|
||||
/** @var JournalRepositoryInterface $repository */
|
||||
$repository = app(JournalRepositoryInterface::class);
|
||||
$result = $repository->searchJournalDescriptions($search);
|
||||
$array = [];
|
||||
if (is_numeric($search)) {
|
||||
$firstResult = $repository->findNull((int)$search);
|
||||
if (null !== $firstResult) {
|
||||
$array[] = $firstResult->toArray();
|
||||
}
|
||||
}
|
||||
// if not numeric, search ahead!
|
||||
|
||||
// limit and unique
|
||||
$limited = $result->slice(0, 15);
|
||||
$array = array_merge($array, $limited->toArray());
|
||||
foreach ($array as $index => $item) {
|
||||
// give another key for consistency
|
||||
$array[$index]['name'] = sprintf('#%d: %s', $item['id'], $item['description']);
|
||||
}
|
||||
|
||||
|
||||
return response()->json($array);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -33,7 +33,8 @@ class EditController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* SingleController constructor.
|
||||
* EditController constructor.
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@@ -48,7 +49,7 @@ class EditController extends Controller
|
||||
|
||||
// some useful repositories:
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
static function ($request, $next) {
|
||||
|
||||
app('view')->share('title', (string)trans('firefly.transactions'));
|
||||
app('view')->share('mainTitleIcon', 'fa-repeat');
|
||||
|
@@ -28,6 +28,8 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionJournalLink;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\View\View;
|
||||
use Log;
|
||||
use URL;
|
||||
|
||||
@@ -43,6 +45,7 @@ class LinkController extends Controller
|
||||
|
||||
/**
|
||||
* LinkController constructor.
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@@ -61,12 +64,23 @@ class LinkController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function modal(TransactionJournal $journal)
|
||||
{
|
||||
$linkTypes = $this->repository->get();
|
||||
|
||||
return view('transactions.links.modal', compact('journal', 'linkTypes'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a link.
|
||||
*
|
||||
* @param TransactionJournalLink $link
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function delete(TransactionJournalLink $link)
|
||||
{
|
||||
@@ -104,9 +118,9 @@ class LinkController extends Controller
|
||||
*/
|
||||
public function store(JournalLinkRequest $request, TransactionJournal $journal)
|
||||
{
|
||||
$linkInfo = $request->getLinkInfo();
|
||||
|
||||
Log::debug('We are here (store)');
|
||||
$linkInfo = $request->getLinkInfo();
|
||||
$other = $this->journalRepository->findNull($linkInfo['transaction_journal_id']);
|
||||
if (null === $other) {
|
||||
session()->flash('error', (string)trans('firefly.invalid_link_selection'));
|
||||
|
@@ -73,7 +73,7 @@ class ShowController extends Controller
|
||||
$type = (string)trans(sprintf('firefly.%s', strtolower($first->transactionType->type)));
|
||||
$title = 1 === $splits ? $first->description : $transactionGroup->title;
|
||||
$subTitle = sprintf('%s: "%s"', $type, $title);
|
||||
$message = $request->get('message');
|
||||
$message = $request->get('message');
|
||||
|
||||
/** @var TransactionGroupTransformer $transformer */
|
||||
$transformer = app(TransactionGroupTransformer::class);
|
||||
@@ -112,9 +112,9 @@ class ShowController extends Controller
|
||||
|
||||
return view(
|
||||
'transactions.show', compact(
|
||||
'transactionGroup', 'amounts', 'first', 'type', 'subTitle', 'splits', 'groupArray',
|
||||
'events', 'attachments', 'links','message'
|
||||
)
|
||||
'transactionGroup', 'amounts', 'first', 'type', 'subTitle', 'splits', 'groupArray',
|
||||
'events', 'attachments', 'links', 'message'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user