(core) Use table title instead of ID in ACL UI

Summary:
Use table titles (i.e. the raw data widget titles) in dropdowns and other parts of the Acess Rules page, instead of the table ID. This is particularly meant for summary tables which have/had an ID of the form `GristSummary_SourceTable_N`, but https://phab.getgrist.com/D3508 is changing that anyway.

The server method `getAclResources` now returns more metadata about each table so that the UI can display titles.

Test Plan: Extended and updated `nbrowser/AccessRules2.ts`. Added a small unit test for constructing table titles from the new description returned by `getAclResources`.

Reviewers: georgegevoian

Reviewed By: georgegevoian

Differential Revision: https://phab.getgrist.com/D3494
This commit is contained in:
Alex Hall
2022-07-18 13:57:56 +02:00
parent a0f405e45f
commit f39b496563
4 changed files with 62 additions and 18 deletions

View File

@@ -2,6 +2,7 @@ import {KoArray} from 'app/client/lib/koArray';
import {DocModel, IRowModel, recordSet, refRecord, ViewSectionRec} from 'app/client/models/DocModel';
import {ColumnRec, ValidationRec, ViewRec} from 'app/client/models/DocModel';
import * as modelUtil from 'app/client/models/modelUtil';
import {summaryGroupByDescription} from 'app/common/ActiveDocAPI';
import {MANUALSORT} from 'app/common/gristTypes';
import * as ko from 'knockout';
import randomcolor from 'randomcolor';
@@ -68,8 +69,7 @@ export function createTableRec(this: TableRec, docModel: DocModel): void {
if (!this.summarySourceTable()) {
return '';
}
const groupBy = this.groupByColumns();
return `[${groupBy.length ? 'by ' + groupBy.map(c => c.label()).join(", ") : "Totals"}]`;
return summaryGroupByDescription(this.groupByColumns().map(c => c.label()));
});
// TODO: We should save this value and let users change it.