mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2026-05-06 07:17:16 +02:00
pagemediaselect is now an extend of filepicker. Add default for folder field. Fill changelog.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
* Unified JSON twig templates
|
||||
* Better error handling for 500 Internal Server Errors, when Fetch fails.
|
||||
* Reworked the `file` field. All files get uploaded via Ajax and are stored upon Save. This improves the Save task tremendously as now there is no longer the need of waiting for the files to finish uploading. Fully backward compatible, `file` field now includes also a `limit` and `filesize` option in the blueprints. The former determines how many files are allowed to be uploaded when in combination with `multiple: true` (default: 10), the latter determines the file size limit (in MB) allowed for each file (default: 5MB)
|
||||
* Added a new `filepicker` field, which allows to pick any file from an ajax-powered select box. The `pagemediaselect` field now internally uses the `filepicker` field to live-reload the available files, and to show image previews.
|
||||
1. [](#bugfix)
|
||||
* Curl fix for invalid cert errors with News Feed
|
||||
* Avoid requiring `admin.super` for ajax calls [#739](https://github.com/getgrav/grav-plugin-admin/issues/739)
|
||||
|
||||
@@ -349,10 +349,13 @@ class AdminController
|
||||
}
|
||||
|
||||
$data = $this->view == 'pages' ? $this->admin->page(true) : $this->prepareData([]);
|
||||
|
||||
$settings = $data->blueprints()->schema()->getProperty($this->post['name']);
|
||||
|
||||
$folder = $settings['folder'];
|
||||
if (isset($settings['folder'])) {
|
||||
$folder = $settings['folder'];
|
||||
} else {
|
||||
$folder = '@self';
|
||||
}
|
||||
|
||||
// Do not use self@ outside of pages
|
||||
if ($this->view != 'pages' && in_array($folder, ['@self', 'self@'])) {
|
||||
|
||||
@@ -1,41 +1,2 @@
|
||||
{% extends "forms/field.html.twig" %}
|
||||
{% extends "forms/fields/filepicker/filepicker.html.twig" %}
|
||||
|
||||
{% set options = {'': 'No file'} %}
|
||||
{% set files = admin.page.media.all %}
|
||||
{% for index, media in files %}
|
||||
{% set option = {(index): index} %}
|
||||
{% set options = options|merge(option) %}
|
||||
{% endfor %}
|
||||
|
||||
{% block global_attributes %}
|
||||
data-grav-selectize="{{ (field.selectize is defined ? field.selectize : {})|json_encode()|e('html_attr') }}"
|
||||
data-grav-field="select"
|
||||
data-grav-disabled="{{ files is empty ? 'true' : 'false' }}"
|
||||
data-grav-default="{{ field.default|json_encode()|e('html_attr') }}"
|
||||
{% endblock %}
|
||||
|
||||
{% block input %}
|
||||
{% if theme or plugin %}
|
||||
The "pagemediaselect" field cannot be used in Themes or Plugins Blueprints. It's intended to be used for Pages blueprints.
|
||||
Use the "file" type instead.
|
||||
{% else %}
|
||||
<div class="form-select-wrapper {{ field.size }}">
|
||||
<select name="{{ (scope ~ field.name)|fieldName ~ (field.multiple ? '[]' : '') }}"
|
||||
{% if field.classes is defined %}class="{{ field.classes }}" {% endif %}
|
||||
{% if field.id is defined %}id="{{ field.id|e }}" {% endif %}
|
||||
{% if field.style is defined %}style="{{ field.style|e }}" {% endif %}
|
||||
{% if field.disabled or files is empty or isDisabledToggleable %}disabled="disabled"{% endif %}
|
||||
{% if field.autofocus in ['on', 'true', 1] %}autofocus="autofocus"{% endif %}
|
||||
{% if field.novalidate in ['on', 'true', 1] %}novalidate="novalidate"{% endif %}
|
||||
{% if field.validate.required in ['on', 'true', 1] %}required="required"{% endif %}
|
||||
{% if field.multiple in ['on', 'true', 1] %}multiple="multiple"{% endif %}
|
||||
{% if field.form %}form="{{ field.form }}"{% endif %}
|
||||
>
|
||||
{% for key, text in options %}
|
||||
<option {% if key == value or (field.multiple and text in value) %}selected="selected"{% endif %} value="{{ field.multiple ? text : key }}">{% if grav.twig.twig.filters['tu'] is defined %}{{ text|tu }}{% else %}{{ text|t }}{% endif %}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
{% if files is empty %}Add files through the page media, or by dropping them in the page folder{% endif %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user