mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
792565976a
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 |
||
---|---|---|
.. | ||
functions | ||
imports | ||
acl_formula.py | ||
acl.py | ||
action_obj.py | ||
action_summary.py | ||
actions.py | ||
autocomplete_context.py | ||
codebuilder.py | ||
column.py | ||
csv_patch.py | ||
depend.py | ||
docactions.py | ||
docmodel.py | ||
engine.py | ||
friendly_errors.py | ||
gencode.py | ||
grist.py | ||
identifiers.py | ||
import_actions.py | ||
logger.py | ||
lookup.py | ||
main.py | ||
match_counter.py | ||
migrations.py | ||
moment.py | ||
objtypes.py | ||
parse_data.py | ||
records.py | ||
relabeling.py | ||
relation.py | ||
runtests.py | ||
sandbox.py | ||
schema.py | ||
sort_specs.py | ||
summary.py | ||
table_data_set.py | ||
table.py | ||
test_acl_formula.py | ||
test_acl_renames.py | ||
test_actions.py | ||
test_codebuilder.py | ||
test_column_actions.py | ||
test_completion.py | ||
test_default_formulas.py | ||
test_depend.py | ||
test_derived.py | ||
test_display_cols.py | ||
test_docmodel.py | ||
test_engine.py | ||
test_find_col.py | ||
test_formula_error.py | ||
test_formula_undo.py | ||
test_functions.py | ||
test_gencode.py | ||
test_import_actions.py | ||
test_logger.py | ||
test_lookups.py | ||
test_match_counter.py | ||
test_migrations.py | ||
test_moment.py | ||
test_record_func.py | ||
test_recordlist.py | ||
test_reflist_rel.py | ||
test_relabeling.py | ||
test_renames2.py | ||
test_renames.py | ||
test_replay.py | ||
test_requests.py | ||
test_rules_grid.py | ||
test_rules.py | ||
test_side_effects.py | ||
test_sort_spec.py | ||
test_summary2.py | ||
test_summary_choicelist.py | ||
test_summary_undo.py | ||
test_summary.py | ||
test_table_actions.py | ||
test_table_data_set.py | ||
test_temp_rowids.py | ||
test_textbuilder.py | ||
test_treeview.py | ||
test_trigger_formulas.py | ||
test_twowaymap.py | ||
test_types.py | ||
test_undo.py | ||
test_urllib_patch.py | ||
test_user.py | ||
test_useractions.py | ||
testsamples.py | ||
testscript.json | ||
testutil.py | ||
textbuilder.py | ||
treeview.py | ||
twowaymap.py | ||
tzdata.data | ||
urllib_patch.py | ||
user.py | ||
useractions.py | ||
usercode.py | ||
usertypes.py | ||
xmlrunner.py |