(core) Add shortcut for opening Record Card

Summary: Also adds tests for previously untested Record Card behavior.

Test Plan: Browser tests.

Reviewers: jarek

Reviewed By: jarek

Differential Revision: https://phab.getgrist.com/D4136
This commit is contained in:
George Gevoian
2023-12-08 00:59:42 -05:00
parent d0318af39b
commit 7e05284cf2
12 changed files with 376 additions and 21 deletions

View File

@@ -228,7 +228,7 @@ BaseView.commonCommands = {
this.scrollToCursor(true).catch(reportError);
this.activateEditorAtCursor({init});
},
editField: function() { closeRegisteredMenu(); this.scrollToCursor(true); this.activateEditorAtCursor(); },
editField: function(event) { closeRegisteredMenu(); this.scrollToCursor(true); this.activateEditorAtCursor({event}); },
insertRecordBefore: function() { this.insertRow(this.cursor.rowIndex()); },
insertRecordAfter: function() { this.insertRow(this.cursor.rowIndex() + 1); },
@@ -243,6 +243,12 @@ BaseView.commonCommands = {
filterByThisCellValue: function() { this.filterByThisCellValue(); },
duplicateRows: function() { this._duplicateRows().catch(reportError); },
openDiscussion: function() { this.openDiscussionAtCursor(); },
viewAsCard: function() {
/* Overridden by subclasses.
*
* This is still needed so that <space> doesn't trigger the `input` command
* if a subclass doesn't support opening the current record as a card. */
},
};
BaseView.prototype.selectedRows = function() {

View File

@@ -308,7 +308,7 @@ GridView.gridCommands = {
fieldEditSave: function() { this.cursor.rowIndex(this.cursor.rowIndex() + 1); },
// Re-define editField after fieldEditSave to make it take precedence for the Enter key.
editField: function() { closeRegisteredMenu(); this.scrollToCursor(true); this.activateEditorAtCursor(); },
editField: function(event) { closeRegisteredMenu(); this.scrollToCursor(true); this.activateEditorAtCursor({event}); },
insertFieldBefore: function(maybeKeyboardEvent) {
if (!maybeKeyboardEvent) {

View File

@@ -71,7 +71,6 @@ export type CommandName =
| 'input'
| 'editLabel'
| 'editLayout'
| 'toggleCheckbox'
| 'historyPrevious'
| 'historyNext'
| 'makeFormula'
@@ -273,7 +272,7 @@ export const groups: CommendGroupDef[] = [{
},
{
name: 'viewAsCard',
keys: [],
keys: ['Space'],
desc: 'Show the record card widget of the selected record',
},
]
@@ -483,10 +482,6 @@ export const groups: CommendGroupDef[] = [{
name: 'editLayout',
keys: [],
desc: 'Edit record layout'
}, {
name: 'toggleCheckbox',
keys: ['Enter', 'Space'],
desc: 'Toggles the value of checkbox cells'
}, {
name: 'historyPrevious',
keys: ['Up'],