Added “new” buttons for manufacturer and category in asset model creation

This commit is contained in:
snipe 2017-12-19 20:30:46 -08:00
parent fbe093705d
commit b716db225f
6 changed files with 91 additions and 1 deletions

View file

@ -29,4 +29,13 @@ class ModalController extends Controller
function user() { function user() {
return view('modals.user'); return view('modals.user');
} }
function category() {
return view('modals.category');
}
function manufacturer() {
return view('modals.manufacturer');
}
} }

View file

@ -0,0 +1,39 @@
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">{{ trans('admin/categories/general.create') }}</h4>
</div>
<div class="modal-body">
<div class="alert alert-danger" id="modal_error_msg" style="display:none">
</div>
<div class="dynamic-form-row">
<div class="col-md-4 col-xs-12"><label for="modal-name">{{ trans('general.name') }}:
</label></div>
<div class="col-md-8 col-xs-12 required">
<input type='text' id='modal-name' class="form-control">
</div>
</div>
<div class="dynamic-form-row">
<div class="col-md-4 col-xs-12"><label for="modal-name">{{ trans('general.name') }}:
</label></div>
<div class="col-md-8 col-xs-12 required">
<select class="select2" id="modal-category_type" style="width: 100%">
<option value="asset">Asset</option>
<option value="accessory" disabled>Accessory</option>
<option value="consumable" disabled>Consumable</option>
<option value="component" disabled>Component</option>
</select>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('button.cancel') }}</button>
<button type="button" class="btn btn-primary" id="modal-save">{{ trans('general.save') }}</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->

View file

@ -0,0 +1,25 @@
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">{{ trans('admin/manufacturers/table.create') }}</h4>
</div>
<div class="modal-body">
<div class="alert alert-danger" id="modal_error_msg" style="display:none">
</div>
<div class="dynamic-form-row">
<div class="col-md-4 col-xs-12"><label for="modal-name">{{ trans('general.name') }}:
</label></div>
<div class="col-md-8 col-xs-12 required">
<input type='text' id='modal-name' class="form-control">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('button.cancel') }}</button>
<button type="button" class="btn btn-primary" id="modal-save">{{ trans('general.save') }}</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->

View file

@ -15,6 +15,13 @@
</select> </select>
</div> </div>
<div class="col-md-1 col-sm-1 text-left">
@can('create', \App\Models\Category::class)
@if ((!isset($hide_new)) || ($hide_new!='true'))
<a href='{{ route('modal.category') }}' data-toggle="modal" data-target="#createModal" data-dependency="categorie" data-select='category_select_id' class="btn btn-sm btn-default">New</a>
@endif
@endcan
</div>
{!! $errors->first($fieldname, '<div class="col-md-8 col-md-offset-3"><span class="alert-msg"><i class="fa fa-times"></i> :message</span></div>') !!} {!! $errors->first($fieldname, '<div class="col-md-8 col-md-offset-3"><span class="alert-msg"><i class="fa fa-times"></i> :message</span></div>') !!}

View file

@ -4,7 +4,7 @@
{{ Form::label($fieldname, $translated_name, array('class' => 'col-md-3 control-label')) }} {{ Form::label($fieldname, $translated_name, array('class' => 'col-md-3 control-label')) }}
<div class="col-md-7{{ ((isset($required)) && ($required=='true')) ? ' required' : '' }}"> <div class="col-md-7{{ ((isset($required)) && ($required=='true')) ? ' required' : '' }}">
<select class="js-data-ajax" data-endpoint="manufacturers" name="{{ $fieldname }}" style="width: 100%" id="category_select_id"> <select class="js-data-ajax" data-endpoint="manufacturers" name="{{ $fieldname }}" style="width: 100%" id="manufacturer_select_id">
@if ($manufacturer_id = Input::old($fieldname, (isset($item)) ? $item->{$fieldname} : '')) @if ($manufacturer_id = Input::old($fieldname, (isset($item)) ? $item->{$fieldname} : ''))
<option value="{{ $manufacturer_id }}" selected="selected"> <option value="{{ $manufacturer_id }}" selected="selected">
{{ (\App\Models\Manufacturer::find($manufacturer_id)) ? \App\Models\Manufacturer::find($manufacturer_id)->name : '' }} {{ (\App\Models\Manufacturer::find($manufacturer_id)) ? \App\Models\Manufacturer::find($manufacturer_id)->name : '' }}
@ -16,6 +16,14 @@
</select> </select>
</div> </div>
<div class="col-md-1 col-sm-1 text-left">
@can('create', \App\Models\Manufacturer::class)
@if ((!isset($hide_new)) || ($hide_new!='true'))
<a href='{{ route('modal.manufacturer') }}' data-toggle="modal" data-target="#createModal" data-dependency="manufacturer" data-select='manufacturer_select_id' class="btn btn-sm btn-default">New</a>
@endif
@endcan
</div>
{!! $errors->first($fieldname, '<div class="col-md-8 col-md-offset-3"><span class="alert-msg"><i class="fa fa-times"></i> :message</span></div>') !!} {!! $errors->first($fieldname, '<div class="col-md-8 col-md-offset-3"><span class="alert-msg"><i class="fa fa-times"></i> :message</span></div>') !!}
</div> </div>

View file

@ -82,6 +82,8 @@ Route::group(['middleware' => 'auth'], function () {
Route::group(['middleware' => 'auth','prefix' => 'modals'], function () { Route::group(['middleware' => 'auth','prefix' => 'modals'], function () {
Route::get('location',['as' => 'modal.location','uses' => 'ModalController@location']); Route::get('location',['as' => 'modal.location','uses' => 'ModalController@location']);
Route::get('category',['as' => 'modal.category','uses' => 'ModalController@category']);
Route::get('manufacturer',['as' => 'modal.manufacturer','uses' => 'ModalController@manufacturer']);
Route::get('model',['as' => 'modal.model','uses' => 'ModalController@model']); Route::get('model',['as' => 'modal.model','uses' => 'ModalController@model']);
Route::get('statuslabel',['as' => 'modal.statuslabel','uses' => 'ModalController@statuslabel']); Route::get('statuslabel',['as' => 'modal.statuslabel','uses' => 'ModalController@statuslabel']);
Route::get('supplier',['as' => 'modal.supplier','uses' => 'ModalController@supplier']); Route::get('supplier',['as' => 'modal.supplier','uses' => 'ModalController@supplier']);