kopia lustrzana https://github.com/wagtail/wagtail
fix issue inline panel ordering
- fixes #9145
- no longer working with the new DOM structure introduced by #8983 / ca7f23d176
- instead of using `$.children` use `$.find` to find the panel's input fields but ensure we still supported nested fields by finding based on the child panel's id
pull/9157/head
rodzic
eff9e91ac8
commit
4b521c51cd
|
@ -25,15 +25,18 @@ function InlinePanel(opts) {
|
|||
|
||||
if (opts.canOrder) {
|
||||
$up.on('click', () => {
|
||||
const currentChildOrderElem = currentChild.children(
|
||||
'input[name$="-ORDER"]',
|
||||
const currentChildOrderElem = currentChild.find(
|
||||
`input[name="${prefix}-ORDER"]`,
|
||||
);
|
||||
const currentChildOrder = currentChildOrderElem.val();
|
||||
|
||||
/* find the previous visible 'inline_child' li before this one */
|
||||
const prevChild = currentChild.prevAll(':not(.deleted)').first();
|
||||
if (!prevChild.length) return;
|
||||
const prevChildOrderElem = prevChild.children('input[name$="-ORDER"]');
|
||||
const prevChildPrefix = prevChild[0].id.replace('inline_child_', '');
|
||||
const prevChildOrderElem = prevChild.find(
|
||||
`input[name="${prevChildPrefix}-ORDER"]`,
|
||||
);
|
||||
const prevChildOrder = prevChildOrderElem.val();
|
||||
|
||||
// async swap animation must run before the insertBefore line below, but doesn't need to finish first
|
||||
|
@ -47,15 +50,18 @@ function InlinePanel(opts) {
|
|||
});
|
||||
|
||||
$down.on('click', () => {
|
||||
const currentChildOrderElem = currentChild.children(
|
||||
'input[name$="-ORDER"]',
|
||||
const currentChildOrderElem = currentChild.find(
|
||||
`input[name="${prefix}-ORDER"]`,
|
||||
);
|
||||
const currentChildOrder = currentChildOrderElem.val();
|
||||
|
||||
/* find the next visible 'inline_child' li after this one */
|
||||
const nextChild = currentChild.nextAll(':not(.deleted)').first();
|
||||
if (!nextChild.length) return;
|
||||
const nextChildOrderElem = nextChild.children('input[name$="-ORDER"]');
|
||||
const nextChildPrefix = nextChild[0].id.replace('inline_child_', '');
|
||||
const nextChildOrderElem = nextChild.find(
|
||||
`input[name="${nextChildPrefix}-ORDER"]`,
|
||||
);
|
||||
const nextChildOrder = nextChildOrderElem.val();
|
||||
|
||||
// async swap animation must run before the insertAfter line below, but doesn't need to finish first
|
||||
|
|
Ładowanie…
Reference in New Issue