In #2574969: Add a Views-like UI for adding fields we are revamping the fields UI to be more usable (and not crash on large sites). I tried to implement it similar to the Views UI, in that changes are first being made and remembered across page requests, but then still need to be explicitly saved once again (and can be discarded until then).
The code is almost completely there (in that issue, not yet committed), but not quite working. Since it isn't integral to that other issue, though, which is so large and invasive that it should be committed ASAP, the "unsaved changes" part will be solved in this follow-up issue.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 2640982-9--fix_fields_ui_unsaved_changes.patch | 48.76 KB | drunken monkey |
Comments
Comment #2
drunken monkeyWhile I now found the problem and was able to fix it (as well as a few others that were previously covered), I ran into difficulties caused (once again) by our permanent caching of the index's fields. Specifically, even after pressing "Cancel" on the "Fields" form, the discarded changes were afterwards still displayed (and used internally) as the current index state until you cleared the cache. And while that would easily fixed by just resetting the cache when discarding the changes, this also means that those changes will be already visible throughout the code on pages other than the Fields UI, which completely defeats the purpose and is bound to lead to complicated bugs.
So, instead of fixing all of this here, I think we should first solve #2638116: Clean up caching of Index class method results (especially fields), which will hopefully put an end to all those problems, and then here only fix the problems specific to this functionality.
Attaching a WIP patch to later pick things up at this point. (Please don't look at the
routing.ymlchanges, it's too embarassing.) The tests still need to be adapted to expect this behavior, and to also test for it.Comment #3
drunken monkeyIn the tests, we should also be sure to check that discarding changes works fine, parallel changes to other parts of the index will be reflected correctly and that the unsaved changes don't appear anywhere else in the UI.
Comment #4
drunken monkeyComment #5
drunken monkeyComment #6
drunken monkeyTime to finally tackle this.
Comment #7
drunken monkeyOK, this should finally fix it, and comes with tests to prove it.
(Contains #2727697-3: Changes to the index are discarded when it is serialized, since that's needed.)
Comment #8
borisson_I just went trough this and it looks good, the test is very readable and it passes, so that's great.
I'm happy with the patch, but I do have some very small nitpicks. But not wanting to hold up the issue for that.
Can we typehint on the DateFormatterInterface here instead?
Interface here as well.
Comment #9
drunken monkeyNeeded a re-roll anyways, so I also corrected the class name use.
Comment #10
borisson_Comment #12
drunken monkeyGreat, thanks for reviewing!
Committed.
Comment #13
drunken monkey