wagtail icon indicating copy to clipboard operation
wagtail copied to clipboard

Fix the order of InlinePanel with min_num argument

Open elhussienalmasri opened this issue 10 months ago • 2 comments

Fixes #9391

this issue because the the initial forms not have value attribute. if "min_num" is any number and after that another item added, this item become first despite the number of "min_num". but if any action occurs to any item of initial forms for example the item moved up or down , in this case the item become has attribute, and this issue not exist in this case.

After Before
After Before

elhussienalmasri avatar Apr 23 '24 16:04 elhussienalmasri

another way to set "value" attribute to the initial forms , but in the client , and solve this issue in the same idea, in the constructor of class "InlinePanel" , just add this code :

for (let i = 0; i < this.formCount; i++) {
    const newChildPrefix = this.opts.emptyChildFormPrefix.replace(
        /__prefix__/g,
        i,
    );
    if ($('#id_' + newChildPrefix + '-ORDER').attr("value") !== undefined) {
        break
    }

    $('#id_' + newChildPrefix + '-ORDER')
        .val(i + 1);
}

elhussienalmasri avatar Apr 23 '24 16:04 elhussienalmasri

Manage this branch in Squash

Test this branch here: https://elhussienalmasrifix-the-order-kw2c9.squash.io

squash-labs[bot] avatar Apr 23 '24 16:04 squash-labs[bot]