Updated to use named routes (#3060), some FORM spoofing for PUT (#3061)

(Updating assets isn’t currently working - investigating that)
This commit is contained in:
snipe 2016-12-15 04:27:17 -08:00
parent 7f65c6e472
commit 9b167d87d2
15 changed files with 43 additions and 31 deletions

View file

@ -58,7 +58,7 @@ class RouteServiceProvider extends ServiceProvider
require base_path('routes/web/hardware.php'); require base_path('routes/web/hardware.php');
require base_path('routes/web/accessories.php'); require base_path('routes/web/accessories.php');
require base_path('routes/web/licenses.php'); require base_path('routes/web/licenses.php');
require base_path('routes/web/consumable.php'); require base_path('routes/web/consumables.php');
require base_path('routes/web.php'); require base_path('routes/web.php');
}); });
} }

View file

@ -2,9 +2,12 @@
'createText' => trans('admin/accessories/general.create') , 'createText' => trans('admin/accessories/general.create') ,
'updateText' => trans('admin/accessories/general.update'), 'updateText' => trans('admin/accessories/general.update'),
'helpTitle' => trans('admin/accessories/general.about_accessories_title'), 'helpTitle' => trans('admin/accessories/general.about_accessories_title'),
'helpText' => trans('admin/accessories/general.about_accessories_text') 'helpText' => trans('admin/accessories/general.about_accessories_text'),
'formAction' => ($item) ? route('accessories.update', ['accessory' => $item->id]) : route('accessories.store'),
]) ])
{{ ($item) ? "route('accessories.update', ['accessory_id' => $item->id])" : "route('accessories.store')" }}
{{-- Page content --}} {{-- Page content --}}
@section('inputFields') @section('inputFields')

View file

@ -8,7 +8,7 @@
@section('header_right') @section('header_right')
@can('accessories.create') @can('accessories.create')
<a href="{{ route('create/accessory') }}" class="btn btn-primary pull-right"> {{ trans('general.create') }}</a> <a href="{{ route('accessories.create') }}" class="btn btn-primary pull-right"> {{ trans('general.create') }}</a>
@endcan @endcan
@stop @stop

View file

@ -30,7 +30,7 @@
@endcan @endcan
@endif @endif
@can('accessories.edit') @can('accessories.edit')
<li role="presentation"><a href="{{ route('update/accessory', $accessory->id) }}">{{ trans('admin/accessories/general.edit') }}</a></li> <li role="presentation"><a href="{{ route('accessories.edit', $accessory->id) }}">{{ trans('admin/accessories/general.edit') }}</a></li>
@endcan @endcan
</ul> </ul>

View file

@ -2,7 +2,8 @@
'createText' => trans('admin/consumables/general.create') , 'createText' => trans('admin/consumables/general.create') ,
'updateText' => trans('admin/consumables/general.update'), 'updateText' => trans('admin/consumables/general.update'),
'helpTitle' => trans('admin/consumables/general.about_consumables_title'), 'helpTitle' => trans('admin/consumables/general.about_consumables_title'),
'helpText' => trans('admin/consumables/general.about_consumables_text') 'helpText' => trans('admin/consumables/general.about_consumables_text'),
'formAction' => ($item) ? route('consumables.update', ['accessory' => $item->id]) : route('consumables.store'),
]) ])
{{-- Page content --}} {{-- Page content --}}
@section('inputFields') @section('inputFields')

View file

@ -8,7 +8,7 @@
@section('header_right') @section('header_right')
@can('consumables.create') @can('consumables.create')
<a href="{{ route('create/consumable') }}" class="btn btn-primary pull-right"> {{ trans('general.create') }}</a> <a href="{{ route('consumables.create') }}" class="btn btn-primary pull-right"> {{ trans('general.create') }}</a>
@endcan @endcan
@stop @stop

View file

@ -25,7 +25,7 @@
<i class="fa fa-barcode"></i> <i class="fa fa-barcode"></i>
</div> </div>
@can('assets.view') @can('assets.view')
<a href="{{ route('hardware') }}" class="small-box-footer">{{ trans('general.moreinfo') }} <i class="fa fa-arrow-circle-right"></i></a> <a href="{{ route('hardware.index') }}" class="small-box-footer">{{ trans('general.moreinfo') }} <i class="fa fa-arrow-circle-right"></i></a>
@endcan @endcan
</div> </div>
</div><!-- ./col --> </div><!-- ./col -->
@ -41,7 +41,7 @@
<i class="fa fa-floppy-o"></i> <i class="fa fa-floppy-o"></i>
</div> </div>
@can('licenses.view') @can('licenses.view')
<a href="{{ route('licenses') }}" class="small-box-footer">{{ trans('general.moreinfo') }} <i class="fa fa-arrow-circle-right"></i></a> <a href="{{ route('licenses.index') }}" class="small-box-footer">{{ trans('general.moreinfo') }} <i class="fa fa-arrow-circle-right"></i></a>
@endcan @endcan
</div> </div>
</div><!-- ./col --> </div><!-- ./col -->
@ -57,7 +57,7 @@
<i class="fa fa-keyboard-o"></i> <i class="fa fa-keyboard-o"></i>
</div> </div>
@can('accessories.view') @can('accessories.view')
<a href="{{ route('accessories') }}" class="small-box-footer">{{ trans('general.moreinfo') }} <i class="fa fa-arrow-circle-right"></i></a> <a href="{{ route('accessories.index') }}" class="small-box-footer">{{ trans('general.moreinfo') }} <i class="fa fa-arrow-circle-right"></i></a>
@endcan @endcan
</div> </div>
</div><!-- ./col --> </div><!-- ./col -->
@ -73,7 +73,7 @@
<i class="fa fa-tint"></i> <i class="fa fa-tint"></i>
</div> </div>
@can('consumables.view') @can('consumables.view')
<a href="{{ route('consumables') }}" class="small-box-footer">{{ trans('general.moreinfo') }} <i class="fa fa-arrow-circle-right"></i></a> <a href="{{ route('consumables.index') }}" class="small-box-footer">{{ trans('general.moreinfo') }} <i class="fa fa-arrow-circle-right"></i></a>
@endcan @endcan
</div> </div>
</div><!-- ./col --> </div><!-- ./col -->

View file

@ -3,7 +3,8 @@
'createText' => trans('admin/hardware/form.create'), 'createText' => trans('admin/hardware/form.create'),
'updateText' => trans('admin/hardware/form.update'), 'updateText' => trans('admin/hardware/form.update'),
'helpTitle' => trans('admin/hardware/general.about_assets_title'), 'helpTitle' => trans('admin/hardware/general.about_assets_title'),
'helpText' => trans('admin/hardware/general.about_assets_text') 'helpText' => trans('admin/hardware/general.about_assets_text'),
'formAction' => ($item) ? route('hardware.update', ['hardware' => $item->id]) : route('hardware.store'),
]) ])
@ -244,7 +245,7 @@ $(function () {
//First check to see if there is a file before doing anything else //First check to see if there is a file before doing anything else
var imageData = ""; var imageData = "";
var $fileInput = $('#file-upload'); var $fileInput = $('#file-upload');
$fileInput.on('change', function(e) { $fileInput.on('change', function(e) {
if( $fileInput != '' ) { if( $fileInput != '' ) {
if(window.File && window.FileReader && window.FormData) { if(window.File && window.FileReader && window.FormData) {
@ -259,7 +260,7 @@ $(function () {
} }
else { else {
console.log("File API not supported, not resizing"); console.log("File API not supported, not resizing");
} }
} }
}); });
@ -271,7 +272,7 @@ $(function () {
processFile(reader.result, file.type); processFile(reader.result, file.type);
} }
reader.onerror = function() { reader.onerror = function() {
alert("Unable to read file"); alert("Unable to read file");
} }

View file

@ -31,7 +31,7 @@
@stop @stop
@section('header_right') @section('header_right')
<a href="{{ route('create/hardware') }}" class="btn btn-primary pull-right"></i> {{ trans('general.create') }}</a> <a href="{{ route('hardware.create') }}" class="btn btn-primary pull-right"></i> {{ trans('general.create') }}</a>
@stop @stop
{{-- Page content --}} {{-- Page content --}}

View file

@ -33,7 +33,7 @@
@elseif ($asset->status_id == 0) @elseif ($asset->status_id == 0)
<li role="presentation"><a href="{{ route('checkout/hardware', $asset->id) }}">{{ trans('admin/hardware/general.checkout') }}</a></li> <li role="presentation"><a href="{{ route('checkout/hardware', $asset->id) }}">{{ trans('admin/hardware/general.checkout') }}</a></li>
@endif @endif
<li role="presentation"><a href="{{ route('update/hardware', $asset->id) }}">{{ trans('admin/hardware/general.edit') }}</a></li> <li role="presentation"><a href="{{ route('hardware.edit', $asset->id) }}">{{ trans('admin/hardware/general.edit') }}</a></li>
<li role="presentation"><a href="{{ route('clone/hardware', $asset->id) }}">{{ trans('admin/hardware/general.clone') }}</a></li> <li role="presentation"><a href="{{ route('clone/hardware', $asset->id) }}">{{ trans('admin/hardware/general.clone') }}</a></li>
</ul> </ul>
</div> </div>

View file

@ -24,7 +24,7 @@
<li role="presentation"><a href="{{ route('checkout/hardware', $asset->id) }}">{{ trans('admin/hardware/general.checkout') }}</a></li> <li role="presentation"><a href="{{ route('checkout/hardware', $asset->id) }}">{{ trans('admin/hardware/general.checkout') }}</a></li>
@endif @endif
@endif @endif
<li role="presentation"><a href="{{ route('update/hardware', $asset->id) }}">{{ trans('admin/hardware/general.edit') }}</a></li> <li role="presentation"><a href="{{ route('hardware.edit', $asset->id) }}">{{ trans('admin/hardware/general.edit') }}</a></li>
<li role="presentation"><a href="{{ route('clone/hardware', $asset->id) }}">{{ trans('admin/hardware/general.clone') }}</a></li> <li role="presentation"><a href="{{ route('clone/hardware', $asset->id) }}">{{ trans('admin/hardware/general.clone') }}</a></li>
</ul> </ul>
</div> </div>

View file

@ -137,20 +137,20 @@
@endcan @endcan
@can('licenses.view') @can('licenses.view')
<li {!! (Request::is('admin/licenses*') ? ' class="active"' : '') !!}> <li {!! (Request::is('admin/licenses*') ? ' class="active"' : '') !!}>
<a href="{{ URL::to('admin/licenses') }}"> <a href="{{ route('licenses.create') }}">
<i class="fa fa-floppy-o"></i> <i class="fa fa-floppy-o"></i>
</a> </a>
</li> </li>
@endcan @endcan
@can('accessories.view') @can('accessories.view')
<li {!! (Request::is('admin/accessories*') ? ' class="active"' : '') !!}> <li {!! (Request::is('admin/accessories*') ? ' class="active"' : '') !!}>
<a href="{{ URL::to('admin/accessories') }}"> <a href="{{ route('accessories.index') }}">
<i class="fa fa-keyboard-o"></i> <i class="fa fa-keyboard-o"></i>
</a> </a>
</li> </li>
@endcan @endcan
@can('consumables.view') @can('consumables.view')
<li {!! (Request::is('admin/consumables*') ? ' class="active"' : '') !!}> <li {!! (Request::is('consunmables*') ? ' class="active"' : '') !!}>
<a href="{{ URL::to('admin/consumables') }}"> <a href="{{ URL::to('admin/consumables') }}">
<i class="fa fa-tint"></i> <i class="fa fa-tint"></i>
</a> </a>
@ -188,7 +188,7 @@
<ul class="dropdown-menu"> <ul class="dropdown-menu">
@can('assets.create') @can('assets.create')
<li {!! (Request::is('hardware/create') ? 'class="active>"' : '') !!}> <li {!! (Request::is('hardware/create') ? 'class="active>"' : '') !!}>
<a href="{{ route('create/hardware') }}"> <a href="{{ route('hardware.create') }}">
<i class="fa fa-barcode fa-fw"></i> <i class="fa fa-barcode fa-fw"></i>
@lang('general.asset')</a> @lang('general.asset')</a>
</li> </li>
@ -201,15 +201,15 @@
</li> </li>
@endcan @endcan
@can('accessories.create') @can('accessories.create')
<li {!! (Request::is('admin/accessories/create') ? 'class="active"' : '') !!}> <li {!! (Request::is('accessories/create') ? 'class="active"' : '') !!}>
<a href="{{ route('create/accessory') }}"> <a href="{{ route('accessories.create') }}">
<i class="fa fa-keyboard-o fa-fw"></i> <i class="fa fa-keyboard-o fa-fw"></i>
@lang('general.accessory')</a> @lang('general.accessory')</a>
</li> </li>
@endcan @endcan
@can('consumables.create') @can('consumables.create')
<li {!! (Request::is('admin/consumables/create') ? 'class="active"' : '') !!}> <li {!! (Request::is('consunmables/create') ? 'class="active"' : '') !!}>
<a href="{{ route('create/consumable') }}"> <a href="{{ route('consumables.create') }}">
<i class="fa fa-tint fa-fw"></i> <i class="fa fa-tint fa-fw"></i>
@lang('general.consumable')</a> @lang('general.consumable')</a>
</li> </li>
@ -459,7 +459,7 @@
@endcan @endcan
@can('licenses.view') @can('licenses.view')
<li{!! (Request::is('admin/licenses*') ? ' class="active"' : '') !!}> <li{!! (Request::is('admin/licenses*') ? ' class="active"' : '') !!}>
<a href="{{ URL::to('admin/licenses') }}"> <a href="{{ route('licenses.create') }}">
<i class="fa fa-floppy-o"></i> <i class="fa fa-floppy-o"></i>
<span>@lang('general.licenses')</span> <span>@lang('general.licenses')</span>
</a> </a>
@ -467,14 +467,14 @@
@endcan @endcan
@can('accessories.view') @can('accessories.view')
<li{!! (Request::is('admin/accessories*') ? ' class="active"' : '') !!}> <li{!! (Request::is('admin/accessories*') ? ' class="active"' : '') !!}>
<a href="{{ URL::to('admin/accessories') }}"> <a href="{{ route('accessories.index') }}">
<i class="fa fa-keyboard-o"></i> <i class="fa fa-keyboard-o"></i>
<span>@lang('general.accessories')</span> <span>@lang('general.accessories')</span>
</a> </a>
</li> </li>
@endcan @endcan
@can('consumables.view') @can('consumables.view')
<li{!! (Request::is('admin/consumables*') ? ' class="active"' : '') !!}> <li{!! (Request::is('consunmables*') ? ' class="active"' : '') !!}>
<a href="{{ URL::to('admin/consumables') }}"> <a href="{{ URL::to('admin/consumables') }}">
<i class="fa fa-tint"></i> <i class="fa fa-tint"></i>
<span>@lang('general.consumables')</span> <span>@lang('general.consumables')</span>

View file

@ -36,7 +36,13 @@
</div><!-- /.box-header --> </div><!-- /.box-header -->
<div class="box-body"> <div class="box-body">
<form id="create-form" class="form-horizontal" method="post" action="{{ \Request::url() }}" autocomplete="off" role="form" enctype="multipart/form-data"> <form id="create-form" class="form-horizontal" method="post" action="{{ (isset($formAction)) ? $formAction : \Request::url() }}" autocomplete="off" role="form" enctype="multipart/form-data">
@if ($item->id)
{{ method_field('PUT') }}
@endif
<!-- CSRF Token --> <!-- CSRF Token -->
{{ csrf_field() }} {{ csrf_field() }}
@yield('inputFields') @yield('inputFields')

View file

@ -2,7 +2,8 @@
'createText' => trans('admin/models/table.create') , 'createText' => trans('admin/models/table.create') ,
'updateText' => trans('admin/models/table.update'), 'updateText' => trans('admin/models/table.update'),
'helpTitle' => trans('admin/models/general.about_models_title'), 'helpTitle' => trans('admin/models/general.about_models_title'),
'helpText' => trans('admin/models/general.about_models_text') 'helpText' => trans('admin/models/general.about_models_text'),
'formAction' => ($item) ? route('models.update', ['model' => $item->id]) : route('models.store'),
]) ])
{{-- Page content --}} {{-- Page content --}}

View file

@ -17,7 +17,7 @@
@if ($model->deleted_at=='') @if ($model->deleted_at=='')
<li><a href="{{ route('update/model', $model->id) }}">{{ trans('admin/models/table.edit') }}</a></li> <li><a href="{{ route('update/model', $model->id) }}">{{ trans('admin/models/table.edit') }}</a></li>
<li><a href="{{ route('clone/model', $model->id) }}">{{ trans('admin/models/table.clone') }}</a></li> <li><a href="{{ route('clone/model', $model->id) }}">{{ trans('admin/models/table.clone') }}</a></li>
<li><a href="{{ route('create/hardware', $model->id) }}">{{ trans('admin/hardware/form.create') }}</a></li> <li><a href="{{ route('hardware.create', $model->id) }}">{{ trans('admin/hardware/form.create') }}</a></li>
@else @else
<li><a href="{{ route('restore/model', $model->id) }}">{{ trans('admin/models/general.restore') }}</a></li> <li><a href="{{ route('restore/model', $model->id) }}">{{ trans('admin/models/general.restore') }}</a></li>
@endif @endif