Problem/Motivation

Domains can be sorted on the /admin/config/domain page and doing this results in weights being assigned. In my use case, I currently have 5 domains. Sorting the domains using the draggable table and saving sets weight values from -10 to -6 on the domains. If I now edit a domain by following the edit link, the weight select is populated with '-6' as the delta is calculated as the number of domains +1.

Saving the domain results in the sort order being corrupted as the edited domain will always be pushed to the bottom of the list.

Proposed resolution

The delta calculated in domain/domain/src/DomainForm.php should be based on the currently assigned maximum absolute value +1 so, in my case, the delta should be 11 giving a range from -11 to +11

Comments

Alan-H created an issue. See original summary.

alanhdev’s picture

Title: Saving domain on edit page may result in undesired domain msort order change » Saving domain on edit page may result in undesired domain sort order change
agentrickard’s picture

Well, that's unexepected. Can you work up a patch? I would guess we have to get the weights of all domains for this calculation and take the abs(HIGHEST).

agentrickard’s picture

I started to look at this and I'm torn. Ideally, the draggable table would not reset values to the negative range.

Can we force those to go back to a count-based sequence (0 - 4 or 1 - 5 in your case)?

agentrickard’s picture

Status: Active » Needs work
StatusFileSize
new725 bytes

Odd. Hard resetting those values doesn't seem to work.

agentrickard’s picture

StatusFileSize
new1.1 KB

Still could use a real test.

agentrickard’s picture

This breaks if you don't use the draggable method but 'show row weights' and order them through the select list.

agentrickard’s picture

StatusFileSize
new2.55 KB

Fixed that. Still needs tests.

agentrickard’s picture

agentrickard’s picture

Status: Needs work » Needs review
agentrickard’s picture

Not sure this will work with pagination as written, which happens at 50 records by default.

agentrickard’s picture

It will not. Corrected in the PR. Needs a test.

agentrickard’s picture

Status: Needs review » Fixed

Fixed, with tests.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.