3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-02-05 00:35:22 +00:00

editing controllers and edit blades for other categories

This commit is contained in:
Godfrey M
2025-07-01 12:31:55 -07:00
parent ca9ff8cf19
commit 8a9cf07063
9 changed files with 24 additions and 10 deletions

View File

@ -1484,7 +1484,7 @@ class Helper
static public function getRedirectOption($request, $id, $table, $item_id = null) : RedirectResponse
{
$redirect_option = Session::get('redirect_option');
$redirect_option = Session::get('redirect_option') ?? $request->input('redirect_option');
$checkout_to_type = Session::get('checkout_to_type');
$checkedInFrom = Session::get('checkedInFrom');
$other_redirect = Session::get('other_redirect');

View File

@ -91,7 +91,8 @@ class ComponentsController extends Controller
session()->put(['redirect_option' => $request->get('redirect_option')]);
if ($component->save()) {
return redirect()->to(Helper::getRedirectOption($request, $component->id, 'Components'))->with('success', trans('admin/components/message.create.success'));
return Helper::getRedirectOption($request, $component->id, 'Components')
->with('success', trans('admin/components/message.create.success'));
}
return redirect()->back()->withInput()->withErrors($component->getErrors());
@ -111,6 +112,7 @@ class ComponentsController extends Controller
{
$this->authorize('update', $component);
session()->put('back_url', url()->previous());
return view('components/edit')
->with('item', $component)
->with('category_type', 'component');
@ -164,7 +166,8 @@ class ComponentsController extends Controller
session()->put(['redirect_option' => $request->get('redirect_option')]);
if ($component->save()) {
return redirect()->to(Helper::getRedirectOption($request, $component->id, 'Components'))->with('success', trans('admin/components/message.update.success'));
return Helper::getRedirectOption($request, $component->id, 'Components')
->with('success', trans('admin/components/message.update.success'));
}
return redirect()->back()->withInput()->withErrors($component->getErrors());

View File

@ -90,7 +90,8 @@ class ConsumablesController extends Controller
session()->put(['redirect_option' => $request->get('redirect_option')]);
if ($consumable->save()) {
return redirect()->to(Helper::getRedirectOption($request, $consumable->id, 'Consumables'))->with('success', trans('admin/consumables/message.create.success'));
return Helper::getRedirectOption($request, $consumable->id, 'Consumables')
->with('success', trans('admin/consumables/message.create.success'));
}
return redirect()->back()->withInput()->withErrors($consumable->getErrors());
@ -107,6 +108,7 @@ class ConsumablesController extends Controller
public function edit(Consumable $consumable) : View | RedirectResponse
{
$this->authorize($consumable);
session()->put('back_url', url()->previous());
return view('consumables/edit')
->with('item', $consumable)
->with('category_type', 'consumable');
@ -160,7 +162,8 @@ class ConsumablesController extends Controller
session()->put(['redirect_option' => $request->get('redirect_option')]);
if ($consumable->save()) {
return redirect()->to(Helper::getRedirectOption($request, $consumable->id, 'Consumables'))->with('success', trans('admin/consumables/message.update.success'));
return Helper::getRedirectOption($request, $consumable->id, 'Consumables')
->with('success', trans('admin/consumables/message.update.success'));
}
return redirect()->back()->withInput()->withErrors($consumable->getErrors());

View File

@ -105,7 +105,8 @@ class LicensesController extends Controller
session()->put(['redirect_option' => $request->get('redirect_option')]);
if ($license->save()) {
return redirect()->to(Helper::getRedirectOption($request, $license->id, 'Licenses'))->with('success', trans('admin/licenses/message.create.success'));
return Helper::getRedirectOption($request, $license->id, 'Licenses')
->with('success', trans('admin/licenses/message.create.success'));
}
return redirect()->back()->withInput()->withErrors($license->getErrors());
@ -125,7 +126,7 @@ class LicensesController extends Controller
{
$this->authorize('update', $license);
session()->put('back_url', url()->previous());
$maintained_list = [
'' => 'Maintained',
'1' => 'Yes',
@ -181,7 +182,8 @@ class LicensesController extends Controller
session()->put(['redirect_option' => $request->get('redirect_option')]);
if ($license->save()) {
return redirect()->to(Helper::getRedirectOption($request, $license->id, 'Licenses'))->with('success', trans('admin/licenses/message.update.success'));
return Helper::getRedirectOption($request, $license->id, 'Licenses')
->with('success', trans('admin/licenses/message.update.success'));
}
// If we can't adjust the number of seats, the error is flashed to the session by the event handler in License.php
return redirect()->back()->withInput()->withErrors($license->getErrors());

View File

@ -154,7 +154,8 @@ class UsersController extends Controller
$user->notify(new WelcomeNotification($data));
}
return redirect()->to(Helper::getRedirectOption($request, $user->id, 'Users'))->with('success', trans('admin/users/message.success.create'));
return Helper::getRedirectOption($request, $user->id, 'Users')
->with('success', trans('admin/users/message.success.create'));
}
return redirect()->back()->withInput()->withErrors($user->getErrors());
@ -186,6 +187,7 @@ class UsersController extends Controller
{
$this->authorize('update', User::class);
session()->put('back_url', url()->previous());
$user = User::with(['assets', 'assets.model', 'consumables', 'accessories', 'licenses', 'userloc'])->withTrashed()->find($user->id);
if ($user) {
@ -312,7 +314,7 @@ class UsersController extends Controller
if ($user->save()) {
// Redirect to the user page
return redirect()->to(Helper::getRedirectOption($request, $user->id, 'Users'))
return Helper::getRedirectOption($request, $user->id, 'Users')
->with('success', trans('admin/users/message.success.update'));
}
return redirect()->back()->withInput()->withErrors($user->getErrors());

View File

@ -6,6 +6,7 @@
'formAction' => (isset($item->id)) ? route('components.update', ['component' => $item->id]) : route('components.store'),
'index_route' => 'components.index',
'options' => [
'back' => trans('admin/hardware/form.redirect_to_type',['type' => trans('general.previous_page')]),
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => 'components']),
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.component')]),
]

View File

@ -6,6 +6,7 @@
'formAction' => (isset($item->id)) ? route('consumables.update', ['consumable' => $item->id]) : route('consumables.store'),
'index_route' => 'consumables.index',
'options' => [
'back' => trans('admin/hardware/form.redirect_to_type',['type' => trans('general.previous_page')]),
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => 'consumables']),
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.consumable')]),
]

View File

@ -5,6 +5,7 @@
'formAction' => ($item->id) ? route('licenses.update', ['license' => $item->id]) : route('licenses.store'),
'index_route' => 'licenses.index',
'options' => [
'back' => trans('admin/hardware/form.redirect_to_type',['type' => trans('general.previous_page')]),
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => 'licenses']),
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.license')]),
]

View File

@ -599,6 +599,7 @@
index_route="users.index"
:button_label="trans('general.save')"
:options="[
'back' => trans('admin/hardware/form.redirect_to_type',['type' => trans('general.previous_page')]),
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => 'users']),
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.user')]),
]"