mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-10-29 17:26:40 +01:00
looks like a fix for deeply nested sortable fields!
Signed-off-by: Andy Miller <rhuk@mac.com>
This commit is contained in:
@@ -231,11 +231,15 @@ export default class CollectionsField {
|
||||
// special case to preserve array field index keys
|
||||
if (prop === 'name' && element.data('gravArrayType')) {
|
||||
const match_index = element.attr(prop).match(/\[[0-9]{1,}\]$/);
|
||||
const pattern = element[0].closest('[data-grav-array-name]').dataset.gravArrayName;
|
||||
if (match_index && pattern) {
|
||||
const array_container = element[0].closest('[data-grav-array-name]');
|
||||
|
||||
if (match_index) {
|
||||
array_index = match_index[0];
|
||||
element.attr(prop, `${pattern}${match_index[0]}`);
|
||||
return;
|
||||
element.attr(prop, element.attr(prop).slice(0, array_index.length * -1));
|
||||
}
|
||||
|
||||
if (array_container && array_container.dataset && array_container.dataset.gravArrayName) {
|
||||
element.attr(prop, array_container.dataset.gravArrayName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,14 +259,8 @@ export default class CollectionsField {
|
||||
|
||||
let matchedKey = currentKey;
|
||||
let replaced = element.attr(prop).replace(regexps[0], (/* str, p1, offset */) => {
|
||||
let extras = '';
|
||||
if (array_index) {
|
||||
extras = array_index;
|
||||
console.log(indexes, extras);
|
||||
}
|
||||
|
||||
matchedKey = indexes.shift() || matchedKey;
|
||||
return `[${matchedKey}]${extras}`;
|
||||
return `[${matchedKey}]`;
|
||||
});
|
||||
|
||||
replaced = replaced.replace(regexps[1], (/* str, p1, offset */) => {
|
||||
@@ -270,7 +268,7 @@ export default class CollectionsField {
|
||||
return `.${matchedKey}.`;
|
||||
});
|
||||
|
||||
element.attr(prop, replaced);
|
||||
element.attr(prop, array_index ? `${replaced}${array_index}` : replaced);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
19
themes/grav/js/admin.min.js
vendored
19
themes/grav/js/admin.min.js
vendored
@@ -5723,11 +5723,13 @@ var CollectionsField = /*#__PURE__*/function () {
|
||||
// special case to preserve array field index keys
|
||||
if (prop === 'name' && element.data('gravArrayType')) {
|
||||
var match_index = element.attr(prop).match(/\[[0-9]{1,}\]$/);
|
||||
var pattern = element[0].closest('[data-grav-array-name]').dataset.gravArrayName;
|
||||
if (match_index && pattern) {
|
||||
var array_container = element[0].closest('[data-grav-array-name]');
|
||||
if (match_index) {
|
||||
array_index = match_index[0];
|
||||
element.attr(prop, "".concat(pattern).concat(match_index[0]));
|
||||
return;
|
||||
element.attr(prop, element.attr(prop).slice(0, array_index.length * -1));
|
||||
}
|
||||
if (array_container && array_container.dataset && array_container.dataset.gravArrayName) {
|
||||
element.attr(prop, array_container.dataset.gravArrayName);
|
||||
}
|
||||
}
|
||||
if (hasCustomKey && !observedValue) {
|
||||
@@ -5746,20 +5748,15 @@ var CollectionsField = /*#__PURE__*/function () {
|
||||
var matchedKey = currentKey;
|
||||
var replaced = element.attr(prop).replace(regexps[0], function /* str, p1, offset */
|
||||
() {
|
||||
var extras = '';
|
||||
if (array_index) {
|
||||
extras = array_index;
|
||||
console.log(indexes, extras);
|
||||
}
|
||||
matchedKey = indexes.shift() || matchedKey;
|
||||
return "[".concat(matchedKey, "]").concat(extras);
|
||||
return "[".concat(matchedKey, "]");
|
||||
});
|
||||
replaced = replaced.replace(regexps[1], function /* str, p1, offset */
|
||||
() {
|
||||
matchedKey = indexes.shift() || matchedKey;
|
||||
return ".".concat(matchedKey, ".");
|
||||
});
|
||||
element.attr(prop, replaced);
|
||||
element.attr(prop, array_index ? "".concat(replaced).concat(array_index) : replaced);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user