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
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | 2925798-domain-sort-8.patch | 2.55 KB | agentrickard |
| #6 | 2925798-domain-sort-6.patch | 1.1 KB | agentrickard |
| #5 | 2925798-domain-sort.patch | 725 bytes | agentrickard |
Comments
Comment #2
alanhdev commentedComment #3
agentrickardWell, 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).
Comment #4
agentrickardI 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)?
Comment #5
agentrickardOdd. Hard resetting those values doesn't seem to work.
Comment #6
agentrickardStill could use a real test.
Comment #7
agentrickardThis breaks if you don't use the draggable method but 'show row weights' and order them through the select list.
Comment #8
agentrickardFixed that. Still needs tests.
Comment #9
agentrickardThe tests have been added -- https://github.com/agentrickard/domain/pull/385
Comment #10
agentrickardComment #11
agentrickardNot sure this will work with pagination as written, which happens at 50 records by default.
Comment #12
agentrickardIt will not. Corrected in the PR. Needs a test.
Comment #13
agentrickardFixed, with tests.