mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) Auto-check aggregate values option as soon as table is a summary
Summary: Auto-check makes sure that the “Aggregate Values” option is checked as soon as the chart table is summarized. Before, user had to check it explicitly. More on this: https://grist.slack.com/archives/C04AYS9JF/p1649400119930389?thread_ts=1649338496.915759&cid=C04AYS9JF Test Plan: Updated tests Reviewers: jarek Reviewed By: jarek Differential Revision: https://phab.getgrist.com/D3422
This commit is contained in:
parent
af1564d410
commit
365f3c7ae2
@ -491,11 +491,15 @@ export class ChartConfig extends GrainJSDisposable {
|
||||
})
|
||||
.onWrite((colId) => this._setXAxis(colId));
|
||||
|
||||
// Whether value is aggregated or not
|
||||
private _isValueAggregated = Computed.create(this, (use) => this._isSummaryTable(use))
|
||||
.onWrite((val) => this._setAggregation(val));
|
||||
|
||||
// Columns options
|
||||
private _columnsOptions: Computed<Array<IOptionFull<string>>> = Computed.create(
|
||||
this, this._freezeXAxis, (use, freeze) => {
|
||||
if (freeze) { return this._columnsOptions.get(); }
|
||||
const columns = use(this._optionsObj.prop('aggregate')) ?
|
||||
const columns = use(this._isValueAggregated) ?
|
||||
this._getSummarySourceColumns(use) :
|
||||
this._getColumns(use);
|
||||
return columns
|
||||
@ -548,9 +552,6 @@ export class ChartConfig extends GrainJSDisposable {
|
||||
});
|
||||
});
|
||||
|
||||
private _isValueAggregated = Computed.create(this, (use) => use(this._optionsObj.prop('aggregate')))
|
||||
.onWrite((val) => this._setAggregation(val));
|
||||
|
||||
constructor(private _gristDoc: GristDoc, private _section: ViewSectionRec) {
|
||||
super();
|
||||
ChartConfig._instanceMap.set(_section, this);
|
||||
@ -711,7 +712,7 @@ export class ChartConfig extends GrainJSDisposable {
|
||||
// if values aggregation is 'on' update the grouped by columns before findColumn()
|
||||
// call. This will make sure that colId is not missing from the summary table's columns (as
|
||||
// could happen if it were a non-numeric for instance).
|
||||
if (this._optionsObj.prop('aggregate')()) {
|
||||
if (this._isValueAggregated.get()) {
|
||||
const splitColId = this._groupDataColId.get();
|
||||
const cols = splitColId === colId ? [colId] : [splitColId, colId];
|
||||
await this._setGroupByColumns(cols);
|
||||
@ -753,7 +754,7 @@ export class ChartConfig extends GrainJSDisposable {
|
||||
// if values aggregation is 'on' update the grouped by columns first. This will make sure
|
||||
// that colId is not missing from the summary table's columns (as could happen if it were a
|
||||
// non-numeric for instance).
|
||||
if (this._optionsObj.prop('aggregate')()) {
|
||||
if (this._isValueAggregated.get()) {
|
||||
const xAxisColId = this._xAxis.get();
|
||||
const cols = xAxisColId === colId ? [colId] : [colId, xAxisColId];
|
||||
await this._setGroupByColumns(cols);
|
||||
@ -840,7 +841,6 @@ export class ChartConfig extends GrainJSDisposable {
|
||||
try {
|
||||
this._freezeXAxis.set(true);
|
||||
await this._gristDoc.docData.bundleActions(`Toggle chart aggregation`, async () => {
|
||||
await this._optionsObj.prop('aggregate').saveOnly(val);
|
||||
if (val) {
|
||||
await this._doAggregation();
|
||||
} else {
|
||||
|
@ -329,7 +329,7 @@ export function buildViewSectionDom(options: {
|
||||
// With new widgetPopup it is hard to click on viewSection without a activating it, hence we
|
||||
// add a little blank space to use in test.
|
||||
const cssTestClick = styled(`div`, `
|
||||
min-width: 1px;
|
||||
min-width: 2px;
|
||||
`);
|
||||
|
||||
const cssSigmaIcon = styled(icon, `
|
||||
|
Loading…
Reference in New Issue
Block a user