WIP & BUGGY: WebUI: Add additional keyboard handlers (e.g. Insert, Delete, Edit...) #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
REQUIRES REVIEW/MODIFICATION. DO NOT MERGE.
I'm not happy about this - but, in my defence, I don't know what I'm doing :)
This adds:
(8. Ctrl + a == Selects displayed record(s) - implemented previously)
This seems to (mostly) work, but it feels ugly and is buggy. All debugging statements left in.
Issues I can see:
The grids already use PgUp/PgDn within the displayed page, so we can't (shouldn't) interfere with these. For example, if you have a scrolling page (maybe 100 items) then PgUp/PgDn moves through it, not forwards/backwards a page. Similarly, Home/End move to the top and bottom of the displayed page, not to the top/bottom of the store.
However, these keys do work if the focus is on the TextBox in the Paging Toolbar (where you'd type a new page number). So I've implemented this as a shift-focus keystroke instead of over-riding the keys: Alt+p moves focus to this text box, and then PgUp/PgDn changes page, with Home and End moving to the first and last page respectively.
The way that the tabbed panel works is that a key event passes through all the tabs in turn until it reaches the active one. So, a keystroke in "Failed Recordings" triggers three events: one for Upcoming, one for Finished, and a final one when arriving at Failed. So we need to find a way to limit processing to the current (active) tab.
I've done this by simply checking to see that a grid is rendered in the panel, as it will only be rendered in the active one.
Save/Undo only make sense if there's something to Save or Undo, so I've tested to see if these buttons have been scoped in (enabled) before triggering the appropriate handler. That leaves the grid to decide if anything has changed, rather than checking again.
The same logic should probably hold to the other buttons - Add, Delete. They're normally there, but you can't guaranteed this.
However, there are some serious bugs:
It's a global keymap, so these keystrokes apply everywhere. They should be limited to the DVR screens, or otherwise to tabs that make sense (e.g. this will intercept DEL on any text field, which is utter rubbish - you go to erase, say, the server name in Configuration -> General and it fires a deletion event associated with a non-existent Button).
This highlights that the button check (if !button.disabled) doesn't work. Something in the way the tabs are organised means that somewhere this button is enabled once something has changed, so this test passes. It has to be limited to the active/displayed tab.
A better way might be to simply have the key bindings on the Button objects, but I don't know that's possible. ExtJS 3.4 seems to have overlooked keyboard input for the most part.
There seems to be an issue with "once selected, always selected". So, if you select an item in Upcoming Recordings, press F2 to Edit, dismiss, then tab away to, say, "Failed", then F2 no longer does anything - which is correct, as there's no selected record to Edit.
However, if you go back to Upcoming and press F2 again then the previously-selected record will pop up, even if no rows are selected... if you select a new row, then F2 will pop up a dialog for both of them. This will repeat for every row you select, so something's remembering the selection.
==> this has serious implications for 'Delete' if that would erase any and all previously-selected records on a tab