Fixes #4445: prevents assigned assets from being checked out in bulk checkout (#5421)

* Fixes #4445: prevents assigned assets from being checked out in bulk checkout

* Updates data attribute to more versatile 'data-asset-status-type'

* Fixes broken unit test
This commit is contained in:
Hannah Tinkler 2018-04-25 10:39:23 +01:00 committed by snipe
parent a2fef11016
commit c4c520c1a3
15 changed files with 22 additions and 17 deletions

View file

@ -354,6 +354,9 @@ class AssetsController extends Controller
'assets.status_id'
])->with('model', 'assetstatus', 'assignedTo')->NotArchived());
if ($request->has('assetStatusType') && $request->input('assetStatusType') === 'RTD') {
$assets = $assets->RTD();
}
if ($request->has('search')) {
$assets = $assets->AssignedSearch($request->input('search'));

View file

@ -649,7 +649,7 @@ class Asset extends Depreciable
public function scopeRTD($query)
{
return $query->whereNULL('assigned_to')
return $query->whereNULL('assets.assigned_to')
->whereHas('assetstatus', function ($query) {
$query->where('deployable', '=', 1)
->where('pending', '=', 0)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
public/js/dist/all.js vendored

Binary file not shown.

View file

@ -1,14 +1,10 @@
{
"/js/build/vue.js": "/js/build/vue.js?id=88921ad9bb64a0915ebb",
"/css/AdminLTE.css": "/css/AdminLTE.css?id=5e72463a66acbcc740d5",
"/css/app.css": "/css/app.css?id=407edb63cc6b6dc62405",
"/css/overrides.css": "/css/overrides.css?id=c289c71c08df753ebc45",
"/js/build/vue.js.map": "/js/build/vue.js.map?id=0b7679d18eb22094e3b7",
"/css/AdminLTE.css.map": "/css/AdminLTE.css.map?id=99f5a5a03c4155cf69f6",
"/css/app.css.map": "/css/app.css.map?id=bdbe05e6ecd70ccfac72",
"/css/overrides.css.map": "/css/overrides.css.map?id=898c91d4a425b01b589b",
"/css/dist/all.css": "/css/dist/all.css?id=e3ae07b03a1d53657a1e",
"/js/dist/all.js": "/js/dist/all.js?id=3f7017ebedf1da0319ef",
"/css/build/all.css": "/css/build/all.css?id=e3ae07b03a1d53657a1e",
"/js/build/all.js": "/js/build/all.js?id=3f7017ebedf1da0319ef"
"/js/build/vue.js": "/js/build/vue.js?id=b0a1e5b88633fe31d519",
"/css/AdminLTE.css": "/css/AdminLTE.css?id=873655358c9cf6f3d557",
"/css/app.css": "/css/app.css?id=0efd6c8bfb966ea55978",
"/css/overrides.css": "/css/overrides.css?id=f1b32a8f3214d14bbd76",
"/css/dist/all.css": "/css/dist/all.css?id=2e031623c0f385ac1e4a",
"/js/dist/all.js": "/js/dist/all.js?id=cc7ceb552461b7599537",
"/css/build/all.css": "/css/build/all.css?id=2e031623c0f385ac1e4a",
"/js/build/all.js": "/js/build/all.js?id=cc7ceb552461b7599537"
}

View file

@ -206,7 +206,8 @@ $(document).ready(function () {
data: function (params) {
var data = {
search: params.term,
page: params.page || 1
page: params.page || 1,
assetStatusType: link.data("asset-status-type"),
};
return data;
},

View file

@ -68,7 +68,12 @@
</div>
</div>
@include ('partials.forms.edit.asset-select', ['translated_name' => trans('general.assets'), 'fieldname' => 'selected_assets[]', 'multiple' => true])
@include ('partials.forms.edit.asset-select', [
'translated_name' => trans('general.assets'),
'fieldname' => 'selected_assets[]',
'multiple' => true,
'asset_status_type' => 'RTD',
])
</div> <!--./box-body-->

View file

@ -2,7 +2,7 @@
<div id="assigned_asset" class="form-group{{ $errors->has($fieldname) ? ' has-error' : '' }}"{!! (isset($style)) ? ' style="'.e($style).'"' : '' !!}>
{{ 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 select2" data-endpoint="hardware" name="{{ $fieldname }}" style="width: 100%" id="assigned_asset_select"{{ (isset($multiple)) ? ' multiple="multiple"' : '' }}>
<select class="js-data-ajax select2" data-endpoint="hardware" name="{{ $fieldname }}" style="width: 100%" id="assigned_asset_select"{{ (isset($multiple)) ? ' multiple' : '' }}{!! (!empty($asset_status_type)) ? ' data-asset-status-type="' . $asset_status_type . '"' : '' !!}>
@if ((!isset($unselect)) && ($asset_id = Input::old($fieldname, (isset($asset) ? $asset->id : (isset($item) ? $item->{$fieldname} : '')))))
<option value="{{ $asset_id }}" selected="selected">

View file

@ -20,7 +20,7 @@ class CustomFieldTest extends BaseTest
public function testFormat()
{
$customfield = factory(CustomField::class)->make();
$customfield = factory(CustomField::class)->make(['format' => 'IP']);
$values = [
'name' => $customfield->name,
'format' => $customfield->format,