mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Added new ajax dropdown menus for components, consumables, etc editing/creating
This commit is contained in:
parent
fe70792cbd
commit
6a3716a06d
|
@ -56,12 +56,7 @@ class AccessoriesController extends Controller
|
|||
$this->authorize('create', Accessory::class);
|
||||
// Show the page
|
||||
return view('accessories/edit')
|
||||
->with('item', new Accessory)
|
||||
->with('category_list', Helper::categoryList('accessory'))
|
||||
->with('company_list', Helper::companyList())
|
||||
->with('supplier_list', Helper::suppliersList())
|
||||
->with('location_list', Helper::locationsList())
|
||||
->with('manufacturer_list', Helper::manufacturerList());
|
||||
->with('item', new Accessory);
|
||||
}
|
||||
|
||||
|
||||
|
@ -137,12 +132,7 @@ class AccessoriesController extends Controller
|
|||
|
||||
$this->authorize($item);
|
||||
|
||||
return view('accessories/edit', compact('item'))
|
||||
->with('category_list', Helper::categoryList('accessory'))
|
||||
->with('company_list', Helper::companyList())
|
||||
->with('location_list', Helper::locationsList())
|
||||
->with('supplier_list', Helper::suppliersList())
|
||||
->with('manufacturer_list', Helper::manufacturerList());
|
||||
return view('accessories/edit', compact('item'));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -159,7 +159,6 @@ class CategoriesController extends Controller
|
|||
// This lets us have more flexibility in special cases like assets, where
|
||||
// they may not have a ->name value but we want to display something anyway
|
||||
foreach ($categories as $category) {
|
||||
$category->use_text = $category->name;
|
||||
$category->use_image = ($category->image) ? url('/').'/uploads/categories/'.$category->image : null;
|
||||
}
|
||||
|
||||
|
|
|
@ -171,7 +171,6 @@ class CompaniesController extends Controller
|
|||
// This lets us have more flexibility in special cases like assets, where
|
||||
// they may not have a ->name value but we want to display something anyway
|
||||
foreach ($companies as $company) {
|
||||
$company->use_text = $company->name;
|
||||
$company->use_image = ($company->image) ? url('/').'/uploads/companies/'.$company->image : null;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ use App\Models\Department;
|
|||
use App\Http\Transformers\DepartmentsTransformer;
|
||||
use App\Helpers\Helper;
|
||||
use Auth;
|
||||
use App\Http\Transformers\SelectlistTransformer;
|
||||
|
||||
class DepartmentsController extends Controller
|
||||
{
|
||||
|
@ -111,4 +112,39 @@ class DepartmentsController extends Controller
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a paginated collection for the select2 menus
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v4.0.16]
|
||||
* @see \App\Http\Transformers\SelectlistTransformer
|
||||
*
|
||||
*/
|
||||
public function selectlist(Request $request)
|
||||
{
|
||||
$this->authorize('view', Department::class);
|
||||
|
||||
$departments = Department::select([
|
||||
'id',
|
||||
'name',
|
||||
'image',
|
||||
]);
|
||||
|
||||
if ($request->has('search')) {
|
||||
$departments = $departments->where('name', 'LIKE', '%'.$request->get('search').'%');
|
||||
}
|
||||
|
||||
$departments = $departments->orderBy('name', 'ASC')->paginate(50);
|
||||
|
||||
// Loop through and set some custom properties for the transformer to use.
|
||||
// This lets us have more flexibility in special cases like assets, where
|
||||
// they may not have a ->name value but we want to display something anyway
|
||||
foreach ($departments as $department) {
|
||||
$department->use_image = ($department->image) ? url('/').'/uploads/departments/'.$department->image : null;
|
||||
}
|
||||
|
||||
return (new SelectlistTransformer)->transformSelectlist($departments);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -61,10 +61,7 @@ class ComponentsController extends Controller
|
|||
$this->authorize('create', Component::class);
|
||||
// Show the page
|
||||
return view('components/edit')
|
||||
->with('item', new Component)
|
||||
->with('category_list', Helper::categoryList('component'))
|
||||
->with('company_list', Helper::companyList())
|
||||
->with('location_list', Helper::locationsList());
|
||||
->with('item', new Component);
|
||||
}
|
||||
|
||||
|
||||
|
@ -128,9 +125,7 @@ class ComponentsController extends Controller
|
|||
$this->authorize('update', $item);
|
||||
|
||||
return view('components/edit', compact('item'))
|
||||
->with('category_list', Helper::categoryList('component'))
|
||||
->with('company_list', Helper::companyList())
|
||||
->with('location_list', Helper::locationsList());
|
||||
->with('category_list', Helper::categoryList('component'));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -58,11 +58,7 @@ class ConsumablesController extends Controller
|
|||
$this->authorize('create', Consumable::class);
|
||||
// Show the page
|
||||
return view('consumables/edit')
|
||||
->with('item', new Consumable)
|
||||
->with('category_list', Helper::categoryList('consumable'))
|
||||
->with('company_list', Helper::companyList())
|
||||
->with('location_list', Helper::locationsList())
|
||||
->with('manufacturer_list', Helper::manufacturerList());
|
||||
->with('item', new Consumable);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -67,10 +67,7 @@ class LicensesController extends Controller
|
|||
return view('licenses/edit')
|
||||
//->with('license_options',$license_options)
|
||||
->with('depreciation_list', Helper::depreciationList())
|
||||
->with('supplier_list', Helper::suppliersList())
|
||||
->with('maintained_list', $maintained_list)
|
||||
->with('company_list', Helper::companyList())
|
||||
->with('manufacturer_list', Helper::manufacturerList())
|
||||
->with('item', new License);
|
||||
|
||||
}
|
||||
|
@ -144,10 +141,7 @@ class LicensesController extends Controller
|
|||
|
||||
return view('licenses/edit', compact('item'))
|
||||
->with('depreciation_list', Helper::depreciationList())
|
||||
->with('supplier_list', Helper::suppliersList())
|
||||
->with('company_list', Helper::companyList())
|
||||
->with('maintained_list', $maintained_list)
|
||||
->with('manufacturer_list', Helper::manufacturerList());
|
||||
->with('maintained_list', $maintained_list);
|
||||
}
|
||||
|
||||
|
||||
|
@ -254,9 +248,7 @@ class LicensesController extends Controller
|
|||
}
|
||||
|
||||
$this->authorize('checkout', $licenseSeat);
|
||||
return view('licenses/checkout', compact('licenseSeat'))
|
||||
->with('users_list', Helper::usersList())
|
||||
->with('asset_list', Helper::detailedAssetList());
|
||||
return view('licenses/checkout', compact('licenseSeat'));
|
||||
}
|
||||
|
||||
|
||||
|
@ -472,11 +464,8 @@ class LicensesController extends Controller
|
|||
// Show the page
|
||||
return view('licenses/edit')
|
||||
->with('depreciation_list', Helper::depreciationList())
|
||||
->with('supplier_list', Helper::suppliersList())
|
||||
->with('item', $license)
|
||||
->with('maintained_list', $maintained_list)
|
||||
->with('company_list', Helper::companyList())
|
||||
->with('manufacturer_list', Helper::manufacturerList());
|
||||
->with('maintained_list', $maintained_list);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -85,10 +85,6 @@ class UsersController extends Controller
|
|||
$permissions = $this->filterDisplayable($permissions);
|
||||
|
||||
return view('users/edit', compact('groups', 'userGroups', 'permissions', 'userPermissions'))
|
||||
->with('location_list', Helper::locationsList())
|
||||
->with('manager_list', Helper::managerList())
|
||||
->with('company_list', Helper::companyList())
|
||||
->with('department_list', Helper::departmentList())
|
||||
->with('user', new User);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ class SelectlistTransformer
|
|||
foreach ($select_items as $select_item) {
|
||||
$items_array[]= [
|
||||
'id' => (int) $select_item->id,
|
||||
'text' => e($select_item->use_text),
|
||||
'text' => ($select_item->use_text) ? e($select_item->use_text) : e($select_item->name),
|
||||
'image' => ($select_item->use_image) ? e($select_item->use_image) : null,
|
||||
|
||||
];
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
{{-- Page content --}}
|
||||
@section('inputFields')
|
||||
|
||||
@include ('partials.forms.edit.company')
|
||||
@include ('partials.forms.edit.company-select', ['translated_name' => trans('general.company'), 'fieldname' => 'company_id'])
|
||||
@include ('partials.forms.edit.name', ['translated_name' => trans('admin/accessories/general.accessory_name')])
|
||||
@include ('partials.forms.edit.category')
|
||||
@include ('partials.forms.edit.supplier')
|
||||
@include ('partials.forms.edit.manufacturer')
|
||||
@include ('partials.forms.edit.location')
|
||||
@include ('partials.forms.edit.category-select', ['translated_name' => trans('general.category'), 'fieldname' => 'category_id'])
|
||||
@include ('partials.forms.edit.supplier-select', ['translated_name' => trans('general.supplier'), 'fieldname' => 'supplier_id'])
|
||||
@include ('partials.forms.edit.manufacturer-select', ['translated_name' => trans('general.manufacturer'), 'fieldname' => 'manufacturer_id'])
|
||||
@include ('partials.forms.edit.location-select', ['translated_name' => trans('general.location'), 'fieldname' => 'location_id'])
|
||||
@include ('partials.forms.edit.model_number')
|
||||
@include ('partials.forms.edit.order_number')
|
||||
@include ('partials.forms.edit.purchase_date')
|
||||
|
|
|
@ -11,12 +11,12 @@
|
|||
@section('inputFields')
|
||||
|
||||
@include ('partials.forms.edit.name', ['translated_name' => trans('admin/components/table.title')])
|
||||
@include ('partials.forms.edit.category')
|
||||
@include ('partials.forms.edit.category-select', ['translated_name' => trans('general.category'), 'fieldname' => 'category_id'])
|
||||
@include ('partials.forms.edit.quantity')
|
||||
@include ('partials.forms.edit.minimum_quantity')
|
||||
@include ('partials.forms.edit.serial')
|
||||
@include ('partials.forms.edit.company')
|
||||
@include ('partials.forms.edit.location')
|
||||
@include ('partials.forms.edit.company-select', ['translated_name' => trans('general.company'), 'fieldname' => 'company_id'])
|
||||
@include ('partials.forms.edit.location-select', ['translated_name' => trans('general.location'), 'fieldname' => 'location_id'])
|
||||
@include ('partials.forms.edit.order_number')
|
||||
@include ('partials.forms.edit.purchase_date')
|
||||
@include ('partials.forms.edit.purchase_cost')
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
{{-- Page content --}}
|
||||
@section('inputFields')
|
||||
|
||||
@include ('partials.forms.edit.company')
|
||||
@include ('partials.forms.edit.company-select', ['translated_name' => trans('general.company'), 'fieldname' => 'company_id'])
|
||||
@include ('partials.forms.edit.name', ['translated_name' => trans('admin/consumables/table.title')])
|
||||
@include ('partials.forms.edit.category')
|
||||
@include ('partials.forms.edit.manufacturer')
|
||||
@include ('partials.forms.edit.location')
|
||||
@include ('partials.forms.edit.category-select', ['translated_name' => trans('general.category'), 'fieldname' => 'category_id'])
|
||||
@include ('partials.forms.edit.manufacturer-select', ['translated_name' => trans('general.manufacturer'), 'fieldname' => 'manufacturer_id'])
|
||||
@include ('partials.forms.edit.location-select', ['translated_name' => trans('general.location'), 'fieldname' => 'location_id'])
|
||||
@include ('partials.forms.edit.model_number')
|
||||
@include ('partials.forms.edit.item_number')
|
||||
@include ('partials.forms.edit.order_number')
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
{!! $errors->first('seats', '<div class="col-md-8 col-md-offset-3"><span class="alert-msg"><i class="fa fa-times"></i> :message</span></div>') !!}
|
||||
</div>
|
||||
|
||||
@include ('partials.forms.edit.company')
|
||||
@include ('partials.forms.edit.manufacturer')
|
||||
@include ('partials.forms.edit.company-select', ['translated_name' => trans('general.company'), 'fieldname' => 'company_id'])
|
||||
@include ('partials.forms.edit.manufacturer-select', ['translated_name' => trans('general.manufacturer'), 'fieldname' => 'manufacturer_id'])
|
||||
|
||||
<!-- Licensed to name -->
|
||||
<div class="form-group {{ $errors->has('license_name') ? ' has-error' : '' }}">
|
||||
|
@ -61,7 +61,7 @@
|
|||
</div>
|
||||
|
||||
|
||||
@include ('partials.forms.edit.supplier')
|
||||
@include ('partials.forms.edit.supplier-select', ['translated_name' => trans('general.supplier'), 'fieldname' => 'supplier_id'])
|
||||
@include ('partials.forms.edit.order_number')
|
||||
@include ('partials.forms.edit.purchase_cost')
|
||||
@include ('partials.forms.edit.purchase_date')
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
{{ Form::label($fieldname, $translated_name, array('class' => 'col-md-3 control-label')) }}
|
||||
<div class="col-md-7 required">
|
||||
<select class="js-data-ajax" data-endpoint="hardware" name="{{ $fieldname }}" style="width: 100%" id="assigned_asset_select">
|
||||
@if ($asset_id = Input::old($fieldname, $item->{$fieldname}))
|
||||
@if ($asset_id = Input::old($fieldname, (isset($item)) ? $item->{$fieldname} : ''))
|
||||
<option value="{{ $asset_id }}" selected="selected">
|
||||
{{ \App\Models\Asset::find($asset_id)->present()->fullName }}
|
||||
</option>
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
{{ Form::label($fieldname, $translated_name, array('class' => 'col-md-3 control-label')) }}
|
||||
<div class="col-md-7">
|
||||
<select class="js-data-ajax" data-endpoint="companies" name="{{ $fieldname }}" style="width: 100%" id="company_select">
|
||||
@if ($company_id = Input::old($fieldname, $item->{$fieldname}))
|
||||
@if ($company_id = Input::old($fieldname, (isset($item)) ? $item->{$fieldname} : ''))
|
||||
<option value="{{ $company_id }}" selected="selected">
|
||||
{{ \App\Models\Company::find($company_id)->name }}
|
||||
</option>
|
||||
@else
|
||||
<option value="">{{ trans('general.select_model') }}</option>
|
||||
<option value="">{{ trans('general.select_company') }}</option>
|
||||
@endif
|
||||
</select>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<div id="assigned_user" class="form-group{{ $errors->has($fieldname) ? ' has-error' : '' }}">
|
||||
|
||||
{{ Form::label($fieldname, $translated_name, array('class' => 'col-md-3 control-label')) }}
|
||||
|
||||
<div class="col-md-7 required">
|
||||
<select class="js-data-ajax" data-endpoint="departments" name="{{ $fieldname }}" style="width: 100%" id="department_select">
|
||||
@if ($department_id = Input::old($fieldname, (isset($item)) ? $item->{$fieldname} : ''))
|
||||
<option value="{{ $department_id }}" selected="selected">
|
||||
{{ \App\Models\Department::find($department_id)->name }}
|
||||
</option>
|
||||
@else
|
||||
<option value="">{{ trans('general.select_department') }}</option>
|
||||
@endif
|
||||
</select>
|
||||
</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>
|
|
@ -4,7 +4,7 @@
|
|||
{{ Form::label($fieldname, $translated_name, array('class' => 'col-md-3 control-label')) }}
|
||||
<div class="col-md-7{{ ((isset($required) && ($required =='true'))) ? ' required' : '' }}">
|
||||
<select class="js-data-ajax" data-endpoint="locations" name="{{ $fieldname }}" style="width: 100%" id="{{ $fieldname }}_location_select">
|
||||
@if ($location_id = Input::old($fieldname, $item->{$fieldname}))
|
||||
@if ($location_id = Input::old($fieldname, (isset($item)) ? $item->{$fieldname} : ''))
|
||||
<option value="{{ $location_id }}" selected="selected">
|
||||
{{ \App\Models\Location::find($location_id)->name }}
|
||||
</option>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
<div class="col-md-7 required">
|
||||
<select class="js-data-ajax" data-endpoint="users" name="{{ $fieldname }}" style="width: 100%" id="assigned_user_select">
|
||||
@if ($user_id = Input::old($fieldname, $item->{$fieldname}))
|
||||
@if ($user_id = Input::old($fieldname, (isset($item)) ? $item->{$fieldname} : ''))
|
||||
<option value="{{ $user_id }}" selected="selected">
|
||||
{{ \App\Models\User::find($user_id)->name }}
|
||||
</option>
|
||||
|
|
|
@ -150,8 +150,7 @@
|
|||
autocomplete="off"
|
||||
readonly
|
||||
onfocus="this.removeAttribute('readonly');"
|
||||
{{ ((config('app.lock_passwords') && ($user->id)) ? ' disabled' : '') }}
|
||||
>
|
||||
{{ ((config('app.lock_passwords') && ($user->id)) ? ' disabled' : '') }}>
|
||||
@else
|
||||
(Managed via LDAP)
|
||||
@endif
|
||||
|
@ -202,8 +201,7 @@
|
|||
{{ ((config('app.lock_passwords') && ($user->id)) ? ' disabled' : '') }}
|
||||
autocomplete="off"
|
||||
readonly
|
||||
onfocus="this.removeAttribute('readonly');"
|
||||
>
|
||||
onfocus="this.removeAttribute('readonly');">
|
||||
@if (config('app.lock_passwords') && ($user->id))
|
||||
<p class="help-block">{{ trans('admin/users/table.lock_passwords') }}</p>
|
||||
@endif
|
||||
|
@ -213,16 +211,7 @@
|
|||
|
||||
<!-- Company -->
|
||||
@if (\App\Models\Company::canManageUsersCompanies())
|
||||
<!-- Company -->
|
||||
<div class="form-group {{ $errors->has('company_id') ? 'has-error' : '' }}">
|
||||
<div class="col-md-3 control-label">
|
||||
{{ Form::label('company_id', trans('general.company')) }}
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
{{ Form::select('company_id', $company_list , Input::old('company_id', $user->company_id), array('class'=>'select2', 'style'=>'width:350px')) }}
|
||||
{!! $errors->first('company_id', '<span class="alert-msg">:message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
@include ('partials.forms.edit.company-select', ['translated_name' => trans('general.select_company'), 'fieldname' => 'company_id'])
|
||||
@endif
|
||||
|
||||
<!-- language -->
|
||||
|
@ -267,35 +256,14 @@
|
|||
|
||||
|
||||
<!-- Manager -->
|
||||
<div class="form-group {{ $errors->has('manager_id') ? 'has-error' : '' }}">
|
||||
<label class="col-md-3 control-label" for="manager_id">{{ trans('admin/users/table.manager') }}</label>
|
||||
<div class="col-md-8">
|
||||
{{ Form::select('manager_id', $manager_list , Input::old('manager_id', $user->manager_id), array('class'=>'select2', 'style'=>'width:350px')) }}
|
||||
{!! $errors->first('manager_id', '<span class="alert-msg">:message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
@include ('partials.forms.edit.user-select', ['translated_name' => trans('general.select_user'), 'fieldname' => 'manager_id'])
|
||||
|
||||
<!-- Department -->
|
||||
<div class="form-group {{ $errors->has('department_id') ? ' has-error' : '' }}">
|
||||
<label for="status_id" class="col-md-3 control-label">
|
||||
{{ trans('general.department') }}
|
||||
</label>
|
||||
<div class="col-md-7">
|
||||
{{ Form::select('department_id', $department_list , Input::old('department_id', $user->department_id), array('class'=>'select2', 'style'=>'width:350px')) }}
|
||||
{!! $errors->first('department_id', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
@include ('partials.forms.edit.department-select', ['translated_name' => trans('general.select_department'), 'fieldname' => 'department_id'])
|
||||
|
||||
|
||||
<!-- Location -->
|
||||
<div class="form-group {{ $errors->has('location_id') ? 'has-error' : '' }}">
|
||||
<label class="col-md-3 control-label" for="location_id">{{ trans('admin/users/table.location') }}
|
||||
</label>
|
||||
<div class="col-md-8">
|
||||
{{ Form::select('location_id', $location_list , Input::old('location_id', $user->location_id), array('class'=>'select2', 'style'=>'width:350px')) }}
|
||||
{!! $errors->first('location_id', '<span class="alert-msg">:message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
@include ('partials.forms.edit.location-select', ['translated_name' => trans('general.select_location'), 'fieldname' => 'location_id'])
|
||||
|
||||
<!-- Phone -->
|
||||
<div class="form-group {{ $errors->has('phone') ? 'has-error' : '' }}">
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
array('deleted'=> (Input::get('status')=='deleted') ? 'true' : 'false','company_id'=>e(Input::get('company_id')))) }}"
|
||||
data-cookie="true"
|
||||
data-click-to-select="true"
|
||||
data-cookie-id-table="userTableDisplay-{{ config('version.hash_version') }}">
|
||||
data-cookie-id-table="userlTableDisplay-{{ config('version.hash_version') }}">
|
||||
|
||||
</table>
|
||||
|
||||
|
|
|
@ -98,6 +98,20 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () {
|
|||
|
||||
/*--- Departments API ---*/
|
||||
|
||||
/*--- Suppliers API ---*/
|
||||
Route::group(['prefix' => 'departments'], function () {
|
||||
|
||||
|
||||
Route::get('selectlist',
|
||||
[
|
||||
'as' => 'api.departments.selectlist',
|
||||
'uses' => 'DepartmentsController@selectlist'
|
||||
]
|
||||
);
|
||||
}); // Departments group
|
||||
|
||||
|
||||
|
||||
Route::resource('departments', 'DepartmentsController',
|
||||
[
|
||||
'names' =>
|
||||
|
@ -568,7 +582,7 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () {
|
|||
'uses' => 'SuppliersController@selectlist'
|
||||
]
|
||||
);
|
||||
}); // Categories group
|
||||
}); // Suppliers group
|
||||
|
||||
|
||||
Route::resource('suppliers', 'SuppliersController',
|
||||
|
|
Loading…
Reference in a new issue