Fixed issue where Adding a new page and canceling from within Editing would alter the Parent location of the edited page (fixes #2067)

This commit is contained in:
Djamil Legato
2021-03-22 17:12:37 -07:00
parent e14e72958f
commit c61d91c7a8
3 changed files with 22 additions and 6 deletions

View File

@@ -1,3 +1,9 @@
# v1.10.9
## mm/dd/2021
1. [](#bugfix)
* Fixed issue where Adding a new page and canceling from within Editing would alter the Parent location of the edited page [#2067](https://github.com/getgrav/grav-plugin-admin/issues/2067)
# v1.10.8
## 03/19/2021

View File

@@ -198,6 +198,7 @@ $(document).on('click', '[data-parents]', (event) => {
const target = $(event.currentTarget);
let field = target.closest('.parents-wrapper').find('input[name]');
let fieldName = field.attr('name');
let selectedField = null;
if (!field.length) {
fieldName = target.data('parents');
@@ -235,7 +236,7 @@ $(document).on('click', '[data-parents]', (event) => {
}
modal.data('parents', Instances[`${fieldName}-${modal.data('remodalId')}`]);
modal.data('parents-selectedField', field);
}
});
});
@@ -244,6 +245,7 @@ $(document).on('click', '[data-parents]', (event) => {
$(document).on('click', '[data-remodal-id].parents-container [data-parents-select]', (event) => {
const modal = $(event.currentTarget).closest('[data-remodal-id]');
const parents = modal.data('parents');
const selectedField = modal.data('parentsSelectedField');
const finder = parents.finder;
const field = parents.field;
const parentLabel = parents.parentLabel;
@@ -252,11 +254,19 @@ $(document).on('click', '[data-remodal-id].parents-container [data-parents-selec
const value = selection._item[finder.config.valueKey];
const name = selection._item[finder.config.labelKey];
console.log('click [data-parents-select]', selectedField);
if (selectedField.closest('.remodal').length) {
const index = field.index(selectedField) - 1;
selectedField.val(value);
$(parentLabel[index]).text(value);
$(parentName[index]).text(name);
} else {
field.val(value);
parentLabel.text(value);
parentName.text(name);
finder.config.defaultPath = value;
}
const remodal = $.remodal.lookup[$(`[data-remodal-id="${modal.data('remodalId')}"]`).data('remodal')];
remodal.close();
});

File diff suppressed because one or more lines are too long