Merge pull request #13796 from snipe/feature/sc-23880

Added optional custom fields to requestable assets page
This commit is contained in:
snipe 2023-10-25 20:57:54 +01:00 committed by GitHub
commit 7509d57bf6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 237 additions and 74 deletions

View file

@ -48,7 +48,7 @@ class AssetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $assetId * @param int $assetId
* @since [v4.0] * @since [v4.0]
* @return JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function index(Request $request, $audit = null) public function index(Request $request, $audit = null)
{ {
@ -443,7 +443,7 @@ class AssetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $assetId * @param int $assetId
* @since [v4.0] * @since [v4.0]
* @return JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function show(Request $request, $id) public function show(Request $request, $id)
{ {
@ -474,7 +474,7 @@ class AssetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0.16] * @since [v4.0.16]
* @see \App\Http\Transformers\SelectlistTransformer * @see \App\Http\Transformers\SelectlistTransformer
* * @return \Illuminate\Http\JsonResponse
*/ */
public function selectlist(Request $request) public function selectlist(Request $request)
{ {
@ -530,6 +530,7 @@ class AssetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param \App\Http\Requests\ImageUploadRequest $request * @param \App\Http\Requests\ImageUploadRequest $request
* @since [v4.0] * @since [v4.0]
* @return \Illuminate\Http\JsonResponse
*/ */
public function store(ImageUploadRequest $request) public function store(ImageUploadRequest $request)
{ {
@ -638,7 +639,7 @@ class AssetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param \App\Http\Requests\ImageUploadRequest $request * @param \App\Http\Requests\ImageUploadRequest $request
* @since [v4.0] * @since [v4.0]
* @return JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function update(ImageUploadRequest $request, $id) public function update(ImageUploadRequest $request, $id)
{ {
@ -719,7 +720,7 @@ class AssetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $assetId * @param int $assetId
* @since [v4.0] * @since [v4.0]
* @return JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function destroy($id) public function destroy($id)
{ {
@ -748,7 +749,7 @@ class AssetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $assetId * @param int $assetId
* @since [v5.1.18] * @since [v5.1.18]
* @return JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function restore(Request $request, $assetId = null) public function restore(Request $request, $assetId = null)
{ {
@ -788,7 +789,7 @@ class AssetsController extends Controller
* @author [N. Butler] * @author [N. Butler]
* @param string $tag * @param string $tag
* @since [v6.0.5] * @since [v6.0.5]
* @return JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function checkoutByTag(AssetCheckoutRequest $request, $tag) public function checkoutByTag(AssetCheckoutRequest $request, $tag)
{ {
@ -804,7 +805,7 @@ class AssetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $assetId * @param int $assetId
* @since [v4.0] * @since [v4.0]
* @return JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function checkout(AssetCheckoutRequest $request, $asset_id) public function checkout(AssetCheckoutRequest $request, $asset_id)
{ {
@ -888,7 +889,7 @@ class AssetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $assetId * @param int $assetId
* @since [v4.0] * @since [v4.0]
* @return JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function checkin(Request $request, $asset_id) public function checkin(Request $request, $asset_id)
{ {
@ -944,7 +945,7 @@ class AssetsController extends Controller
* *
* @author [A. Janes] [<ajanes@adagiohealth.org>] * @author [A. Janes] [<ajanes@adagiohealth.org>]
* @since [v6.0] * @since [v6.0]
* @return JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function checkinByTag(Request $request, $tag = null) public function checkinByTag(Request $request, $tag = null)
{ {
@ -970,7 +971,7 @@ class AssetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $id * @param int $id
* @since [v4.0] * @since [v4.0]
* @return JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function audit(Request $request) public function audit(Request $request)
@ -1031,24 +1032,54 @@ class AssetsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @return JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function requestable(Request $request) public function requestable(Request $request)
{ {
$this->authorize('viewRequestable', Asset::class); $this->authorize('viewRequestable', Asset::class);
$allowed_columns = [
'name',
'asset_tag',
'serial',
'model_number',
'image',
'purchase_cost',
'expected_checkin',
];
$all_custom_fields = CustomField::all(); //used as a 'cache' of custom fields throughout this page load
foreach ($all_custom_fields as $field) {
$allowed_columns[] = $field->db_column_name();
}
$assets = Asset::select('assets.*') $assets = Asset::select('assets.*')
->with('location', 'assetstatus', 'assetlog', 'company', 'defaultLoc','assignedTo', ->with('location', 'assetstatus', 'assetlog', 'company','assignedTo',
'model.category', 'model.manufacturer', 'model.fieldset', 'supplier') 'model.category', 'model.manufacturer', 'model.fieldset', 'supplier', 'requests')
->requestableAssets(); ->requestableAssets();
$offset = request('offset', 0);
$limit = $request->input('limit', 50);
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
if ($request->filled('search')) { if ($request->filled('search')) {
$assets->TextSearch($request->input('search')); $assets->TextSearch($request->input('search'));
} }
// Search custom fields by column name
foreach ($all_custom_fields as $field) {
if ($request->filled($field->db_column_name())) {
$assets->where($field->db_column_name(), '=', $request->input($field->db_column_name()));
}
}
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
$sort_override = str_replace('custom_fields.', '', $request->input('sort'));
// This handles all the pivot sorting (versus the assets.* fields
// in the allowed_columns array)
$column_sort = in_array($sort_override, $allowed_columns) ? $sort_override : 'assets.created_at';
switch ($request->input('sort')) { switch ($request->input('sort')) {
case 'model': case 'model':
$assets->OrderModels($order); $assets->OrderModels($order);
@ -1056,17 +1087,18 @@ class AssetsController extends Controller
case 'model_number': case 'model_number':
$assets->OrderModelNumber($order); $assets->OrderModelNumber($order);
break; break;
case 'category': case 'location':
$assets->OrderCategory($order); $assets->OrderLocation($order);
break;
case 'manufacturer':
$assets->OrderManufacturer($order);
break;
default: default:
$assets->orderBy('assets.created_at', $order); $assets->orderBy($column_sort, $order);
break; break;
} }
// Make sure the offset and limit are actually integers and do not exceed system limits
$offset = ($request->input('offset') > $assets->count()) ? $assets->count() : app('api_offset_value');
$limit = app('api_limit_value');
$total = $assets->count(); $total = $assets->count();
$assets = $assets->skip($offset)->take($limit)->get(); $assets = $assets->skip($offset)->take($limit)->get();

View file

@ -11,6 +11,7 @@ use Illuminate\Http\Request;
use Laravel\Passport\TokenRepository; use Laravel\Passport\TokenRepository;
use Illuminate\Contracts\Validation\Factory as ValidationFactory; use Illuminate\Contracts\Validation\Factory as ValidationFactory;
use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Gate;
use App\Models\CustomField;
use DB; use DB;
class ProfileController extends Controller class ProfileController extends Controller
@ -48,14 +49,23 @@ class ProfileController extends Controller
{ {
$checkoutRequests = CheckoutRequest::where('user_id', '=', Auth::user()->id)->get(); $checkoutRequests = CheckoutRequest::where('user_id', '=', Auth::user()->id)->get();
$results = []; $results = array();
$show_field = array();
$showable_fields = array();
$results['total'] = $checkoutRequests->count(); $results['total'] = $checkoutRequests->count();
$all_custom_fields = CustomField::all(); //used as a 'cache' of custom fields throughout this page load
foreach ($all_custom_fields as $field) {
if (($field->field_encrypted=='0') && ($field->show_in_requestable_list=='1')) {
$showable_fields[] = $field->db_column_name();
}
}
foreach ($checkoutRequests as $checkoutRequest) { foreach ($checkoutRequests as $checkoutRequest) {
// Make sure the asset and request still exist // Make sure the asset and request still exist
if ($checkoutRequest && $checkoutRequest->itemRequested()) { if ($checkoutRequest && $checkoutRequest->itemRequested()) {
$results['rows'][] = [ $assets = [
'image' => e($checkoutRequest->itemRequested()->present()->getImageUrl()), 'image' => e($checkoutRequest->itemRequested()->present()->getImageUrl()),
'name' => e($checkoutRequest->itemRequested()->present()->name()), 'name' => e($checkoutRequest->itemRequested()->present()->name()),
'type' => e($checkoutRequest->itemType()), 'type' => e($checkoutRequest->itemType()),
@ -64,7 +74,16 @@ class ProfileController extends Controller
'expected_checkin' => Helper::getFormattedDateObject($checkoutRequest->itemRequested()->expected_checkin, 'datetime'), 'expected_checkin' => Helper::getFormattedDateObject($checkoutRequest->itemRequested()->expected_checkin, 'datetime'),
'request_date' => Helper::getFormattedDateObject($checkoutRequest->created_at, 'datetime'), 'request_date' => Helper::getFormattedDateObject($checkoutRequest->created_at, 'datetime'),
]; ];
foreach ($showable_fields as $showable_field_name) {
$show_field['custom_fields.'.$showable_field_name] = $checkoutRequest->itemRequested()->{$showable_field_name};
}
// Merge the plain asset data and the custom fields data
$results['rows'][] = array_merge($assets, $show_field);
} }
} }
return $results; return $results;

View file

@ -110,6 +110,7 @@ class CustomFieldsController extends Controller
"display_in_user_view" => $display_in_user_view, "display_in_user_view" => $display_in_user_view,
"auto_add_to_fieldsets" => $request->get("auto_add_to_fieldsets", 0), "auto_add_to_fieldsets" => $request->get("auto_add_to_fieldsets", 0),
"show_in_listview" => $request->get("show_in_listview", 0), "show_in_listview" => $request->get("show_in_listview", 0),
"show_in_requestable_list" => $request->get("show_in_requestable_list", 0),
"user_id" => Auth::id() "user_id" => Auth::id()
]); ]);
@ -267,6 +268,7 @@ class CustomFieldsController extends Controller
$field->display_in_user_view = $display_in_user_view; $field->display_in_user_view = $display_in_user_view;
$field->auto_add_to_fieldsets = $request->get("auto_add_to_fieldsets", 0); $field->auto_add_to_fieldsets = $request->get("auto_add_to_fieldsets", 0);
$field->show_in_listview = $request->get("show_in_listview", 0); $field->show_in_listview = $request->get("show_in_listview", 0);
$field->show_in_requestable_list = $request->get("show_in_requestable_list", 0);
if ($request->get('format') == 'CUSTOM REGEX') { if ($request->get('format') == 'CUSTOM REGEX') {
$field->format = e($request->get('custom_format')); $field->format = e($request->get('custom_format'));

View file

@ -7,7 +7,7 @@ use App\Models\Asset;
use App\Models\Setting; use App\Models\Setting;
use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Gate;
use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Collection;
use Auth;
class AssetsTransformer class AssetsTransformer
{ {
@ -231,6 +231,29 @@ class AssetsTransformer
'assigned_to_self' => ($asset->assigned_to == \Auth::user()->id), 'assigned_to_self' => ($asset->assigned_to == \Auth::user()->id),
]; ];
if (($asset->model) && ($asset->model->fieldset) && ($asset->model->fieldset->fields->count() > 0)) {
$fields_array = [];
foreach ($asset->model->fieldset->fields as $field) {
// Only display this if it's allowed via the custom field setting
if (($field->field_encrypted=='0') && ($field->show_in_requestable_list=='1')) {
$value = $asset->{$field->db_column};
if (($field->format == 'DATE') && (!is_null($value)) && ($value != '')) {
$value = Helper::getFormattedDateObject($value, 'date', false);
}
$fields_array[$field->db_column] = e($value);
}
$array['custom_fields'] = $fields_array;
}
} else {
$array['custom_fields'] = new \stdClass; // HACK to force generation of empty object instead of empty list
}
$permissions_array['available_actions'] = [ $permissions_array['available_actions'] = [
'cancel' => ($asset->isRequestedBy(\Auth::user())) ? true : false, 'cancel' => ($asset->isRequestedBy(\Auth::user())) ? true : false,
'request' => ($asset->isRequestedBy(\Auth::user())) ? false : true, 'request' => ($asset->isRequestedBy(\Auth::user())) ? false : true,

View file

@ -787,7 +787,6 @@ class Asset extends Depreciable
} }
/** /**
* Get the next autoincremented asset tag * Get the next autoincremented asset tag
* *

View file

@ -53,6 +53,12 @@ class CustomField extends Model
'field_encrypted' => 'nullable|boolean', 'field_encrypted' => 'nullable|boolean',
'auto_add_to_fieldsets' => 'boolean', 'auto_add_to_fieldsets' => 'boolean',
'show_in_listview' => 'boolean', 'show_in_listview' => 'boolean',
'show_in_requestable_list' => 'boolean',
'show_in_email' => 'boolean',
];
protected $casts = [
'show_in_requestable_list' => 'boolean',
]; ];
/** /**
@ -72,7 +78,8 @@ class CustomField extends Model
'display_in_user_view', 'display_in_user_view',
'auto_add_to_fieldsets', 'auto_add_to_fieldsets',
'show_in_listview', 'show_in_listview',
'show_in_email',
'show_in_requestable_list',
]; ];
/** /**
@ -243,8 +250,6 @@ class CustomField extends Model
/** /**
* Gets the DB column name. * Gets the DB column name.
* *
* @todo figure out if this is still needed? I don't know WTF it's for.
*
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v3.0] * @since [v3.0]
* @return string * @return string

View file

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddShowInRequestableToCustomFields extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('custom_fields', function (Blueprint $table) {
$table->boolean('show_in_requestable_list')->after('show_in_email')->nullable()->default(0);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('custom_fields', function (Blueprint $table) {
if (Schema::hasColumn('custom_fields', 'show_in_requestable_list')) {
$table->dropColumn('show_in_requestable_list');
}
});
}
}

View file

@ -34,7 +34,8 @@ return [
'create_field' => 'New Custom Field', 'create_field' => 'New Custom Field',
'create_field_title' => 'Create a new custom field', 'create_field_title' => 'Create a new custom field',
'value_encrypted' => 'The value of this field is encrypted in the database. Only admin users will be able to view the decrypted value', 'value_encrypted' => 'The value of this field is encrypted in the database. Only admin users will be able to view the decrypted value',
'show_in_email' => 'Include the value of this field in checkout emails sent to the user? Encrypted fields cannot be included in emails.', 'show_in_email' => 'Include the value of this field in checkout emails sent to the user? Encrypted fields cannot be included in emails',
'show_in_email_short' => 'Include in emails.',
'help_text' => 'Help Text', 'help_text' => 'Help Text',
'help_text_description' => 'This is optional text that will appear below the form elements while editing an asset to provide context on the field.', 'help_text_description' => 'This is optional text that will appear below the form elements while editing an asset to provide context on the field.',
'about_custom_fields_title' => 'About Custom Fields', 'about_custom_fields_title' => 'About Custom Fields',
@ -51,7 +52,10 @@ return [
'display_in_user_view_table' => 'Visible to User', 'display_in_user_view_table' => 'Visible to User',
'auto_add_to_fieldsets' => 'Automatically add this to every new fieldset', 'auto_add_to_fieldsets' => 'Automatically add this to every new fieldset',
'add_to_preexisting_fieldsets' => 'Add to any existing fieldsets', 'add_to_preexisting_fieldsets' => 'Add to any existing fieldsets',
'show_in_listview' => 'Show in list views by default. Authorized users will still be able to show/hide via the column selector.', 'show_in_listview' => 'Show in list views by default. Authorized users will still be able to show/hide via the column selector',
'show_in_listview_short' => 'Show in lists', 'show_in_listview_short' => 'Show in lists',
'show_in_requestable_list_short' => 'Show in requestable assets list',
'show_in_requestable_list' => 'Show value in requestable assets list. Encrypted fields will not be shown',
'encrypted_options' => 'This field is encrypted, so some display options will not be available.',
]; ];

View file

@ -65,6 +65,12 @@
<th class="col-md-2" data-field="location" data-sortable="true">{{ trans('admin/hardware/table.location') }}</th> <th class="col-md-2" data-field="location" data-sortable="true">{{ trans('admin/hardware/table.location') }}</th>
<th class="col-md-2" data-field="status" data-sortable="true">{{ trans('admin/hardware/table.status') }}</th> <th class="col-md-2" data-field="status" data-sortable="true">{{ trans('admin/hardware/table.status') }}</th>
<th class="col-md-2" data-field="expected_checkin" data-formatter="dateDisplayFormatter" data-sortable="true">{{ trans('admin/hardware/form.expected_checkin') }}</th> <th class="col-md-2" data-field="expected_checkin" data-formatter="dateDisplayFormatter" data-sortable="true">{{ trans('admin/hardware/form.expected_checkin') }}</th>
@foreach(\App\Models\CustomField::get() as $field)
@if (($field->field_encrypted=='0') && ($field->show_in_requestable_list=='1'))
<th class="col-md-2" data-field="custom_fields.{{ $field->db_column }}" data-sortable="true">{{ $field->name }}</th>
@endif
@endforeach
<th class="col-md-1" data-formatter="assetRequestActionsFormatter" data-field="actions" data-sortable="false">{{ trans('table.actions') }}</th> <th class="col-md-1" data-formatter="assetRequestActionsFormatter" data-field="actions" data-sortable="false">{{ trans('table.actions') }}</th>
</tr> </tr>
</thead> </thead>

View file

@ -32,13 +32,19 @@
}'> }'>
<thead> <thead>
<tr> <tr>
<th class="col-md-1" data-field="image" data-formatter="imageFormatter">{{ trans('general.image') }}</th> <th data-field="image" data-formatter="imageFormatter">{{ trans('general.image') }}</th>
<th class="col-md-2" data-field="name">{{ trans('general.item_name') }}</th> <th data-field="name">{{ trans('general.item_name') }}</th>
<th class="col-md-2" data-field="type">{{ trans('general.type') }}</th> <th data-field="type">{{ trans('general.type') }}</th>
<th class="col-md-2" data-field="qty">{{ trans('general.qty') }}</th> <th data-field="qty">{{ trans('general.qty') }}</th>
<th class="col-md-2" data-field="location">{{ trans('admin/hardware/table.location') }}</th> <th data-field="location">{{ trans('admin/hardware/table.location') }}</th>
<th class="col-md-2" data-field="expected_checkin" data-formatter="dateDisplayFormatter"> {{ trans('admin/hardware/form.expected_checkin') }}</th> <th data-field="expected_checkin" data-formatter="dateDisplayFormatter"> {{ trans('admin/hardware/form.expected_checkin') }}</th>
<th class="col-md-2" data-field="request_date" data-formatter="dateDisplayFormatter"> {{ trans('general.requested_date') }}</th> <th data-field="request_date" data-formatter="dateDisplayFormatter"> {{ trans('general.requested_date') }}</th>
@foreach(\App\Models\CustomField::get() as $field)
@if (($field->field_encrypted=='0') && ($field->show_in_requestable_list=='1'))
<th data-field="custom_fields.{{ $field->db_column }}">{{ $field->name }}</th>
@endif
@endforeach
</tr> </tr>
</thead> </thead>
</table> </table>

View file

@ -88,7 +88,7 @@
} }
@endphp @endphp
<div class="col-md-8 required"> <div class="col-md-8 required">
{{ Form::select("format",Helper::predefined_formats(), ($field_format == '') ? $field->format : $field_format, array('class'=>'format select2 form-control', 'aria-label'=>'format')) }} {{ Form::select("format",Helper::predefined_formats(), ($field_format == '') ? $field->format : $field_format, array('class'=>'format select2 form-control', 'aria-label'=>'format', 'style' => 'width:100%;')) }}
{!! $errors->first('format', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!} {!! $errors->first('format', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div> </div>
</div> </div>
@ -118,10 +118,40 @@
</div> </div>
</div> </div>
<!-- Set up checkbox form group -->
<div class="form-group">
<!-- Encrypted warning callout box -->
@if (($field->id) && ($field->field_encrypted=='1'))
<div class="col-md-9 col-md-offset-3">
<div class="alert alert-warning fade in">
<i class="fas fa-exclamation-triangle faa-pulse animated"></i>
<strong>{{ trans('general.notification_warning') }}:</strong>
{{ trans('admin/custom_fields/general.encrypted_options') }}
</div>
</div>
@endif
@if (!$field->id)
<!-- Encrypted -->
<div class="col-md-9 col-md-offset-3">
<label class="form-control">
<input type="checkbox" value="1" name="field_encrypted" id="field_encrypted"{{ (Request::old('field_encrypted') || $field->field_encrypted) ? ' checked="checked"' : '' }}>
{{ trans('admin/custom_fields/general.encrypt_field') }}
</label>
</div>
<div class="col-md-9 col-md-offset-3" id="encrypt_warning" style="display:none;">
<div class="callout callout-danger">
<p><i class="fas fa-exclamation-triangle" aria-hidden="true"></i> {{ trans('admin/custom_fields/general.encrypt_field_help') }}</p>
</div>
</div>
@endif
<!-- Auto-Add to Future Fieldsets --> <!-- Auto-Add to Future Fieldsets -->
<div class="form-group {{ $errors->has('auto_add_to_fieldsets') ? ' has-error' : '' }}" id="auto_add_to_fieldsets">
<div class="col-md-9 col-md-offset-3"> <div class="col-md-9 col-md-offset-3">
<label class="form-control"> <label class="form-control">
<input type="checkbox" name="auto_add_to_fieldsets" aria-label="auto_add_to_fieldsets" value="1"{{ (old('auto_add_to_fieldsets') || $field->auto_add_to_fieldsets) ? ' checked="checked"' : '' }}> <input type="checkbox" name="auto_add_to_fieldsets" aria-label="auto_add_to_fieldsets" value="1"{{ (old('auto_add_to_fieldsets') || $field->auto_add_to_fieldsets) ? ' checked="checked"' : '' }}>
@ -129,6 +159,7 @@
</label> </label>
</div> </div>
<!-- Show in list view -->
<div class="col-md-9 col-md-offset-3"> <div class="col-md-9 col-md-offset-3">
<label class="form-control"> <label class="form-control">
<input type="checkbox" name="show_in_listview" aria-label="show_in_listview" value="1"{{ (old('show_in_listview') || $field->show_in_listview) ? ' checked="checked"' : '' }}> <input type="checkbox" name="show_in_listview" aria-label="show_in_listview" value="1"{{ (old('show_in_listview') || $field->show_in_listview) ? ' checked="checked"' : '' }}>
@ -136,45 +167,43 @@
</label> </label>
</div> </div>
@if (!$field->id)
<!-- Encrypted -->
<div class="col-md-9 col-md-offset-3">
<label class="form-control">
<input type="checkbox" value="1" name="field_encrypted" id="field_encrypted"{{ (Request::old('field_encrypted') || $field->field_encrypted) ? ' checked="checked"' : '' }}>
{{ trans('admin/custom_fields/general.encrypt_field') }}
</label>
</div>
<div class="col-md-9 col-md-offset-3" id="encrypt_warning" style="display:none;"> @if ((!$field->id) || ($field->field_encrypted=='0'))
<div class="callout callout-danger">
<p><i class="fas fa-exclamation-triangle" aria-hidden="true"></i> {{ trans('admin/custom_fields/general.encrypt_field_help') }}</p> <!-- Show in requestable list view -->
</div> <div class="col-md-9 col-md-offset-3" id="show_in_requestable_list">
</div> <label class="form-control">
@endif <input type="checkbox" name="show_in_requestable_list" aria-label="show_in_requestable_list" value="1"{{ (old('show_in_requestable_list') || $field->show_in_requestable_list) ? ' checked="checked"' : '' }}>
{{ trans('admin/custom_fields/general.show_in_requestable_list') }}
</label>
</div>
<!-- Show in Email --> <!-- Show in Email -->
<div class="col-md-9 col-md-offset-3"> <div class="col-md-9 col-md-offset-3" id="show_in_email">
<label class="form-control"> <label class="form-control">
<input type="checkbox" name="show_in_email" aria-label="show_in_email" value="1"{{ (old('show_in_email') || $field->show_in_email) ? ' checked="checked"' : '' }}> <input type="checkbox" name="show_in_email" aria-label="show_in_email" value="1"{{ (old('show_in_email') || $field->show_in_email) ? ' checked="checked"' : '' }}>
{{ trans('admin/custom_fields/general.show_in_email') }} {{ trans('admin/custom_fields/general.show_in_email') }}
</label> </label>
</div> </div>
<!-- Value Must be Unique -->
<div class="col-md-9 col-md-offset-3" id="is_unique">
<label class="form-control">
<input type="checkbox" name="is_unique" aria-label="is_unique" value="1"{{ (old('is_unique') || $field->is_unique) ? ' checked="checked"' : '' }}>
{{ trans('admin/custom_fields/general.is_unique') }}
</label>
</div>
@endif
<!-- Show in View All Assets profile view --> <!-- Show in View All Assets profile view -->
<div class="col-md-9 col-md-offset-3"> <div class="col-md-9 col-md-offset-3" id="display_in_user_view">
<label class="form-control"> <label class="form-control">
<input type="checkbox" name="display_in_user_view" aria-label="display_in_user_view" value="1" {{ (old('display_in_user_view') || $field->display_in_user_view) ? ' checked="checked"' : '' }}> <input type="checkbox" name="display_in_user_view" aria-label="display_in_user_view" value="1" {{ (old('display_in_user_view') || $field->display_in_user_view) ? ' checked="checked"' : '' }}>
{{ trans('admin/custom_fields/general.display_in_user_view') }} {{ trans('admin/custom_fields/general.display_in_user_view') }}
</label> </label>
</div> </div>
<!-- Value Must be Unique -->
<div class="col-md-9 col-md-offset-3">
<label class="form-control">
<input type="checkbox" name="is_unique" aria-label="is_unique" value="1"{{ (old('is_unique') || $field->is_unique) ? ' checked="checked"' : '' }}>
{{ trans('admin/custom_fields/general.is_unique') }}
</label>
</div>
</div> </div>
@ -287,11 +316,13 @@
$("#show_in_email").hide(); $("#show_in_email").hide();
$("#display_in_user_view").hide(); $("#display_in_user_view").hide();
$("#is_unique").hide(); $("#is_unique").hide();
$("#show_in_requestable_list").hide();
} else { } else {
$("#encrypt_warning").hide(); $("#encrypt_warning").hide();
$("#show_in_email").show(); $("#show_in_email").show();
$("#display_in_user_view").show(); $("#display_in_user_view").show();
$("#is_unique").show(); $("#is_unique").show();
$("#show_in_requestable_list").show();
} }
}); });

View file

@ -145,12 +145,13 @@
<th data-sortable="true"><i class="fa fa-lock" aria-hidden="true"></i> <th data-sortable="true"><i class="fa fa-lock" aria-hidden="true"></i>
<span class="hidden-xs hidden-sm hidden-md hidden-lg">{{ trans('admin/custom_fields/general.encrypted') }}</span> <span class="hidden-xs hidden-sm hidden-md hidden-lg">{{ trans('admin/custom_fields/general.encrypted') }}</span>
</th> </th>
<th data-sortable="true"><i class="fa fa-list" aria-hidden="true"></i> <th data-sortable="true" class="text-center"><i class="fa fa-list" aria-hidden="true"></i>
<span class="hidden-xs hidden-sm hidden-md hidden-lg">{{ trans('admin/custom_fields/general.show_in_listview_short') }}</span> <span class="hidden-xs hidden-sm hidden-md hidden-lg">{{ trans('admin/custom_fields/general.show_in_listview_short') }}</span>
</th> </th>
<th data-visible="false" data-sortable="true"><i class="fa fa-eye" aria-hidden="true"><span class="sr-only">Visible to User</span></i></th> <th data-visible="false" data-sortable="true" class="text-center"><i class="fa fa-eye" aria-hidden="true"><span class="sr-only">Visible to User</span></i></th>
<th data-sortable="true" data-searchable="true"><i class="fa fa-envelope" aria-hidden="true"><span class="sr-only">Show in Email</span></i></th> <th data-sortable="true" data-searchable="true" class="text-center"><i class="fa fa-envelope" aria-hidden="true"><span class="sr-only">{{ trans('admin/custom_fields/general.show_in_email_short') }}</span></i></th>
<th data-sortable="true" data-searchable="true">{{ trans('admin/custom_fields/general.field_element_short') }}</th> <th data-sortable="true" data-searchable="true" class="text-center"><i class="fa fa-laptop fa-fw" aria-hidden="true"><span class="sr-only">{{ trans('admin/custom_fields/general.show_in_requestable_list_short') }}</span></i></th>
<th data-sortable="true" data-searchable="true" class="text-center">{{ trans('admin/custom_fields/general.field_element_short') }}</th>
<th data-searchable="true">{{ trans('admin/custom_fields/general.fieldsets') }}</th> <th data-searchable="true">{{ trans('admin/custom_fields/general.fieldsets') }}</th>
<th>{{ trans('button.actions') }}</th> <th>{{ trans('button.actions') }}</th>
</tr> </tr>
@ -161,7 +162,7 @@
<td>{{ $field->name }}</td> <td>{{ $field->name }}</td>
<td>{{ $field->help_text }}</td> <td>{{ $field->help_text }}</td>
<td class='text-center'>{!! ($field->is_unique=='1') ? '<i class="fas fa-check text-success" aria-hidden="true"><span class="sr-only">'.trans('general.yes').'</span></i>' : '<i class="fas fa-times text-danger" aria-hidden="true"><span class="sr-only">'.trans('general.no').'</span></i>' !!}</td> <td class="text-center">{!! ($field->is_unique=='1') ? '<i class="fas fa-check text-success" aria-hidden="true"><span class="sr-only">'.trans('general.yes').'</span></i>' : '<i class="fas fa-times text-danger" aria-hidden="true"><span class="sr-only">'.trans('general.no').'</span></i>' !!}</td>
<td> <td>
<code>{{ $field->convertUnicodeDbSlug() }}</code> <code>{{ $field->convertUnicodeDbSlug() }}</code>
@if ($field->convertUnicodeDbSlug()!=$field->db_column) @if ($field->convertUnicodeDbSlug()!=$field->db_column)
@ -170,10 +171,11 @@
@endif @endif
</td> </td>
<td>{{ $field->format }}</td> <td>{{ $field->format }}</td>
<td>{!! ($field->field_encrypted=='1' ? '<i class="fa fa-check text-success"></i>' : '<i class="fa fa-times text-danger"></i>') !!}</td> <td class="text-center">{!! ($field->field_encrypted=='1' ? '<i class="fa fa-check text-success"></i>' : '<i class="fa fa-times text-danger"></i>') !!}</td>
<td>{!! ($field->show_in_listview=='1' ? '<i class="fa fa-check text-success"></i>' : '<i class="fa fa-times text-danger"></i>') !!}</td> <td class="text-center">{!! ($field->show_in_listview=='1' ? '<i class="fa fa-check text-success"></i>' : '<i class="fa fa-times text-danger"></i>') !!}</td>
<td>{!! ($field->display_in_user_view=='1' ? '<i class="fa fa-check text-success"></i>' : '<i class="fa fa-times text-danger"></i>') !!}</td> <td class="text-center">{!! ($field->display_in_user_view=='1' ? '<i class="fa fa-check text-success"></i>' : '<i class="fa fa-times text-danger"></i>') !!}</td>
<td class='text-center'>{!! ($field->show_in_email=='1') ? '<i class="fas fa-check text-success" aria-hidden="true"><span class="sr-only">'.trans('general.yes').'</span></i>' : '<i class="fas fa-times text-danger" aria-hidden="true"><span class="sr-only">'.trans('general.no').'</span></i>' !!}</td> <td class="text-center">{!! ($field->show_in_email=='1') ? '<i class="fas fa-check text-success" aria-hidden="true"><span class="sr-only">'.trans('general.yes').'</span></i>' : '<i class="fas fa-times text-danger" aria-hidden="true"><span class="sr-only">'.trans('general.no').'</span></i>' !!}</td>
<td class="text-center">{!! ($field->show_in_requestable_list=='1') ? '<i class="fas fa-check text-success" aria-hidden="true"><span class="sr-only">'.trans('general.yes').'</span></i>' : '<i class="fas fa-times text-danger" aria-hidden="true"><span class="sr-only">'.trans('general.no').'</span></i>' !!}</td>
<td>{{ $field->element }}</td> <td>{{ $field->element }}</td>
<td> <td>
@foreach($field->fieldset as $fieldset) @foreach($field->fieldset as $fieldset)