Skip to content

Commit

Permalink
When creating a new page, automatically select the Page Template base…
Browse files Browse the repository at this point in the history
…d on Parent Page Child Type (fixes #1008)
  • Loading branch information
w00fz committed Mar 6, 2017
1 parent 2a7650e commit e42119f
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 43 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions themes/grav/app/pages/page/add.js
Original file line number Diff line number Diff line change
@@ -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]"]');
Expand Down Expand Up @@ -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);
});
});
32 changes: 16 additions & 16 deletions themes/grav/js/admin.min.js

Large diffs are not rendered by default.

52 changes: 25 additions & 27 deletions themes/grav/js/vendor.min.js

Large diffs are not rendered by default.

0 comments on commit e42119f

Please sign in to comment.