mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 14:27:33 -08:00
Use blade component for redirect option
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
f77d300549
commit
73a80a5fbc
|
@ -1491,21 +1491,23 @@ class Helper
|
||||||
$checkout_to_type = Session::get('checkout_to_type');
|
$checkout_to_type = Session::get('checkout_to_type');
|
||||||
|
|
||||||
// return to index
|
// return to index
|
||||||
if ($redirect_option == '0') {
|
if ($redirect_option == 'index') {
|
||||||
switch ($table) {
|
switch ($table) {
|
||||||
case "Assets":
|
case "Assets":
|
||||||
return redirect()->route('hardware.index')->with('success', trans('admin/hardware/message.checkout.success'));
|
return redirect()->route('hardware.index')->with('success', trans('admin/hardware/message.checkout.success'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// return to thing being assigned
|
// return to thing being assigned
|
||||||
if ($redirect_option == '1') {
|
if ($redirect_option == 'item') {
|
||||||
switch ($table) {
|
switch ($table) {
|
||||||
case "Assets":
|
case "Assets":
|
||||||
return redirect()->route('hardware.show', $id ? $id : $asset_id)->with('success', trans('admin/hardware/message.checkout.success'));
|
return redirect()->route('hardware.show', $id ? $id : $asset_id)->with('success', trans('admin/hardware/message.checkout.success'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//return to thing being assigned to
|
|
||||||
if ($redirect_option == '2') {
|
// return to assignment target
|
||||||
|
if ($redirect_option == 'target') {
|
||||||
switch ($checkout_to_type) {
|
switch ($checkout_to_type) {
|
||||||
case 'user':
|
case 'user':
|
||||||
return redirect()->route('users.show', $request->assigned_user)->with('success', trans('admin/hardware/message.checkout.success'));
|
return redirect()->route('users.show', $request->assigned_user)->with('success', trans('admin/hardware/message.checkout.success'));
|
||||||
|
|
|
@ -23,6 +23,7 @@ use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Gate;
|
use Illuminate\Support\Facades\Gate;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Crypt;
|
use Illuminate\Support\Facades\Crypt;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use League\Csv\Reader;
|
use League\Csv\Reader;
|
||||||
|
@ -204,6 +205,8 @@ class AssetsController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
session()->put(['redirect_option' => $request->get('redirect_option'), 'checkout_to_type' => $request->get('checkout_to_type')]);
|
||||||
|
|
||||||
if ($success) {
|
if ($success) {
|
||||||
return redirect()->route('hardware.index')
|
return redirect()->route('hardware.index')
|
||||||
->with('success-unescaped', trans('admin/hardware/message.create.success_linked', ['link' => route('hardware.show', ['hardware' => $asset->id]), 'id', 'tag' => e($asset->asset_tag)]));
|
->with('success-unescaped', trans('admin/hardware/message.create.success_linked', ['link' => route('hardware.show', ['hardware' => $asset->id]), 'id', 'tag' => e($asset->asset_tag)]));
|
||||||
|
@ -289,6 +292,8 @@ class AssetsController extends Controller
|
||||||
*/
|
*/
|
||||||
public function update(ImageUploadRequest $request, $assetId = null) : RedirectResponse
|
public function update(ImageUploadRequest $request, $assetId = null) : RedirectResponse
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
// Check if the asset exists
|
// Check if the asset exists
|
||||||
if (! $asset = Asset::find($assetId)) {
|
if (! $asset = Asset::find($assetId)) {
|
||||||
// Redirect to the asset management page with error
|
// Redirect to the asset management page with error
|
||||||
|
@ -387,10 +392,10 @@ class AssetsController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
session()->put(['redirect_option' => $request->get('redirect_option'), 'checkout_to_type' => $request->get('checkout_to_type')]);
|
||||||
|
|
||||||
if ($asset->save()) {
|
if ($asset->save()) {
|
||||||
return redirect()->route('hardware.show', $assetId)
|
return Helper::getRedirectOption($request, $assetId, 'Assets');
|
||||||
->with('success', trans('admin/hardware/message.update.success'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back()->withInput()->withErrors($asset->getErrors());
|
return redirect()->back()->withInput()->withErrors($asset->getErrors());
|
||||||
|
|
38
resources/views/blade/redirect_submit_options.blade.php
Normal file
38
resources/views/blade/redirect_submit_options.blade.php
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
<!-- begin redirect submit options -->
|
||||||
|
@props([
|
||||||
|
'route' => 'hardware.index',
|
||||||
|
'button_label',
|
||||||
|
'disabled_select' => false,
|
||||||
|
'options' => [],
|
||||||
|
])
|
||||||
|
|
||||||
|
<div class="box-footer">
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
|
<div class="col-md-3">
|
||||||
|
<a class="btn btn-link" href="{{ route($route) }}">{{ trans('button.cancel') }}</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-9 text-right">
|
||||||
|
<div class="btn-group text-left">
|
||||||
|
|
||||||
|
@if (($options) && (count($options) > 0))
|
||||||
|
<select class="redirect-options form-control select2" data-minimum-results-for-search="Infinity" name="redirect_option" style="min-width: 200px"{{ ($disabled_select ? ' disabled' : '') }}>
|
||||||
|
@foreach ($options as $key => $value)
|
||||||
|
<option value="{{ $key }}"{{ Session::get('redirect_option') == $key ? ' selected' : ''}}>
|
||||||
|
{{ $value }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<button type="submit" class="btn btn-primary pull-right{{ ($disabled_select ? ' disabled' : '') }}" style="margin-left:5px; border-radius: 3px;"{!! ($disabled_select ? ' data-tooltip="true" title="'.trans('admin/hardware/general.edit').'" disabled' : '') !!}>
|
||||||
|
<i class="fas fa-check icon-white" aria-hidden="true"></i>
|
||||||
|
{{ $button_label }}
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</div><!-- /.btn-group -->
|
||||||
|
</div><!-- /.col-md-9 -->
|
||||||
|
</div><!-- /.row -->
|
||||||
|
</div> <!-- /.box-footer -->
|
||||||
|
<!-- end redirect submit options -->
|
|
@ -31,9 +31,13 @@
|
||||||
<div class="col-md-12"><!-- .col-md-12 -->
|
<div class="col-md-12"><!-- .col-md-12 -->
|
||||||
|
|
||||||
@if ($backto == 'user')
|
@if ($backto == 'user')
|
||||||
<form class="form-horizontal" method="post" action="{{ route('hardware.checkin.store', array('assetId'=> $asset->id, 'backto'=>'user')) }}" autocomplete="off">
|
<form class="form-horizontal" method="post"
|
||||||
|
action="{{ route('hardware.checkin.store', array('assetId'=> $asset->id, 'backto'=>'user')) }}"
|
||||||
|
autocomplete="off">
|
||||||
@else
|
@else
|
||||||
<form class="form-horizontal" method="post" action="{{ route('hardware.checkin.store', array('assetId'=> $asset->id)) }}" autocomplete="off">
|
<form class="form-horizontal" method="post"
|
||||||
|
action="{{ route('hardware.checkin.store', array('assetId'=> $asset->id)) }}"
|
||||||
|
autocomplete="off">
|
||||||
@endif
|
@endif
|
||||||
{{csrf_field()}}
|
{{csrf_field()}}
|
||||||
|
|
||||||
|
@ -68,7 +72,8 @@
|
||||||
{{ trans('general.name') }}
|
{{ trans('general.name') }}
|
||||||
</label>
|
</label>
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
<input class="form-control" type="text" name="name" aria-label="name" id="name" value="{{ old('name', $asset->name) }}"/>
|
<input class="form-control" type="text" name="name" aria-label="name"
|
||||||
|
id="name" value="{{ old('name', $asset->name) }}"/>
|
||||||
{!! $errors->first('name', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
{!! $errors->first('name', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -94,9 +99,14 @@
|
||||||
|
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
<div class="input-group col-md-5 required">
|
<div class="input-group col-md-5 required">
|
||||||
<div class="input-group date" data-provide="datepicker" data-date-format="yyyy-mm-dd" data-autoclose="true">
|
<div class="input-group date" data-provide="datepicker"
|
||||||
<input type="text" class="form-control" placeholder="{{ trans('general.select_date') }}" name="checkin_at" id="checkin_at" value="{{ old('checkin_at', date('Y-m-d')) }}">
|
data-date-format="yyyy-mm-dd" data-autoclose="true">
|
||||||
<span class="input-group-addon"><i class="fas fa-calendar" aria-hidden="true"></i></span>
|
<input type="text" class="form-control"
|
||||||
|
placeholder="{{ trans('general.select_date') }}"
|
||||||
|
name="checkin_at" id="checkin_at"
|
||||||
|
value="{{ old('checkin_at', date('Y-m-d')) }}">
|
||||||
|
<span class="input-group-addon"><i class="fas fa-calendar"
|
||||||
|
aria-hidden="true"></i></span>
|
||||||
</div>
|
</div>
|
||||||
{!! $errors->first('checkin_at', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
{!! $errors->first('checkin_at', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||||
</div>
|
</div>
|
||||||
|
@ -109,25 +119,27 @@
|
||||||
{{ trans('general.notes') }}
|
{{ trans('general.notes') }}
|
||||||
</label>
|
</label>
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
<textarea class="col-md-6 form-control" id="note" name="note">{{ old('note', $asset->note) }}</textarea>
|
<textarea class="col-md-6 form-control" id="note"
|
||||||
|
name="note">{{ old('note', $asset->note) }}</textarea>
|
||||||
{!! $errors->first('note', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
{!! $errors->first('note', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div> <!--/.box-body-->
|
</div> <!--/.box-body-->
|
||||||
</div> <!--/.box-body-->
|
</div> <!--/.box-body-->
|
||||||
|
|
||||||
@include ('partials.forms.redirect_submit_options',
|
<x-redirect_submit_options
|
||||||
[
|
route="hardware.index"
|
||||||
'route' => 'hardware.index',
|
:button_label="trans('general.checkout')"
|
||||||
'table_name' => $table_name,
|
:disabled_select="!$asset->model"
|
||||||
'type'=> ($asset->model ? $asset->model->name : trans('general.asset_model')),
|
:options="[
|
||||||
'checkin' => true
|
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => 'assets']),
|
||||||
])
|
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.asset')]),
|
||||||
|
]"
|
||||||
|
/>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@stop
|
@stop
|
|
@ -70,7 +70,8 @@
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
<input class="form-control" type="text" name="name" id="name" value="{{ old('name', $asset->name) }}" tabindex="1">
|
<input class="form-control" type="text" name="name" id="name"
|
||||||
|
value="{{ old('name', $asset->name) }}" tabindex="1">
|
||||||
{!! $errors->first('name', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
{!! $errors->first('name', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -103,9 +104,13 @@
|
||||||
{{ trans('admin/hardware/form.checkout_date') }}
|
{{ trans('admin/hardware/form.checkout_date') }}
|
||||||
</label>
|
</label>
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
<div class="input-group date col-md-7" data-provide="datepicker" data-date-format="yyyy-mm-dd" data-date-end-date="0d" data-date-clear-btn="true">
|
<div class="input-group date col-md-7" data-provide="datepicker"
|
||||||
<input type="text" class="form-control" placeholder="{{ trans('general.select_date') }}" name="checkout_at" id="checkout_at" value="{{ old('checkout_at', date('Y-m-d')) }}">
|
data-date-format="yyyy-mm-dd" data-date-end-date="0d" data-date-clear-btn="true">
|
||||||
<span class="input-group-addon"><i class="fas fa-calendar" aria-hidden="true"></i></span>
|
<input type="text" class="form-control"
|
||||||
|
placeholder="{{ trans('general.select_date') }}" name="checkout_at"
|
||||||
|
id="checkout_at" value="{{ old('checkout_at', date('Y-m-d')) }}">
|
||||||
|
<span class="input-group-addon"><i class="fas fa-calendar"
|
||||||
|
aria-hidden="true"></i></span>
|
||||||
</div>
|
</div>
|
||||||
{!! $errors->first('checkout_at', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
{!! $errors->first('checkout_at', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||||
</div>
|
</div>
|
||||||
|
@ -118,9 +123,13 @@
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
<div class="input-group date col-md-7" data-provide="datepicker" data-date-format="yyyy-mm-dd" data-date-start-date="0d" data-date-clear-btn="true">
|
<div class="input-group date col-md-7" data-provide="datepicker"
|
||||||
<input type="text" class="form-control" placeholder="{{ trans('general.select_date') }}" name="expected_checkin" id="expected_checkin" value="{{ old('expected_checkin') }}">
|
data-date-format="yyyy-mm-dd" data-date-start-date="0d" data-date-clear-btn="true">
|
||||||
<span class="input-group-addon"><i class="fas fa-calendar" aria-hidden="true"></i></span>
|
<input type="text" class="form-control"
|
||||||
|
placeholder="{{ trans('general.select_date') }}" name="expected_checkin"
|
||||||
|
id="expected_checkin" value="{{ old('expected_checkin') }}">
|
||||||
|
<span class="input-group-addon"><i class="fas fa-calendar"
|
||||||
|
aria-hidden="true"></i></span>
|
||||||
</div>
|
</div>
|
||||||
{!! $errors->first('expected_checkin', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
{!! $errors->first('expected_checkin', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||||
</div>
|
</div>
|
||||||
|
@ -132,7 +141,8 @@
|
||||||
{{ trans('general.notes') }}
|
{{ trans('general.notes') }}
|
||||||
</label>
|
</label>
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
<textarea class="col-md-6 form-control" id="note" name="note">{{ old('note', $asset->note) }}</textarea>
|
<textarea class="col-md-6 form-control" id="note"
|
||||||
|
name="note">{{ old('note', $asset->note) }}</textarea>
|
||||||
{!! $errors->first('note', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
{!! $errors->first('note', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -164,13 +174,19 @@
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
</div> <!--/.box-body-->
|
</div> <!--/.box-body-->
|
||||||
@include ('partials.forms.redirect_submit_options',
|
|
||||||
[
|
<x-redirect_submit_options
|
||||||
'route' => 'hardware.index',
|
route="hardware.index"
|
||||||
'table_name' => $table_name,
|
:button_label="trans('general.checkout')"
|
||||||
'type'=> ($asset->model ? $asset->model->name : trans('general.asset_model')),
|
:disabled_select="!$asset->model"
|
||||||
'checkin' => false
|
:options="[
|
||||||
])
|
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => 'assets']),
|
||||||
|
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.asset')]),
|
||||||
|
'target' => trans('admin/hardware/form.redirect_to_checked_out_to'),
|
||||||
|
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div> <!--/.col-md-7-->
|
</div> <!--/.col-md-7-->
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
'helpText' => trans('help.assets'),
|
'helpText' => trans('help.assets'),
|
||||||
'helpPosition' => 'right',
|
'helpPosition' => 'right',
|
||||||
'formAction' => ($item->id) ? route('hardware.update', ['hardware' => $item->id]) : route('hardware.store'),
|
'formAction' => ($item->id) ? route('hardware.update', ['hardware' => $item->id]) : route('hardware.store'),
|
||||||
|
'options' => [
|
||||||
|
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => 'assets']),
|
||||||
|
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.asset')]),
|
||||||
|
]
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
@ -130,8 +134,6 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- byod checkbox -->
|
<!-- byod checkbox -->
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-md-7 col-md-offset-3">
|
<div class="col-md-7 col-md-offset-3">
|
||||||
|
|
|
@ -66,7 +66,11 @@
|
||||||
<!-- CSRF Token -->
|
<!-- CSRF Token -->
|
||||||
{{ csrf_field() }}
|
{{ csrf_field() }}
|
||||||
@yield('inputFields')
|
@yield('inputFields')
|
||||||
@include('partials.forms.edit.submit')
|
<x-redirect_submit_options
|
||||||
|
route="hardware.index"
|
||||||
|
:button_label="trans('general.save')"
|
||||||
|
:options="$options ?? []"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div> <!-- ./box-body -->
|
</div> <!-- ./box-body -->
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
<!-- begin redirect submit options -->
|
|
||||||
|
|
||||||
<div class="box-footer">
|
|
||||||
<div class="row">
|
|
||||||
|
|
||||||
<div class="col-md-3">
|
|
||||||
<a class="btn btn-link" href="{{ route($route) }}">{{ trans('button.cancel') }}</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-9 text-right">
|
|
||||||
<div class="btn-group text-left">
|
|
||||||
|
|
||||||
<select class="redirect-options form-control select2" data-minimum-results-for-search="Infinity" name="redirect_option" style="min-width: 200px"{{ (!$asset->model ? ' disabled' : '') }}>
|
|
||||||
|
|
||||||
<option {{ (Session::get('redirect_option')=="0" || (Session::get('redirect_option')=="2" && $checkin)) ? 'selected' : '' }} value="0">
|
|
||||||
{{ trans('admin/hardware/form.redirect_to_all', ['type' => $table_name]) }}
|
|
||||||
</option>
|
|
||||||
<option {{ Session::get('redirect_option')=="1" ? 'selected' : ''}} value="1">
|
|
||||||
{{ trans('admin/hardware/form.redirect_to_type', ['type' => $type]) }}
|
|
||||||
</option>
|
|
||||||
<option {{ Session::get('redirect_option')=="2" && !$checkin ? 'selected' : ''}}{{ $checkin ? 'hidden disabled' : '' }} value="2" >
|
|
||||||
{{ !$checkin ? trans('admin/hardware/form.redirect_to_checked_out_to') : '' }}
|
|
||||||
</option>
|
|
||||||
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<button type="submit" class="btn btn-primary pull-right{{ (!$asset->model ? ' disabled' : '') }}" style="margin-left:5px; border-radius: 3px;"{!! (!$asset->model ? ' data-tooltip="true" title="'.trans('admin/hardware/general.edit').'" disabled' : '') !!}>
|
|
||||||
<i class="fas fa-check icon-white" aria-hidden="true"></i>
|
|
||||||
{{ $checkin ? trans('general.checkin') : trans('general.checkout') }}
|
|
||||||
</button>
|
|
||||||
|
|
||||||
</div><!-- /.btn-group -->
|
|
||||||
</div><!-- /.col-md-9 -->
|
|
||||||
</div><!-- /.row -->
|
|
||||||
</div> <!-- /.box-footer -->
|
|
||||||
<!-- end redirect submit options -->
|
|
Loading…
Reference in a new issue