mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-15 22:28:14 +00:00
Can edit category notes
This commit is contained in:
@@ -41,11 +41,8 @@ use Illuminate\View\View;
|
||||
class EditController extends Controller
|
||||
{
|
||||
|
||||
/** @var CategoryRepositoryInterface The category repository */
|
||||
private $repository;
|
||||
|
||||
/** @var AttachmentHelperInterface Helper for attachments. */
|
||||
private $attachments;
|
||||
private CategoryRepositoryInterface $repository;
|
||||
private AttachmentHelperInterface $attachments;
|
||||
|
||||
/**
|
||||
* CategoryController constructor.
|
||||
@@ -58,9 +55,9 @@ class EditController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.categories'));
|
||||
app('view')->share('title', (string)trans('firefly.categories'));
|
||||
app('view')->share('mainTitleIcon', 'fa-bookmark');
|
||||
$this->repository = app(CategoryRepositoryInterface::class);
|
||||
$this->repository = app(CategoryRepositoryInterface::class);
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
|
||||
return $next($request);
|
||||
@@ -79,7 +76,7 @@ class EditController extends Controller
|
||||
*/
|
||||
public function edit(Request $request, Category $category)
|
||||
{
|
||||
$subTitle = (string) trans('firefly.edit_category', ['name' => $category->name]);
|
||||
$subTitle = (string)trans('firefly.edit_category', ['name' => $category->name]);
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (true !== session('categories.edit.fromUpdate')) {
|
||||
@@ -87,7 +84,11 @@ class EditController extends Controller
|
||||
}
|
||||
$request->session()->forget('categories.edit.fromUpdate');
|
||||
|
||||
return view('categories.edit', compact('category', 'subTitle'));
|
||||
$preFilled = [
|
||||
'notes' => $request->old('notes') ?? $this->repository->getNoteText($category),
|
||||
];
|
||||
|
||||
return view('categories.edit', compact('category', 'subTitle', 'preFilled'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,7 +104,7 @@ class EditController extends Controller
|
||||
$data = $request->getCategoryData();
|
||||
$this->repository->update($category, $data);
|
||||
|
||||
$request->session()->flash('success', (string) trans('firefly.updated_category', ['name' => $category->name]));
|
||||
$request->session()->flash('success', (string)trans('firefly.updated_category', ['name' => $category->name]));
|
||||
app('preferences')->mark();
|
||||
|
||||
// store new attachment(s):
|
||||
@@ -112,7 +113,7 @@ class EditController extends Controller
|
||||
$this->attachments->saveAttachmentsForModel($category, $files);
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
session()->flash('info',(string)trans('firefly.no_att_demo_user'));
|
||||
session()->flash('info', (string)trans('firefly.no_att_demo_user'));
|
||||
}
|
||||
|
||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
@@ -122,7 +123,7 @@ class EditController extends Controller
|
||||
|
||||
$redirect = redirect($this->getPreviousUri('categories.edit.uri'));
|
||||
|
||||
if (1 === (int) $request->get('return_to_edit')) {
|
||||
if (1 === (int)$request->get('return_to_edit')) {
|
||||
// @codeCoverageIgnoreStart
|
||||
$request->session()->put('categories.edit.fromUpdate', true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user