mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Fix linking after a summary update
Summary: When linking table to a summary, the linking ended up broken after updating the summary group by columns. This diff fixes that issue. There were two issues: 1) some subscriptions were missing due to some .peek() calls instead of directly calling the observable. 2) the LinkingState instance was not being disposed. 3) the filterColValues was not updating after source data table has been loaded Test Plan: Include new test file. Reviewers: alexmojaki Reviewed By: alexmojaki Subscribers: paulfitz Differential Revision: https://phab.getgrist.com/D3358
This commit is contained in:
@@ -103,7 +103,16 @@ export class LinkingState extends Disposable {
|
||||
// TODO: This approach doesn't help cursor-linking (the other direction). If we have the
|
||||
// inverse of summary-table's 'group' column, we could implement both, and more efficiently.
|
||||
const isDirectSummary = srcSection.table().summarySourceTable() === tgtSection.table().getRowId();
|
||||
this.filterColValues = this.autoDispose(ko.computed(() => {
|
||||
const _filterColValues = ko.observable<FilterColValues>();
|
||||
this.filterColValues = this.autoDispose(ko.computed(() => _filterColValues()));
|
||||
|
||||
// source data table could still be loading (this could happen after changing the group by
|
||||
// columns of a linked summary table for instance), hence the below listeners.
|
||||
this.autoDispose(srcTableData.dataLoadedEmitter.addListener(_update));
|
||||
this.autoDispose(srcTableData.tableActionEmitter.addListener(_update));
|
||||
|
||||
_update();
|
||||
function _update() {
|
||||
const result: FilterColValues = {filters: {}, operations: {}};
|
||||
const srcRowId = srcSection.activeRowId();
|
||||
for (const c of srcSection.table().groupByColumns()) {
|
||||
@@ -119,8 +128,8 @@ export class LinkingState extends Disposable {
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}));
|
||||
_filterColValues(result);
|
||||
}
|
||||
} else if (isSummaryOf(tgtSection.table(), srcSection.table())) {
|
||||
// TODO: We should move the cursor, but don't currently it for summaries. For that, we need a
|
||||
// column or map representing the inverse of summary table's "group" column.
|
||||
|
||||
Reference in New Issue
Block a user