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

only redirect to previous page if not creating

This commit is contained in:
Godfrey M
2025-08-05 12:05:22 -07:00
parent a35731d9d5
commit 18e49e9067
6 changed files with 48 additions and 30 deletions

View File

@ -1543,11 +1543,6 @@ class Helper
// return to previous page
if ($redirect_option === 'back') {
if ($backUrl === route('home')) {
return redirect()->to($backUrl)
->with('warning', trans('general.page_error'));
}
return redirect()->to($backUrl);
}

View File

@ -1,3 +1,13 @@
@php
$options = [
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => 'components']),
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.component')]),
];
if (Route::currentRouteName() !== 'components.create') {
$options['back'] = trans('admin/hardware/form.redirect_to_type',['type' => trans('general.previous_page')]);
}
@endphp
@extends('layouts/edit-form', [
'createText' => trans('admin/components/general.create') ,
'updateText' => trans('admin/components/general.update'),
@ -5,12 +15,7 @@
'helpText' => trans('help.components'),
'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')]),
]
'options' => $options,
])
{{-- Page content --}}

View File

@ -1,3 +1,13 @@
@php
$options = [
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => 'consumables']),
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.consumable')]),
];
if (Route::currentRouteName() !== 'consumables.create') {
$options['back'] = trans('admin/hardware/form.redirect_to_type',['type' => trans('general.previous_page')]);
}
@endphp
@extends('layouts/edit-form', [
'createText' => trans('admin/consumables/general.create') ,
'updateText' => trans('admin/consumables/general.update'),
@ -5,11 +15,7 @@
'helpText' => trans('help.consumables'),
'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')]),
]
'options' => $options,
])
{{-- Page content --}}
@section('inputFields')

View File

@ -1,3 +1,13 @@
@php
$options = [
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => 'assets']),
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.asset')]),
'other_redirect' => trans('admin/hardware/form.redirect_to_type', [ 'type' => trans('general.asset') . ' ' . trans('general.asset_model')]),
];
if (Route::currentRouteName() !== 'hardware.create') {
$options['back'] = trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.previous_page')]);
}
@endphp
@extends('layouts/edit-form', [
'createText' => trans('admin/hardware/form.create'),
@ -7,12 +17,7 @@
'helpPosition' => 'right',
'formAction' => ($item->id) ? route('hardware.update', $item) : route('hardware.store'),
'index_route' => 'hardware.index',
'options' => [
'back' => trans('admin/hardware/form.redirect_to_type',['type' => trans('general.previous_page')]),
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => 'assets']),
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.asset')]),
'other_redirect' => trans('admin/hardware/form.redirect_to_type', [ 'type' => trans('general.asset').' '.trans('general.asset_model')]),
]
'options' => $options,
])

View File

@ -1,14 +1,20 @@
@php
$options = [
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => 'licenses']),
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.license')]),
];
if (Route::currentRouteName() !== 'licenses.create') {
$options['back'] = trans('admin/hardware/form.redirect_to_type',['type' => trans('general.previous_page')]);
}
@endphp
@extends('layouts/edit-form', [
'createText' => trans('admin/licenses/form.create'),
'updateText' => trans('admin/licenses/form.update'),
'topSubmit' => true,
'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')]),
]
'options' => $options,
])
{{-- Page content --}}

View File

@ -639,11 +639,12 @@
<x-redirect_submit_options
index_route="users.index"
:button_label="trans('general.save')"
:options="[
'back' => trans('admin/hardware/form.redirect_to_type',['type' => trans('general.previous_page')]),
:options="array_filter([
Route::currentRouteName() !== 'users.create' ?
['back' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.previous_page')])] : null,
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => 'users']),
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.user')]),
]"
])"
/>
</div><!-- nav-tabs-custom -->
</form>