(core) fix up newRec when column names change; autocomplete after newRec

Summary: This treats newRec in the same way as rec in access formulas.

Test Plan: updated test for column renames; autocomplete checked manually.

Reviewers: dsagal

Reviewed By: dsagal

Differential Revision: https://phab.getgrist.com/D2810
pull/23/head
Paul Fitzpatrick 3 years ago
parent 37521a3612
commit e55fba24e7

@ -47,7 +47,7 @@ export function aclFormulaEditor(options: ACLFormulaOptions) {
// Some grist-specific constants:
'OWNER', 'EDITOR', 'VIEWER',
// The common variables.
'user', 'rec',
'user', 'rec', 'newRec',
// Other completions that depend on doc schema or other rules.
...options.getSuggestions(prefix),
];

@ -1091,6 +1091,7 @@ class ObsRulePart extends Disposable {
private _completions = Computed.create<string[]>(this, (use) => [
...use(this._ruleSet.accessRules.userAttrChoices).map(opt => opt.label),
...this._ruleSet.getValidColIds().map(colId => `rec.${colId}`),
...this._ruleSet.getValidColIds().map(colId => `newRec.${colId}`),
]);
// The permission bits.

@ -131,7 +131,7 @@ class _EntityCollector(_TreeConverter):
parent = self.visit(node.value)
# We recognize a couple of specific patterns for entities that may be affected by renames.
if parent == ['Name', 'rec']:
if parent == ['Name', 'rec'] or parent == ['Name', 'newRec']:
# rec.COL refers to the column from the table that the rule is on.
self.entities.append(NamedEntity('recCol', node.last_token.startpos, node.attr, None))
if parent == ['Name', 'user']:

@ -1139,6 +1139,12 @@ export async function getTestState(): Promise<TestState> {
return state || {};
}
// Get the full text from an element containing an Ace editor.
export async function getAceText(el: WebElement): Promise<string> {
return driver.executeScript('return ace.edit(arguments[0]).getValue()',
el.find('.ace_editor'));
}
// All users ('user1', etc.) that can be logged in using Session.user().
export enum TestUserEnum {
user1 = 'chimpy',

Loading…
Cancel
Save