When creating a new page, automatically select the Page Template based on Parent Page Child Type (fixes #1008)

This commit is contained in:
Djamil Legato
2017-03-05 22:27:56 -08:00
parent 2a7650eab8
commit e42119f72e
4 changed files with 59 additions and 43 deletions

View File

@@ -5,6 +5,7 @@
* Added new **toolbox** with `Direct-Install` option via ZIP or URL.
* Added an option to reinstall a plugin/theme already installed [#984](https://github.com/getgrav/grav-plugin-admin/issues/984)
* Added a new **range field** [#995](https://github.com/getgrav/grav-plugin-admin/issues/995)
* When creating a new page, automatically select the Page Template based on Parent Page Child Type [#1008](https://github.com/getgrav/grav-plugin-admin/issues/1008)
1. [](#improved)
* Separated user details and avatar in separate twig to allow more granular overriding in plugins [#989](https://github.com/getgrav/grav-plugin-admin/issues/989)
* Nicer layout of themes list on wider screen

View File

@@ -1,5 +1,7 @@
import $ from 'jquery';
import '../../utils/jquery-utils';
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="modular"] input[name="data[folder]"]');
@@ -42,3 +44,18 @@ folder.on('input', (event) => {
});
folder.on('focus blur', (event) => getFields('title', event.currentTarget).title.trigger('input'));
$(document).on('change', '[name="data[route]"]', (event) => {
const rawroute = $(event.currentTarget).val();
const pageTemplate = $('[name="data[name]"]');
const URI = `${config.base_url_relative}/ajax.json/task${config.param_sep}getChildTypes`;
request(URI, {
method: 'post',
body: { rawroute }
}, (response) => {
const type = response.child_type || 'default';
pageTemplate.val(type);
pageTemplate.data('selectize').setValue(type);
});
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long