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/accessories.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');
});
}

View file

@ -2,9 +2,12 @@
'createText' => trans('admin/accessories/general.create') ,
'updateText' => trans('admin/accessories/general.update'),
'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 --}}
@section('inputFields')

View file

@ -8,7 +8,7 @@
@section('header_right')
@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
@stop

View file

@ -30,7 +30,7 @@
@endcan
@endif
@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
</ul>

View file

@ -2,7 +2,8 @@
'createText' => trans('admin/consumables/general.create') ,
'updateText' => trans('admin/consumables/general.update'),
'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 --}}
@section('inputFields')

View file

@ -8,7 +8,7 @@
@section('header_right')
@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
@stop

View file

@ -25,7 +25,7 @@
<i class="fa fa-barcode"></i>
</div>
@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
</div>
</div><!-- ./col -->
@ -41,7 +41,7 @@
<i class="fa fa-floppy-o"></i>
</div>
@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
</div>
</div><!-- ./col -->
@ -57,7 +57,7 @@
<i class="fa fa-keyboard-o"></i>
</div>
@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
</div>
</div><!-- ./col -->
@ -73,7 +73,7 @@
<i class="fa fa-tint"></i>
</div>
@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
</div>
</div><!-- ./col -->

View file

@ -3,7 +3,8 @@
'createText' => trans('admin/hardware/form.create'),
'updateText' => trans('admin/hardware/form.update'),
'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
var imageData = "";
var $fileInput = $('#file-upload');
var $fileInput = $('#file-upload');
$fileInput.on('change', function(e) {
if( $fileInput != '' ) {
if(window.File && window.FileReader && window.FormData) {
@ -259,7 +260,7 @@ $(function () {
}
else {
console.log("File API not supported, not resizing");
}
}
}
});
@ -271,7 +272,7 @@ $(function () {
processFile(reader.result, file.type);
}
reader.onerror = function() {
reader.onerror = function() {
alert("Unable to read file");
}

View file

@ -31,7 +31,7 @@
@stop
@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
{{-- Page content --}}

View file

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

View file

@ -24,7 +24,7 @@
<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>
</ul>
</div>

View file

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

View file

@ -36,7 +36,13 @@
</div><!-- /.box-header -->
<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_field() }}
@yield('inputFields')

View file

@ -2,7 +2,8 @@
'createText' => trans('admin/models/table.create') ,
'updateText' => trans('admin/models/table.update'),
'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 --}}

View file

@ -17,7 +17,7 @@
@if ($model->deleted_at=='')
<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('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
<li><a href="{{ route('restore/model', $model->id) }}">{{ trans('admin/models/general.restore') }}</a></li>
@endif