mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-18 03:00:56 +01:00
Fixed issue with array field nested in list that were losing their index order when the list reordered
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
* Fixed 2FA regenerate for Flex Users
|
* Fixed 2FA regenerate for Flex Users
|
||||||
* Added missing closing </li> in language loops
|
* Added missing closing </li> in language loops
|
||||||
* Fixed issue with nested `list` fields both utilizing the custom `key` functionality
|
* Fixed issue with nested `list` fields both utilizing the custom `key` functionality
|
||||||
|
* Fixed issue with `array` field nested in `list` that were losing their index order when the list reordered
|
||||||
|
|
||||||
# v1.9.7
|
# v1.9.7
|
||||||
## 06/21/2019
|
## 06/21/2019
|
||||||
|
|||||||
@@ -177,11 +177,20 @@ export default class CollectionsField {
|
|||||||
item.find('[' + prop + '], [_' + prop + ']').each(function() {
|
item.find('[' + prop + '], [_' + prop + ']').each(function() {
|
||||||
let element = $(this);
|
let element = $(this);
|
||||||
let indexes = [];
|
let indexes = [];
|
||||||
|
let array_index = null;
|
||||||
let regexps = [
|
let regexps = [
|
||||||
new RegExp('\\[(\\d+|\\*|' + currentKey + ')\\]', 'g'),
|
new RegExp('\\[(\\d+|\\*|' + currentKey + ')\\]', 'g'),
|
||||||
new RegExp('\\.(\\d+|\\*|' + currentKey + ')\\.', 'g')
|
new RegExp('\\.(\\d+|\\*|' + currentKey + ')\\.', 'g')
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// special case to preserve array field index keys
|
||||||
|
if (prop === 'name' && element.data('gravArrayType')) {
|
||||||
|
const match_index = element.attr(prop).match(/\[\d+\]$/);
|
||||||
|
if (match_index) {
|
||||||
|
array_index = match_index[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (hasCustomKey && !observedValue) {
|
if (hasCustomKey && !observedValue) {
|
||||||
element.attr(`_${prop}`, element.attr(prop));
|
element.attr(`_${prop}`, element.attr(prop));
|
||||||
element.attr(prop, null);
|
element.attr(prop, null);
|
||||||
@@ -198,8 +207,11 @@ export default class CollectionsField {
|
|||||||
|
|
||||||
let matchedKey = currentKey;
|
let matchedKey = currentKey;
|
||||||
let replaced = element.attr(prop).replace(regexps[0], (/* str, p1, offset */) => {
|
let replaced = element.attr(prop).replace(regexps[0], (/* str, p1, offset */) => {
|
||||||
|
let extras = '';
|
||||||
|
if (array_index) { extras = array_index; }
|
||||||
|
|
||||||
matchedKey = indexes.shift() || matchedKey;
|
matchedKey = indexes.shift() || matchedKey;
|
||||||
return `[${matchedKey}]`;
|
return `[${matchedKey}]${extras}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
replaced = replaced.replace(regexps[1], (/* str, p1, offset */) => {
|
replaced = replaced.replace(regexps[1], (/* str, p1, offset */) => {
|
||||||
|
|||||||
2
themes/grav/js/admin.min.js
vendored
2
themes/grav/js/admin.min.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user