mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 14:27:33 -08:00
Merge branch 'master' of https://github.com/snipe/snipe-it
This commit is contained in:
commit
d06e3dd892
|
@ -8,6 +8,7 @@ use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||||
use App\Helpers\Helper;
|
use App\Helpers\Helper;
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
use Log;
|
use Log;
|
||||||
|
use JsonException;
|
||||||
|
|
||||||
|
|
||||||
class Handler extends ExceptionHandler
|
class Handler extends ExceptionHandler
|
||||||
|
@ -26,6 +27,7 @@ class Handler extends ExceptionHandler
|
||||||
\Illuminate\Validation\ValidationException::class,
|
\Illuminate\Validation\ValidationException::class,
|
||||||
\Intervention\Image\Exception\NotSupportedException::class,
|
\Intervention\Image\Exception\NotSupportedException::class,
|
||||||
\League\OAuth2\Server\Exception\OAuthServerException::class,
|
\League\OAuth2\Server\Exception\OAuthServerException::class,
|
||||||
|
JsonException::class
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,6 +62,12 @@ class Handler extends ExceptionHandler
|
||||||
return redirect()->back()->with('error', trans('general.token_expired'));
|
return redirect()->back()->with('error', trans('general.token_expired'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Invalid JSON exception
|
||||||
|
// TODO: don't understand why we have to do this when we have the invalidJson() method, below, but, well, whatever
|
||||||
|
if ($e instanceof JsonException) {
|
||||||
|
return response()->json(Helper::formatStandardApiResponse('error', null, 'invalid JSON'), 422);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Handle Ajax requests that fail because the model doesn't exist
|
// Handle Ajax requests that fail because the model doesn't exist
|
||||||
if ($request->ajax() || $request->wantsJson()) {
|
if ($request->ajax() || $request->wantsJson()) {
|
||||||
|
|
|
@ -866,7 +866,7 @@ class AssetsController extends Controller
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', ['asset'=> e($asset->asset_tag)], trans('admin/hardware/message.checkin.success')));
|
return response()->json(Helper::formatStandardApiResponse('success', ['asset'=> e($asset->asset_tag)], trans('admin/hardware/message.checkin.success')));
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', ['asset'=> e($asset->asset_tag)], trans('admin/hardware/message.checkin.error')));
|
return response()->json(Helper::formatStandardApiResponse('error', ['asset'=> e($asset->asset_tag)], trans('admin/hardware/message.checkin.error')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -155,7 +155,6 @@ class AssetModelsController extends Controller
|
||||||
$model->requestable = $request->input('requestable', '0');
|
$model->requestable = $request->input('requestable', '0');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$this->removeCustomFieldsDefaultValues($model);
|
$this->removeCustomFieldsDefaultValues($model);
|
||||||
|
|
||||||
if ($request->input('custom_fieldset')=='') {
|
if ($request->input('custom_fieldset')=='') {
|
||||||
|
@ -168,7 +167,6 @@ class AssetModelsController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($model->save()) {
|
if ($model->save()) {
|
||||||
return redirect()->route("models.index")->with('success', trans('admin/models/message.update.success'));
|
return redirect()->route("models.index")->with('success', trans('admin/models/message.update.success'));
|
||||||
}
|
}
|
||||||
|
@ -463,7 +461,9 @@ class AssetModelsController extends Controller
|
||||||
private function assignCustomFieldsDefaultValues(AssetModel $model, array $defaultValues)
|
private function assignCustomFieldsDefaultValues(AssetModel $model, array $defaultValues)
|
||||||
{
|
{
|
||||||
foreach ($defaultValues as $customFieldId => $defaultValue) {
|
foreach ($defaultValues as $customFieldId => $defaultValue) {
|
||||||
if ($defaultValue) {
|
if(is_array($defaultValue)){
|
||||||
|
$model->defaultValues()->attach($customFieldId, ['default_value' => implode(', ', $defaultValue)]);
|
||||||
|
}elseif ($defaultValue) {
|
||||||
$model->defaultValues()->attach($customFieldId, ['default_value' => $defaultValue]);
|
$model->defaultValues()->attach($customFieldId, ['default_value' => $defaultValue]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,14 @@ abstract class Request extends FormRequest
|
||||||
{
|
{
|
||||||
protected $rules = [];
|
protected $rules = [];
|
||||||
|
|
||||||
|
public function json($key = null, $default = null)
|
||||||
|
{
|
||||||
|
if ($this->ajax() || $this->wantsJson()) {
|
||||||
|
json_decode($this->getContent(), false, 512, JSON_THROW_ON_ERROR); // ignore output, just throw
|
||||||
|
}
|
||||||
|
return parent::json($key, $default);
|
||||||
|
}
|
||||||
|
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return $this->rules;
|
return $this->rules;
|
||||||
|
|
|
@ -115,6 +115,7 @@ trait Loggable
|
||||||
|
|
||||||
$log->location_id = null;
|
$log->location_id = null;
|
||||||
$log->note = $note;
|
$log->note = $note;
|
||||||
|
$log->action_date = $action_date;
|
||||||
|
|
||||||
if (Auth::user()) {
|
if (Auth::user()) {
|
||||||
$log->user_id = Auth::user()->id;
|
$log->user_id = Auth::user()->id;
|
||||||
|
|
|
@ -46,6 +46,14 @@
|
||||||
<input v-if="field.type == 'text'" class="form-control m-b-xs" type="text" :value="getValue(field)" :id="'default-value' + field.id" :name="'default_values[' + field.id + ']'">
|
<input v-if="field.type == 'text'" class="form-control m-b-xs" type="text" :value="getValue(field)" :id="'default-value' + field.id" :name="'default_values[' + field.id + ']'">
|
||||||
<textarea v-if="field.type == 'textarea'" class="form-control" :value="getValue(field)" :id="'default-value' + field.id" :name="'default_values[' + field.id + ']'"></textarea><br>
|
<textarea v-if="field.type == 'textarea'" class="form-control" :value="getValue(field)" :id="'default-value' + field.id" :name="'default_values[' + field.id + ']'"></textarea><br>
|
||||||
|
|
||||||
|
<div v-if="field.type == 'checkbox'" v-for="field_value in field.field_values_array">
|
||||||
|
<input v-if="field.type == 'checkbox'" class="" type="checkbox" :name="'default_values[' + field.id + '][]'" :value="field_value" :checked="getValue(field).split(', ').includes(field_value)"> <label>{{ field_value }}</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="field.type == 'radio'" v-for="field_value in field.field_values_array">
|
||||||
|
<input v-if="field.type == 'radio'" class="" type="radio" :name="'default_values[' + field.id + ']'" :value="field_value" :checked="getValue(field).split(', ').includes(field_value)"> <label>{{ field_value }}</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
<select v-if="field.type == 'listbox'" class="form-control m-b-xs" :name="'default_values[' + field.id + ']'">
|
<select v-if="field.type == 'listbox'" class="form-control m-b-xs" :name="'default_values[' + field.id + ']'">
|
||||||
<option value=""></option>
|
<option value=""></option>
|
||||||
<option v-for="field_value in field.field_values_array" :value="field_value" :selected="getValue(field) == field_value">{{ field_value }}</option>
|
<option v-for="field_value in field.field_values_array" :value="field_value" :selected="getValue(field) == field_value">{{ field_value }}</option>
|
||||||
|
|
|
@ -1079,7 +1079,7 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th data-visible="true" style="width: 40px;" class="hidden-xs">Icon</th>
|
<th data-visible="true" style="width: 40px;" class="hidden-xs">Icon</th>
|
||||||
<th class="col-sm-2" data-visible="true" data-field="created_at" data-formatter="dateDisplayFormatter">{{ trans('general.date') }}</th>
|
<th class="col-sm-2" data-visible="true" data-field="action_date" data-formatter="dateDisplayFormatter">{{ trans('general.date') }}</th>
|
||||||
<th class="col-sm-1" data-visible="true" data-field="admin" data-formatter="usersLinkObjFormatter">{{ trans('general.admin') }}</th>
|
<th class="col-sm-1" data-visible="true" data-field="admin" data-formatter="usersLinkObjFormatter">{{ trans('general.admin') }}</th>
|
||||||
<th class="col-sm-1" data-visible="true" data-field="action_type">{{ trans('general.action') }}</th>
|
<th class="col-sm-1" data-visible="true" data-field="action_type">{{ trans('general.action') }}</th>
|
||||||
<th class="col-sm-2" data-visible="true" data-field="item" data-formatter="polymorphicItemFormatter">{{ trans('general.item') }}</th>
|
<th class="col-sm-2" data-visible="true" data-field="item" data-formatter="polymorphicItemFormatter">{{ trans('general.item') }}</th>
|
||||||
|
|
|
@ -18,10 +18,9 @@
|
||||||
@elseif ($field->element=='checkbox')
|
@elseif ($field->element=='checkbox')
|
||||||
<!-- Checkboxes -->
|
<!-- Checkboxes -->
|
||||||
@foreach ($field->formatFieldValuesAsArray() as $key => $value)
|
@foreach ($field->formatFieldValuesAsArray() as $key => $value)
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" value="{{ $value }}" name="{{ $field->db_column_name() }}[]" class="minimal" {{ isset($item) ? (in_array($key, explode(', ', $item->{$field->db_column_name()})) ? ' checked="checked"' : '') : (Request::old($field->db_column_name()) != '' ? ' checked="checked"' : '') }}>
|
<input type="checkbox" value="{{ $value }}" name="{{ $field->db_column_name() }}[]" class="minimal" {{ isset($item) ? (in_array($value, explode(', ', $item->{$field->db_column_name()})) ? ' checked="checked"' : '') : (Request::old($field->db_column_name()) != '' ? ' checked="checked"' : (in_array($key, explode(', ', $field->defaultValue($model->id))) ? ' checked="checked"' : '')) }}>
|
||||||
{{ $value }}
|
{{ $value }}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
@ -32,7 +31,7 @@
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label>
|
<label>
|
||||||
<input type="radio" value="{{ $value }}" name="{{ $field->db_column_name() }}" class="minimal" {{ isset($item) ? ($item->{$field->db_column_name()} == $value ? ' checked="checked"' : '') : (Request::old($field->db_column_name()) != '' ? ' checked="checked"' : '') }}>
|
<input type="radio" value="{{ $value }}" name="{{ $field->db_column_name() }}" class="minimal" {{ isset($item) ? ($item->{$field->db_column_name()} == $value ? ' checked="checked"' : '') : (Request::old($field->db_column_name()) != '' ? ' checked="checked"' : (in_array($value, explode(', ', $field->defaultValue($model->id))) ? ' checked="checked"' : '')) }}>
|
||||||
{{ $value }}
|
{{ $value }}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue