Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to show/hide custom fields in list views by default #13312

Merged
merged 1 commit into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/Http/Controllers/CustomFieldsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public function store(CustomFieldRequest $request)
"is_unique" => $request->get("is_unique", 0),
"display_in_user_view" => $display_in_user_view,
"auto_add_to_fieldsets" => $request->get("auto_add_to_fieldsets", 0),
"show_in_listview" => $request->get("show_in_listview", 0),
"user_id" => Auth::id()
]);

Expand Down Expand Up @@ -265,6 +266,7 @@ public function update(CustomFieldRequest $request, $id)
$field->is_unique = $request->get("is_unique", 0);
$field->display_in_user_view = $display_in_user_view;
$field->auto_add_to_fieldsets = $request->get("auto_add_to_fieldsets", 0);
$field->show_in_listview = $request->get("show_in_listview", 0);

if ($request->get('format') == 'CUSTOM REGEX') {
$field->format = e($request->get('custom_format'));
Expand Down
1 change: 1 addition & 0 deletions app/Http/Transformers/CustomFieldsTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public function transformCustomField(CustomField $field)
'required' => (($field->pivot) && ($field->pivot->required=='1')) ? true : false,
'display_in_user_view' => ($field->display_in_user_view =='1') ? true : false,
'auto_add_to_fieldsets' => ($field->auto_add_to_fieldsets == '1') ? true : false,
'show_in_listview' => ($field->show_in_listview == '1') ? true : false,
'created_at' => Helper::getFormattedDateObject($field->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($field->updated_at, 'datetime'),
];
Expand Down
2 changes: 2 additions & 0 deletions app/Models/CustomField.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class CustomField extends Model
'element' => 'required|in:text,listbox,textarea,checkbox,radio',
'field_encrypted' => 'nullable|boolean',
'auto_add_to_fieldsets' => 'boolean',
'show_in_listview' => 'boolean',
];

/**
Expand All @@ -71,6 +72,7 @@ class CustomField extends Model
'is_unique',
'display_in_user_view',
'auto_add_to_fieldsets',
'show_in_listview',

];

Expand Down
2 changes: 1 addition & 1 deletion app/Presenters/AssetPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public static function dataTableLayout()
'formatter'=> 'customFieldsFormatter',
'escape' => true,
'class' => ($field->field_encrypted == '1') ? 'css-padlock' : '',
'visible' => true,
'visible' => ($field->show_in_listview == '1') ? true : false,
];
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddShowInListViewToCustomFields extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('custom_fields', function (Blueprint $table) {
$table->boolean('show_in_listview')->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_listview')) {
$table->dropColumn('show_in_listview');
}
});
}
}
3 changes: 3 additions & 0 deletions resources/lang/en/admin/custom_fields/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,7 @@
'display_in_user_view_table' => 'Visible to User',
'auto_add_to_fieldsets' => 'Automatically add this to every new fieldset',
'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_short' => 'Show in lists',

];
11 changes: 10 additions & 1 deletion resources/views/custom_fields/fields/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@
</div>
</div>

<!-- 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">
<label class="form-control">
Expand All @@ -127,6 +129,13 @@
</label>
</div>

<div class="col-md-9 col-md-offset-3">
<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"' : '' }}>
{{ trans('admin/custom_fields/general.show_in_listview') }}
</label>
</div>

@if (!$field->id)
<!-- Encrypted -->
<div class="col-md-9 col-md-offset-3">
Expand Down
4 changes: 4 additions & 0 deletions resources/views/custom_fields/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ class="table table-striped snipe-table"
<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>
</th>
<th data-sortable="true"><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>
</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-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">{{ trans('admin/custom_fields/general.field_element_short') }}</th>
Expand All @@ -168,6 +171,7 @@ class="table table-striped snipe-table"
</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>{!! ($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->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>{{ $field->element }}</td>
Expand Down