Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the order of InlinePanel with min_num argument #11889

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

elhussienalmasri
Copy link
Contributor

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
Copy link
Contributor Author

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);
}

Copy link

squash-labs bot commented Apr 23, 2024

Manage this branch in Squash

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

InlinePanels with min_num are incorrectly ordered on first save
1 participant