gristlabs_grist-core/app/client/components
Alex Hall 792565976a (core) Show example values in formula autocomplete
Summary:
This diff adds a preview of the value of certain autocomplete suggestions, especially of the form `$foo.bar` or `user.email`. The main initial motivation was to show the difference between `$Ref` and `$Ref.DisplayCol`, but the feature is more general.

The client now sends the row ID of the row being edited (along with the table and column IDs which were already sent) to the server to fetch autocomplete suggestions. The returned suggestions are now tuples `(suggestion, example_value)` where `example_value` is a string or null. The example value is simply obtained by evaluating (in a controlled way) the suggestion in the context of the given record and the current user. The string representation is similar to the standard `repr` but dates and datetimes are formatted, and the whole thing is truncated for efficiency.

The example values are shown in the autocomplete popup separated from the actual suggestion by a number of spaces calculated to:

1. Clearly separate the suggestion from the values
2. Left-align the example values in most cases
3. Avoid having so much space such that connecting suggestions and values becomes visually difficult.

The tokenization of the row is then tweaked to show the example in light grey to deemphasise it.

Main discussion where the above was decided: https://grist.slack.com/archives/CDHABLZJT/p1661795588100009

The diff also includes various other small improvements and fixes:

- The autocomplete popup is much wider to make room for long suggestions, particularly lookups, as pointed out in https://phab.getgrist.com/D3580#inline-41007. The wide popup is the reason a fancy solution was needed to position the example values. I didn't see a way to dynamically resize the popup based on suggestions, and it didn't seem like a good idea to try.
- The `grist` and `python` labels previously shown on the right are removed. They were not helpful (https://grist.slack.com/archives/CDHABLZJT/p1659697086155179) and would get in the way of the example values.
- Fixed a bug in our custom tokenization that caused function arguments to be weirdly truncated in the middle: https://grist.slack.com/archives/CDHABLZJT/p1661956353699169?thread_ts=1661953258.342739&cid=CDHABLZJT and https://grist.slack.com/archives/C069RUP71/p1659696778991339
- Hide suggestions involving helper columns like `$gristHelper_Display` or `Table.lookupRecords(gristHelper_Display=` (https://grist.slack.com/archives/CDHABLZJT/p1661953258342739). The former has been around for a while and seems to be a mistake. The fix is simply to use `is_visible_column` instead of `is_user_column`. Since the latter is not used anywhere else, and using it in the first place seems like a mistake more than anything else, I've also removed the function to prevent similar mistakes in the future.
- Don't suggest private columns as lookup arguments: https://grist.slack.com/archives/CDHABLZJT/p1662133416652499?thread_ts=1661795588.100009&cid=CDHABLZJT
- Only fetch fresh suggestions specifically after typing `lookupRecords(` or `lookupOne(` rather than just `(`, as this would needlessly hide function suggestions which could still be useful to see the arguments. However this only makes a difference when there are still multiple matching suggestions, otherwise Ace hides them anyway.

Test Plan: Extended and updated several Python and browser tests.

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D3611
2022-09-28 19:42:36 +02:00
..
AceEditor.css (core) Show example values in formula autocomplete 2022-09-28 19:42:36 +02:00
AceEditor.js (core) Show example values in formula autocomplete 2022-09-28 19:42:36 +02:00
AceEditorCompletions.ts (core) Show example values in formula autocomplete 2022-09-28 19:42:36 +02:00
ActionLog.css (core) Add dark mode to user preferences 2022-09-05 19:17:32 -07:00
ActionLog.ts (core) Faster builds all around. 2022-07-04 10:42:40 -04:00
Banner.ts (core) Add product for new personal plan 2022-07-26 11:33:23 -07:00
Base.js (core) move client code to core 2020-10-02 13:24:21 -04:00
BaseView2.ts (core) Copy column type and options when pasting into an empty column 2022-04-04 14:53:16 +02:00
BaseView.js (core) Showing a raw data section on a popup 2022-08-25 09:30:07 +02:00
CellPosition.ts (core) Draft cells 2021-05-25 21:14:49 +02:00
ChartView.css (core) move client code to core 2020-10-02 13:24:21 -04:00
ChartView.ts (core) Add dark mode to user preferences 2022-09-05 19:17:32 -07:00
ClientScope.ts (core) move client code to core 2020-10-02 13:24:21 -04:00
Clipboard.css (core) move client code to core 2020-10-02 13:24:21 -04:00
Clipboard.js (core) Trim trailing whitespace when pasting plain text 2021-11-04 01:26:47 +02:00
CodeEditorPanel.css (core) Add dark mode to user preferences 2022-09-05 19:17:32 -07:00
CodeEditorPanel.ts (core) another bundle of dependabot suggestions 2022-09-12 14:20:09 -04:00
ColumnFilters.css (core) Context menu for cards. 2021-06-29 15:29:56 +02:00
ColumnTransform.ts (core) Adding font options to the style picker 2022-04-07 20:35:03 +02:00
Comm.ts (core) Fix issue with 'UNEXPECTED ORDER OF CALLBACKS' in Client.ts. 2022-06-16 23:51:14 -04:00
commandList.js (core) Adding hide for multiple columns 2022-08-17 22:31:16 +02:00
commands.css (core) move client code to core 2020-10-02 13:24:21 -04:00
commands.js (core) Improve focus and keyboard shortcuts in modals. 2020-10-03 22:56:00 -04:00
CopySelection.ts (core) Copy column type and options when pasting into an empty column 2022-04-04 14:53:16 +02:00
Cursor.ts (core) Faster builds all around. 2022-07-04 10:42:40 -04:00
CursorMonitor.ts (core) Raw renames 2022-04-27 22:21:55 +02:00
CustomView.css (core) Fix CustomView css to take full height of widget on all browsers including Safari 2020-10-06 13:18:50 -04:00
CustomView.ts (core) Faster builds all around. 2022-07-04 10:42:40 -04:00
DataTables.ts (core) Add dark mode to user preferences 2022-09-05 19:17:32 -07:00
DetailView.css (core) Add dark mode to user preferences 2022-09-05 19:17:32 -07:00
DetailView.js (core) Adding new command Duplicate rows 2022-04-20 17:29:48 +02:00
DocComm.ts (core) add an access token mechanism to help with attachments in custom widgets 2022-07-19 11:55:18 -04:00
DocConfigTab.js (core) move client code to core 2020-10-02 13:24:21 -04:00
DocumentUsage.ts (core) Add dark mode to user preferences 2022-09-05 19:17:32 -07:00
Drafts.ts (core) Add dark mode to user preferences 2022-09-05 19:17:32 -07:00
duplicatePage.ts (core) Speed up and upgrade build. 2022-06-27 16:10:10 -04:00
EditorMonitor.ts (core) Raw renames 2022-04-27 22:21:55 +02:00
EmbedForm.css (core) move client code to core 2020-10-02 13:24:21 -04:00
FieldConfigTab.css (core) move client code to core 2020-10-02 13:24:21 -04:00
FormulaTransform.ts (core) Add dark mode to user preferences 2022-09-05 19:17:32 -07:00
GridView.css (core) Add dark mode to user preferences 2022-09-05 19:17:32 -07:00
GridView.js (core) Clearing selection after rows or cols were removed 2022-09-12 08:40:07 +02:00
GristDoc.css (core) move client code to core 2020-10-02 13:24:21 -04:00
GristDoc.ts Export xlsx #256 (#270) 2022-09-14 14:55:44 -04:00
GristWSConnection.ts (core) Fix issue with 'UNEXPECTED ORDER OF CALLBACKS' in Client.ts. 2022-06-16 23:51:14 -04:00
Importer.ts (core) Add dark mode to user preferences 2022-09-05 19:17:32 -07:00
Layout.css (core) Collapse inactive view sections on mobile screens. 2021-02-09 09:17:32 -05:00
Layout.js (core) Fixing bug with undoing page delation with a custom layout 2021-12-20 19:32:14 +01:00
LayoutEditor.css (core) move client code to core 2020-10-02 13:24:21 -04:00
LayoutEditor.js (core) move client code to core 2020-10-02 13:24:21 -04:00
LayoutPreview.css (core) move client code to core 2020-10-02 13:24:21 -04:00
LayoutPreview.js (core) move client code to core 2020-10-02 13:24:21 -04:00
LinkingState.ts (core) Fix summary table titles and linking when source table is hidden by ACL 2022-09-01 19:14:47 +02:00
Login.css (core) move client code to core 2020-10-02 13:24:21 -04:00
ParseOptions.ts (core) Add dark mode to user preferences 2022-09-05 19:17:32 -07:00
PluginScreen.ts (core) Show proper message on empty Excel import, rather than a code error 2022-04-27 00:49:28 -04:00
Preferences.css (core) Add dark mode to user preferences 2022-09-05 19:17:32 -07:00
Printing.css (core) Improve printing of tables, fix printing of charts, add a browser test. 2020-10-12 16:04:18 -04:00
Printing.ts (core) Faster builds all around. 2022-07-04 10:42:40 -04:00
RawDataPage.ts (core) Add dark mode to user preferences 2022-09-05 19:17:32 -07:00
RecordLayout.css (core) Add dark mode to user preferences 2022-09-05 19:17:32 -07:00
RecordLayout.js (core) Showing a raw data section on a popup 2022-08-25 09:30:07 +02:00
RecordLayoutEditor.js (core) move client code to core 2020-10-02 13:24:21 -04:00
RefSelect.ts (core) Reference columns weren't added to Raw Data Views 2022-07-07 17:07:13 +02:00
SearchBar.css (core) move client code to core 2020-10-02 13:24:21 -04:00
Selector.js (core) Fixing bug with first click on windows 2022-06-30 17:08:57 +02:00
TypeConversion.ts (core) Don't clear widget options when changing column type 2022-07-11 14:27:44 +02:00
TypeTransform.ts (core) Add dark mode to user preferences 2022-09-05 19:17:32 -07:00
UndoStack.ts (core) Change UndoStack._linkMap to store an array of action groups for each linkId 2022-01-20 19:00:01 +02:00
UnsavedChanges.ts (core) support ?embed=true and &style=light for a clean embed experience 2020-08-14 13:34:38 -04:00
ValidationPanel.css (core) move client code to core 2020-10-02 13:24:21 -04:00
ValidationPanel.js (core) move client code to core 2020-10-02 13:24:21 -04:00
viewCommon.css (core) Adding selection layer on top of field element 2022-09-08 12:38:18 +02:00
viewCommon.js (core) Skip saving column resizes in read-only mode 2021-12-07 14:37:25 -08:00
ViewConfigTab.css (core) move client code to core 2020-10-02 13:24:21 -04:00
ViewConfigTab.js (core) Add dark mode to user preferences 2022-09-05 19:17:32 -07:00
ViewLayout.css (core) Add dark mode to user preferences 2022-09-05 19:17:32 -07:00
ViewLayout.ts (core) Add dark mode to user preferences 2022-09-05 19:17:32 -07:00
ViewLinker.css (core) move client code to core 2020-10-02 13:24:21 -04:00
ViewPane.ts (core) Implementing row conditional formatting 2022-08-09 20:11:36 +02:00
WidgetFrame.ts (core) add an access token mechanism to help with attachments in custom widgets 2022-07-19 11:55:18 -04:00