mirror of
https://github.com/flextype/flextype.git
synced 2025-08-23 21:33:01 +02:00
feat(admin-plugin): add entry select type modal on entry creation #331
This commit is contained in:
@@ -69,6 +69,30 @@ class EntriesController extends Controller
|
||||
$parts = [0 => ''];
|
||||
}
|
||||
|
||||
// Init Fieldsets
|
||||
$fieldsets = [];
|
||||
|
||||
// Get fieldsets files
|
||||
$fieldsets_list = Filesystem::listContents(PATH['site'] . '/fieldsets/');
|
||||
|
||||
// If there is any fieldset file then go...
|
||||
if (count($fieldsets_list) > 0) {
|
||||
foreach ($fieldsets_list as $fieldset) {
|
||||
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']) &&
|
||||
isset($fieldset_content['sections']['main']['fields']['title'])) {
|
||||
if (isset($fieldset_content['hide']) && $fieldset_content['hide'] == true) {
|
||||
continue;
|
||||
}
|
||||
$fieldsets[$fieldset['basename']] = $fieldset_content;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->view->render(
|
||||
$response,
|
||||
'plugins/admin/views/templates/content/entries/index.html',
|
||||
@@ -76,6 +100,7 @@ class EntriesController extends Controller
|
||||
'entries_list' => $this->entries->fetch($this->getEntryID($query), ['order_by' => ['field' => 'published_at', 'direction' => 'desc']]),
|
||||
'id_current' => $this->getEntryID($query),
|
||||
'menu_item' => 'entries',
|
||||
'fieldsets' => $fieldsets,
|
||||
'parts' => $parts,
|
||||
'i' => count($parts),
|
||||
'last' => Arr::last($parts),
|
||||
@@ -88,9 +113,9 @@ class EntriesController extends Controller
|
||||
],
|
||||
'buttons' => [
|
||||
'create' => [
|
||||
'link' => $this->router->pathFor('admin.entries.add') . '?id=' . $this->getEntryID($query),
|
||||
'link' => 'javascript:;',
|
||||
'title' => __('admin_create_new_entry'),
|
||||
'attributes' => ['class' => 'float-right btn']
|
||||
'attributes' => ['class' => 'float-right btn', 'data-toggle' => 'modal', 'data-target' => '#selectEntryTypeModal']
|
||||
]
|
||||
]
|
||||
]
|
||||
@@ -117,40 +142,19 @@ class EntriesController extends Controller
|
||||
$parts = [0 => ''];
|
||||
}
|
||||
|
||||
// Init Fieldsets
|
||||
$fieldsets = [];
|
||||
$type = isset($query['type']) ? $query['type']: '';
|
||||
|
||||
// Get fieldsets files
|
||||
$fieldsets_list = Filesystem::listContents(PATH['site'] . '/fieldsets/');
|
||||
|
||||
// If there is any fieldset file then go...
|
||||
if (count($fieldsets_list) > 0) {
|
||||
foreach ($fieldsets_list as $fieldset) {
|
||||
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']) &&
|
||||
isset($fieldset_content['sections']['main']['fields']['title'])) {
|
||||
if (isset($fieldset_content['hide']) && $fieldset_content['hide'] == true) {
|
||||
continue;
|
||||
}
|
||||
$fieldsets[$fieldset['basename']] = $fieldset_content['title'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->view->render(
|
||||
$response,
|
||||
'plugins/admin/views/templates/content/entries/add.html',
|
||||
[
|
||||
'entries_list' => $this->entries->fetch($this->getEntryID($query), ['order_by' => ['field' => 'title', 'direction' => 'asc']]),
|
||||
'menu_item' => 'entries',
|
||||
'fieldsets' => $fieldsets,
|
||||
'current_id' => $this->getEntryID($query),
|
||||
'parts' => $parts,
|
||||
'i' => count($parts),
|
||||
'last' => Arr::last($parts),
|
||||
'type' => $type,
|
||||
'links' => [
|
||||
'entries' => [
|
||||
'link' => $this->router->pathFor('admin.entries.index'),
|
||||
|
@@ -785,3 +785,14 @@ ul.messenger-theme-flat .messenger-message-slot.messenger-first.messenger-last .
|
||||
.bootstrap-datetimepicker-widget table th {
|
||||
border-color: #ced4da;
|
||||
}
|
||||
|
||||
.fieldset-selector {
|
||||
> li {
|
||||
> a {
|
||||
&:hover {
|
||||
color: $navbar-item-text-color;
|
||||
background: $navbar-background-color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -533,3 +533,30 @@ textarea.form-control.code-editor {
|
||||
outline: none!important;
|
||||
box-shadow: none!important;
|
||||
}
|
||||
|
||||
.fieldset-selector {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
||||
> li {
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
||||
> a {
|
||||
display: block;
|
||||
padding: 18px;
|
||||
|
||||
&:hover {
|
||||
color: #b7b9bd;
|
||||
background: #3b404b;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.fieldset-thumbnail {
|
||||
font-size: 42px;
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@ admin_profile: "Profile"
|
||||
admin_view_site: "View Site"
|
||||
admin_snippets: "Snippets"
|
||||
admin_not_installed: "Not Installed"
|
||||
admin_select_entry_type: "Select Entry Type"
|
||||
admin_off: "Off"
|
||||
admin_on: "On"
|
||||
admin_add: "Add"
|
||||
|
@@ -4,6 +4,7 @@
|
||||
<form method="post" id="form">
|
||||
{{ csrf() }}
|
||||
<input type="hidden" id="current_id" name="current_id" value="{{ current_id }}">
|
||||
<input type="hidden" id="fieldset" name="fieldset" value="{{ type }}">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
@@ -16,29 +17,26 @@
|
||||
<input type="text" id="id" 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_entry_name') }}</small>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{{ tr('admin_type') }}</label>
|
||||
<select class="form-control" name="fieldset">
|
||||
{% for key, fieldset in fieldsets %}
|
||||
<option value="{{ key }}">{{ fieldset }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<small class="form-text text-muted">{{ tr('admin_help_text_for_entry_type') }}</small>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{{ tr('admin_routable') }}</label>
|
||||
<select class="form-control" name="routable">
|
||||
<option value="1" selected>{{ tr('admin_yes') }}</option>
|
||||
<option value="0">{{ tr('admin_no') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{{ tr('admin_visibility') }}</label>
|
||||
<select class="form-control" name="visibility">
|
||||
<option value="visible" selected>{{ tr('admin_visible') }}</option>
|
||||
<option value="hidden">{{ tr('admin_hidden') }}</option>
|
||||
<option value="draft">{{ tr('admin_draft') }}</option>
|
||||
</select>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label>{{ tr('admin_routable') }}</label>
|
||||
<select class="form-control" name="routable">
|
||||
<option value="1" selected>{{ tr('admin_yes') }}</option>
|
||||
<option value="0">{{ tr('admin_no') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label>{{ tr('admin_visibility') }}</label>
|
||||
<select class="form-control" name="visibility">
|
||||
<option value="visible" selected>{{ tr('admin_visible') }}</option>
|
||||
<option value="hidden">{{ tr('admin_hidden') }}</option>
|
||||
<option value="draft">{{ tr('admin_draft') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" id="create" name="create" value="{{ tr('admin_create') }}" class="btn btn-black">
|
||||
|
@@ -96,4 +96,29 @@
|
||||
<a href="{{ path_for('admin.entries.add') }}?id={{ entry.slug }}" class="btn">{{ tr('admin_create_new_entry') }}</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="modal fade" id="selectEntryTypeModal" tabindex="-1" role="dialog" aria-labelledby="selectEntryTypeModal" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="selectEntryTypeModalLabel">{{ tr('admin_select_entry_type') }}</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<ul class="fieldset-selector row">
|
||||
{% for key, fieldset in fieldsets %}
|
||||
<li class="col-md-4">
|
||||
<a href="{{ path_for('admin.entries.add') }}?id={{ id_current }}&type={{ key }}" class="fieldset-item">
|
||||
<div class="fieldset-thumbnail">{% if fieldset.icon %}<i class="{{ fieldset.icon }}"></i>{% else %}<i class="far fa-file-alt"></i>{% endif %}</div>
|
||||
<div class="fieldset-title">{{ fieldset.title }}</div>
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
Reference in New Issue
Block a user