gristlabs_grist-core/app/client/widgets/BaseEditor.js
Dmitry S 48e90c4998 (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
2021-03-05 12:42:57 -05:00

60 lines
1.8 KiB
JavaScript

/**
* Required parameters:
* @param {RowModel} options.field: ViewSectionField (i.e. column) being edited.
* @param {Object} options.cellValue: The value in the underlying cell being edited.
* @param {String} options.editValue: String to be edited, or undefined to use cellValue.
* @param {Number} options.cursorPos: The initial position where to place the cursor.
* @param {Object} options.commands: Object mapping command names to functions, to enable as part
* of the command group that should be activated while the editor exists.
*/
function BaseEditor(options) {
}
/**
* Called after the editor is instantiated to attach its DOM to the page.
* - cellElem: The element representing the cell that this editor should match
* in size and position. Used by derived classes, e.g. to construct an EditorPlacement object.
*/
BaseEditor.prototype.attach = function(cellElem) {
// No-op by default.
};
/**
* Returns DOM container with the editor, typically present and attached after attach() has been
* called.
*/
BaseEditor.prototype.getDom = function() {
return null;
};
/**
* Called to get the value to save back to the cell.
*/
BaseEditor.prototype.getCellValue = function() {
throw new Error("Not Implemented");
};
/**
* Used if an editor needs preform any actions before a save
*/
BaseEditor.prototype.prepForSave = function() {
// No-op by default.
};
/**
* Called to get the text in the editor, used when switching between editing data and formula.
*/
BaseEditor.prototype.getTextValue = function() {
throw new Error("Not Implemented");
};
/**
* Called to get the position of the cursor in the editor. Used when switching between editing
* data and formula.
*/
BaseEditor.prototype.getCursorPos = function() {
throw new Error("Not Implemented");
};
module.exports = BaseEditor;