Initial setup for new copy page modal (#1738)

This commit is contained in:
Djamil Legato
2021-04-20 22:17:21 -07:00
parent a6b8732c39
commit 38af7a75fe
6 changed files with 90 additions and 3 deletions

View File

@@ -7,6 +7,7 @@
* Removed sourcemaps references from fork-awesome.min.css [#2122](https://github.com/getgrav/grav-plugin-admin/issues/2122)
* Support native spell checkers in CodeMirror editor [#1266](https://github.com/getgrav/grav-plugin-admin/issues/1266)
* Added new 'Content Highlight' color to presets
* Copying Pages now prompts a dedicated modal that allows for picking title, folder name, parent location, page template and visibility [#1738](https://github.com/getgrav/grav-plugin-admin/issues/1738)
1. [](#bugfix)
* Moved preset CSS compile to earlier in the process to ensure compilation happens in time.
* Prevent Save actions from Flex Objects to trigger the unsaved unload notice [#2125](https://github.com/getgrav/grav-plugin-admin/issues/2125)

View File

@@ -0,0 +1,63 @@
rules:
slug:
pattern: '[a-zA-Zа-яA-Я0-9_\-]+'
min: 1
max: 200
form:
validation: loose
fields:
section:
type: section
title: PLUGIN_ADMIN.COPY_PAGE
title:
type: text
label: PLUGIN_ADMIN.PAGE_TITLE
help: PLUGIN_ADMIN.PAGE_TITLE_HELP
validate:
required: true
folder:
type: text
label: PLUGIN_ADMIN.FOLDER_NAME
help: PLUGIN_ADMIN.FOLDER_NAME_HELP
validate:
rule: slug
required: true
route:
type: parents
label: PLUGIN_ADMIN.PARENT_PAGE
classes: fancy
validate:
required: true
name:
type: select
classes: fancy
label: PLUGIN_ADMIN.PAGE_FILE
help: PLUGIN_ADMIN.PAGE_FILE_HELP
data-options@: '\Grav\Plugin\AdminPlugin::pagesTypes'
data-default@: '\Grav\Plugin\Admin\Admin::getLastPageName'
validate:
required: true
visible:
type: toggle
label: PLUGIN_ADMIN.VISIBLE
help: PLUGIN_ADMIN.VISIBLE_HELP
highlight: ''
default: ''
options:
'': Auto
1: PLUGIN_ADMIN.YES
0: PLUGIN_ADMIN.NO
validate:
type: bool
required: true
blueprint:
type: blueprint

View File

@@ -548,6 +548,7 @@ PLUGIN_ADMIN:
REVERSE_PROXY_HELP: "Enable this if you are behind a reverse proxy and you are having trouble with URLs containing incorrect ports"
INVALID_FRONTMATTER_COULD_NOT_SAVE: "Invalid frontmatter, could not save"
ADD_FOLDER: "Add Folder"
COPY_PAGE: "Copy Page"
PROXY_URL: "Proxy URL"
PROXY_URL_HELP: "Enter the proxy HOST or IP and PORT"
NOTHING_TO_SAVE: "Nothing to Save"

View File

@@ -4,8 +4,8 @@ import request from '../../utils/request';
import { config } from 'grav-config';
let custom = false;
let folder = $('[data-remodal-id="modal"] input[name="data[folder]"], [data-remodal-id="module"] input[name="data[folder]"]');
let title = $('[data-remodal-id="modal"] input[name="data[title]"], [data-remodal-id="module"] input[name="data[title]"]');
let folder = $('[data-remodal-id="modal"] input[name="data[folder]"], [data-remodal-id="module"] input[name="data[folder]"], [data-remodal-id="modal-page-copy"] input[name="data[folder]"]');
let title = $('[data-remodal-id="modal"] input[name="data[title]"], [data-remodal-id="module"] input[name="data[title]"], [data-remodal-id="modal-page-copy"] input[name="data[title]"]');
let getFields = (type, target) => {
target = $(target);
let query = `[data-remodal-id="${target.closest('[data-remodal-id]').data('remodal-id')}"]`;

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,22 @@
{% set form_id = form_id ? form_id : 'blueprints' %}
{% set scope = scope ?: 'data.' %}
<form {% if form_action %}action="{{ form_action }}"{% endif %} id="{{ form_id }}" method="post" data-grav-form="{{ form_id }}" {% if form.novalidate %}novalidate{% endif %} data-grav-keepalive="true">
{% for field in blueprints.fields %}
{% if field.type %}
{% set value = field.name ? (form.value(field.name) ?? data.value(field.name)) : data.toArray %}
<div class="block block-{{field.type}}">
{% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %}
</div>
{% endif %}
{% endfor %}
<input type="hidden" name="task" value="continue" />
<div class="button-bar">
<button data-remodal-action="cancel" class="button secondary remodal-cancel"><i class="fa fa-fw fa-close"></i> Cancel</button>
<button class="button success">{{ "PLUGIN_ADMIN.CONTINUE"|tu }}</button>
</div>
{{ nonce_field('admin-form', 'admin-nonce')|raw }}
</form>