Linkstate refactor (#609)

* Linkingstate Refactor, and displaying link info in rightpanel

Big refactor to LinkingState
    Collects descriptive/user-facing labels into FilterState
    Unifies/cleans up some logic
    Adds LinkTypeDescription, a string enum which can be used
    to easily switch/case between various cases of linking, and
    codifies the logic in one place (currently only used for linkInfo)

Adds Link info to creator panel, near SelectBy dropdown

Bugfix: Disables linking from Attachment columns
Bugfix/Behavior change: changed linking with empty RefLists to better
match behavior of refs.
    for context: Linking by a blank Ref filters to show records with a
    blank value for that Ref. Previously this didn't work with RefLists. 
    Linking from a blank refList would show no records 
    (except in some cases involving summary tables)
    Fixed this so that linking by a blank val consistently means "show
    all records where the corresponding col is blank"
This commit is contained in:
Janet Vorobyeva
2023-09-08 14:21:32 -04:00
committed by GitHub
parent a0f5ab81ad
commit f8c1bd612c
5 changed files with 724 additions and 204 deletions

View File

@@ -42,6 +42,9 @@ interface LinkNode {
// is the table a summary table
isSummary: boolean;
// does this node involve an "Attachments" column. Can be tricky if Attachments is one of groupby cols
isAttachments: boolean;
// For a summary table, the set of col refs of the groupby columns of the underlying table
groupbyColumns?: Set<number>;
@@ -114,6 +117,12 @@ function isValidLink(source: LinkNode, target: LinkNode) {
return false;
}
//cannot select from attachments, even though they're implemented as reflists
if (source.isAttachments || target.isAttachments) {
return false;
}
// cannot select from chart
if (source.widgetType === 'chart') {
return false;
@@ -230,6 +239,7 @@ function fromViewSectionRec(section: ViewSectionRec): LinkNode[] {
const mainNode: LinkNode = {
tableId: table.primaryTableId.peek(),
isSummary,
isAttachments: isSummary && table.groupByColumns.peek().some(col => col.type.peek() == "Attachments"),
groupbyColumns: isSummary ? table.summarySourceColRefs.peek() : undefined,
widgetType: section.parentKey.peek(),
ancestors,
@@ -266,6 +276,8 @@ function fromPageWidget(docModel: DocModel, pageWidget: IPageWidget): LinkNode[]
const mainNode: LinkNode = {
tableId: table.primaryTableId.peek(),
isSummary,
isAttachments: false, // hmm, we should need a check here in case attachments col is on the main-node link
// (e.g.: link from summary table with Attachments in group-by) but it seems to work fine as is
groupbyColumns,
widgetType: pageWidget.type,
ancestors: new Set(),
@@ -284,7 +296,7 @@ function fromColumns(table: TableRec, mainNode: LinkNode, tableExists: boolean =
}
const tableId = getReferencedTableId(column.type.peek());
if (tableId) {
nodes.push({...mainNode, tableId, column});
nodes.push({...mainNode, tableId, column, isAttachments: column.type.peek() == "Attachments"});
}
}
return nodes;