Skip to content

Firefly III: a personal finances manager

Fix missing parameters

James Cole94d70cdb620b
diff --git a/app/Api/V2/Controllers/Autocomplete/CategoryController.php b/app/Api/V2/Controllers/Autocomplete/CategoryController.php
index 683cba4b06..1fac580dbc 100644
--- a/app/Api/V2/Controllers/Autocomplete/CategoryController.php
+++ b/app/Api/V2/Controllers/Autocomplete/CategoryController.php
@@ -63,13 +63,14 @@ class CategoryController extends Controller
*/
public function categories(AutocompleteRequest $request): JsonResponse
{
- $data = $request->getData();
- $result = $this->repository->searchCategory($data['query'], $this->parameters->get('limit'));
+ $queryParameters = $request->getParameters();
+ $result = $this->repository->searchCategory($queryParameters['query'], $this->parameters->get('size'));
$filtered = $result->map(
static function (Category $item) {
return [
'id' => (string)$item->id,
- 'name' => $item->name,
+ 'title' => $item->name,
+ 'meta' => [],
];
}
);
diff --git a/app/Api/V2/Controllers/Autocomplete/TagController.php b/app/Api/V2/Controllers/Autocomplete/TagController.php
index 780241cd0f..35fd46cc2d 100644
--- a/app/Api/V2/Controllers/Autocomplete/TagController.php
+++ b/app/Api/V2/Controllers/Autocomplete/TagController.php
@@ -63,13 +63,14 @@ class TagController extends Controller
*/
public function tags(AutocompleteRequest $request): JsonResponse
{
- $data = $request->getData();
- $result = $this->repository->searchTag($data['query'], $data['limit']);
+ $queryParameters = $request->getParameters();
+ $result = $this->repository->searchTag($queryParameters['query'], $queryParameters['size']);
$filtered = $result->map(
static function (Tag $item) {
return [
'id' => (string)$item->id,
'name' => $item->tag,
+ 'title' => $item->tag,
'value' => (string)$item->id,
'label' => $item->tag,
];
diff --git a/app/Api/V2/Controllers/Autocomplete/TransactionController.php b/app/Api/V2/Controllers/Autocomplete/TransactionController.php
index fa49140af1..c6f1da01ac 100644
--- a/app/Api/V2/Controllers/Autocomplete/TransactionController.php
+++ b/app/Api/V2/Controllers/Autocomplete/TransactionController.php
@@ -63,8 +63,8 @@ class TransactionController extends Controller
*/
public function transactionDescriptions(AutocompleteRequest $request): JsonResponse
{
- $data = $request->getData();
- $result = $this->repository->searchJournalDescriptions($data['query'], $data['limit']);
+ $queryParameters = $request->getParameters();
+ $result = $this->repository->searchJournalDescriptions($queryParameters['query'], $queryParameters['limit']);
// limit and unique
$filtered = $result->unique('description');
@@ -73,10 +73,13 @@ class TransactionController extends Controller
/** @var TransactionJournal $journal */
foreach ($filtered as $journal) {
$array[] = [
- 'id' => (string)$journal->id,
- 'transaction_group_id' => (string)$journal->transaction_group_id,
- 'name' => $journal->description,
- 'description' => $journal->description,
+ 'id' => (string) $journal->id,
+ 'title' => $journal->description,
+ 'meta' => [
+ 'description' => $journal->description,
+ 'transaction_group_id' => (string) $journal->transaction_group_id,
+ 'name' => $journal->description,
+ ],
];
}
diff --git a/app/Api/V2/Request/Autocomplete/AutocompleteRequest.php b/app/Api/V2/Request/Autocomplete/AutocompleteRequest.php
index d37d01b6ee..7a9b55cb80 100644
--- a/app/Api/V2/Request/Autocomplete/AutocompleteRequest.php
+++ b/app/Api/V2/Request/Autocomplete/AutocompleteRequest.php
@@ -73,27 +73,28 @@ class AutocompleteRequest extends FormRequest
];
}
- public function getData(): array
- {
- return [];
- $types = $this->convertString('types');
- $array = [];
- if ('' !== $types) {
- $array = explode(',', $types);
- }
- $limit = $this->convertInteger('limit');
- $limit = 0 === $limit ? 10 : $limit;
-
- // remove 'initial balance' and another from allowed types. its internal
- $array = array_diff($array, [AccountType::INITIAL_BALANCE, AccountType::RECONCILIATION]);
-
- return [
- 'types' => $array,
- 'query' => $this->convertString('query'),
- 'date' => $this->getCarbonDate('date'),
- 'limit' => $limit,
- ];
- }
+// public function getData(): array
+// {
+//
+// return [];
+// $types = $this->convertString('types');
+// $array = [];
+// if ('' !== $types) {
+// $array = explode(',', $types);
+// }
+// $limit = $this->convertInteger('limit');
+// $limit = 0 === $limit ? 10 : $limit;
+//
+// // remove 'initial balance' and another from allowed types. its internal
+// $array = array_diff($array, [AccountType::INITIAL_BALANCE, AccountType::RECONCILIATION]);
+//
+// return [
+// 'types' => $array,
+// 'query' => $this->convertString('query'),
+// 'date' => $this->getCarbonDate('date'),
+// 'limit' => $limit,
+// ];
+// }
public function rules(): array
{