1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-23 05:16:03 +02:00

feat(admin-plugin): add ability to hide fieldsets from entries type select #304

Logic:
if hide property is true then hide fieldsets from entries type select.
if hide property is false then show fieldsets from entries type select.
if hide property is is not exists then show fieldsets from entries type select.
This commit is contained in:
Awilum
2019-11-21 23:07:32 +03:00
parent 5ad20548f4
commit d44037338c
5 changed files with 40 additions and 14 deletions

View File

@@ -129,6 +129,9 @@ class EntriesController extends Controller
if ($fieldset['type'] == 'file' && $fieldset['extension'] == 'yaml') {
$fieldset_content = $this->parser->decode(Filesystem::read($fieldset['path']), 'yaml');
if (isset($fieldset_content['sections']) && isset($fieldset_content['sections']['main']) && isset($fieldset_content['sections']['main']['fields'])) {
if (isset($fieldset_content['hide']) && $fieldset_content['hide'] == true) {
continue;
}
$fieldsets[$fieldset['basename']] = $fieldset_content['title'];
}
}

View File

@@ -79,6 +79,7 @@ class FieldsetsController extends Controller
$data = ['title' => $data['title'],
'default_field' => 'title',
'icon' => $data['icon'],
'hide' => (bool) $data['hide'],
'sections' => [
'main' => [
'title' => 'Main',

View File

@@ -299,3 +299,5 @@ admin_help_text_for_settings_errors_display_label: "Display errors."
admin_help_text_for_settings_errors_display_datails_label: "Display errors details."
admin_help_text_for_settings_errors_whoops_editor_label: "Whoops editor."
admin_help_text_for_settings_errors_whoops_page_title_label: "Whoops page title."
admin_help_text_for_fieldsets_hide: "Hide fieldsets from entries type select."
admin_hide: "Hide"

View File

@@ -15,11 +15,33 @@
<input type="text" id="fieldsetId" name="id" value="" class="form-control" required="required" data-validation="length required" data-validation-length="min1" data-validation-error-msg="{{ tr('admin_error_name_empty_input') }}">
<small class="form-text text-muted">{{ tr('admin_help_text_for_fieldsets_name') }}</small>
</div>
<div class="form-group">
<label for="icon">{{ tr('admin_icon') }}</label>
<input type="text" id="fieldsetIcon" name="icon" value="far fa-file-alt" class="form-control" required="required" data-validation="length required" data-validation-length="min1" data-validation-error-msg="{{ tr('admin_error_icon_empty_input') }}">
<small class="form-text text-muted">{{ tr('admin_help_text_for_fieldsets_icon', {':link': '<a href="https://fontawesome.com/icons?d=gallery&m=free" target="_blank">fontawesome</a>'})|raw }}</small>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="col-md-7">
<div class="form-group">
<label for="icon">{{ tr('admin_icon') }}</label>
<input type="text" id="fieldsetIcon" name="icon" value="far fa-file-alt" class="form-control" required="required" data-validation="length required" data-validation-length="min1" data-validation-error-msg="{{ tr('admin_error_icon_empty_input') }}">
<small class="form-text text-muted">{{ tr('admin_help_text_for_fieldsets_icon', {':link': '<a href="https://fontawesome.com/icons?d=gallery&m=free" target="_blank">fontawesome</a>'})|raw }}</small>
</div>
</div>
<div class="col-md-5">
<div class="form-group">
<label for="icon">{{ tr('admin_hide') }}</label>
<select class="form-control" id="fieldsetHide" name="hide" class="form-control">
<option value="1">{{ tr('admin_yes') }}</option>
<option value="0" selected>{{ tr('admin_no') }}</option>
</select>
<small class="form-text text-muted">{{ tr('admin_help_text_for_fieldsets_hide') }}</small>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<input type="submit" id="createFieldset" name="create_fieldset" value="{{ tr('admin_create') }}" class="btn btn-black">
</div>

View File

@@ -5,21 +5,19 @@
<table class="table no-margin">
<tbody>
{% for id, title in fieldsets_list %}
{% set fieldset_path = PATH_FIELDSETS ~ '/' ~ id ~ '.yaml' %}
{% if filesystem_has(fieldset_path) %}
{% set fieldset = parser_decode(filesystem_read(fieldset_path), 'yaml') %}
{% endif %}
<tr>
<td style="width: 50px; padding-right: 10px; text-align:center;">
{% set fieldset_path = PATH_FIELDSETS ~ '/' ~ id ~ '.yaml' %}
{% if filesystem_has(fieldset_path) %}
{% set fieldset = parser_decode(filesystem_read(fieldset_path), 'yaml') %}
{% if fieldset.icon %}
<i class="{{ fieldset.icon }}"></i>
{% else %}
<i class="far fa-file-alt"></i>
{% endif %}
<td style="width: 50px; padding-right: 10px; text-align:center;" class="{% if fieldset.hide %}opacity-50{% endif %}">
{% if fieldset.icon %}
<i class="{{ fieldset.icon }}"></i>
{% else %}
<i class="far fa-file-alt"></i>
{% endif %}
</td>
<td style="padding-left:0px;">
<td style="padding-left:0px;" class="{% if fieldset.hide %}opacity-50{% endif %}">
<a href="{{ path_for('admin.fieldsets.edit') }}?id={{ id }}">{{ title }}</a>
</td>
<td class="text-right">