mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Change how formula columns can be converted to data.
Summary: - No longer convert data columns to formula by typing a leading "=". Instead, show a tooltip with a link to click if the conversion was intended. - No longer convert a formula column to data by deleting its formula. Leave the column empty instead. - Offer the option "Convert formula to data" in column menu for formulas. - Offer the option to "Clear column" - If a subset of rows is shown, offer "Clear values" and "Clear entire column". - Add logic to detect when a view shows a subset of all rows. - Factor out showTooltip() from showTransientTooltip(). - Add a bunch of test cases to cover various combinations (there are small variations in options depending on whether all rows are shown, on whether multiple columns are selected, and whether columns include data columns). Test Plan: Added a bunch of test cases. Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D2746
This commit is contained in:
@@ -133,6 +133,10 @@ export class DataTableModelWithDiff extends DisposableWithEvents implements Data
|
||||
return this.core.getAllRows();
|
||||
}
|
||||
|
||||
public getNumRows(): number {
|
||||
return this.core.getNumRows();
|
||||
}
|
||||
|
||||
public getRowGrouping(groupByCol: string): RowGrouping<CellValue> {
|
||||
return this.core.getRowGrouping(groupByCol);
|
||||
}
|
||||
|
||||
@@ -130,6 +130,10 @@ export class DynamicQuerySet extends RowSource {
|
||||
return this._querySet ? this._querySet.getAllRows() : [];
|
||||
}
|
||||
|
||||
public getNumRows(): number {
|
||||
return this._querySet ? this._querySet.getNumRows() : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells whether the query's result got truncated, i.e. not all rows are included.
|
||||
*/
|
||||
|
||||
@@ -35,6 +35,10 @@ TableModel.prototype.getAllRows = function() {
|
||||
return this.tableData.getRowIds();
|
||||
};
|
||||
|
||||
TableModel.prototype.getNumRows = function() {
|
||||
return this.tableData.numRecords();
|
||||
};
|
||||
|
||||
TableModel.prototype.getRowGrouping = function(groupByCol) {
|
||||
var grouping = this.rowGroupings[groupByCol];
|
||||
if (!grouping) {
|
||||
|
||||
@@ -48,13 +48,16 @@ export type RowsChanged = RowList | typeof ALL;
|
||||
* and `rowNotify(rows, value)` event to notify listeners of a value associated with a row.
|
||||
* For the `rowNotify` event, rows may be the rowset.ALL constant.
|
||||
*/
|
||||
export class RowSource extends DisposableWithEvents {
|
||||
export abstract class RowSource extends DisposableWithEvents {
|
||||
/**
|
||||
* Returns an iterable over all rows in this RowSource. Should be implemented by derived classes.
|
||||
*/
|
||||
public getAllRows(): RowList {
|
||||
throw new Error("RowSource#getAllRows: Not implemented");
|
||||
}
|
||||
public abstract getAllRows(): RowList;
|
||||
|
||||
/**
|
||||
* Returns the number of rows in this row source.
|
||||
*/
|
||||
public abstract getNumRows(): number;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -123,6 +126,15 @@ export class RowListener extends DisposableWithEvents {
|
||||
// MappedRowSource
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* A trivial RowSource returning a fixed list of rows.
|
||||
*/
|
||||
export abstract class ArrayRowSource extends RowSource {
|
||||
constructor(private _rows: RowId[]) { super(); }
|
||||
public getAllRows(): RowList { return this._rows; }
|
||||
public getNumRows(): number { return this._rows.length; }
|
||||
}
|
||||
|
||||
/**
|
||||
* MappedRowSource wraps any other RowSource, and passes through all rows, replacing each row
|
||||
* identifier with the result of mapperFunc(row) call.
|
||||
@@ -155,6 +167,10 @@ export class MappedRowSource extends RowSource {
|
||||
public getAllRows(): RowList {
|
||||
return Array.from(this.parentRowSource.getAllRows(), this._mapperFunc);
|
||||
}
|
||||
|
||||
public getNumRows(): number {
|
||||
return this.parentRowSource.getNumRows();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,6 +196,10 @@ export class ExtendedRowSource extends RowSource {
|
||||
public getAllRows(): RowList {
|
||||
return [...this.parentRowSource.getAllRows()].concat(this.extras);
|
||||
}
|
||||
|
||||
public getNumRows(): number {
|
||||
return this.parentRowSource.getNumRows() + this.extras.length;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -209,6 +229,10 @@ export class BaseFilteredRowSource extends RowListener implements RowSource {
|
||||
return this._matchingRows.values();
|
||||
}
|
||||
|
||||
public getNumRows(): number {
|
||||
return this._matchingRows.size;
|
||||
}
|
||||
|
||||
public onAddRows(rows: RowList) {
|
||||
const outputRows = [];
|
||||
for (const r of rows) {
|
||||
@@ -353,6 +377,10 @@ class RowGroupHelper<Value> extends RowSource {
|
||||
return this.rows.values();
|
||||
}
|
||||
|
||||
public getNumRows(): number {
|
||||
return this.rows.size;
|
||||
}
|
||||
|
||||
public _addAll(rows: RowList) {
|
||||
for (const r of rows) { this.rows.add(r); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user