(core) Accept values entered into Reference columns showing RowIDs without waiting.

Summary:
- Normally Reference columns can only be used for data entry once the target
  table has loaded. When it shows RowID, we shouldn't need to wait.
- Also, fix pasting values between cells of a RowID-showing column.

Test Plan: Added a test for entering data before data has loaded.

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D2902
pull/9/head
Dmitry S 3 years ago
parent d0905b6224
commit 11c944d794

@ -107,7 +107,7 @@ function makePasteHtml(tableData, selection, includeColHeaders) {
let rawValue = col.rawGetter(rowId);
let fmtValue = col.fmtGetter(rowId);
let dataOptions = {};
if (rawValue != fmtValue) {
if (rawValue !== fmtValue) {
dataOptions['data-grist-raw-value'] = JSON.stringify(rawValue);
}
return dom('td', dataOptions, fmtValue);

@ -128,7 +128,12 @@ export class ReferenceEditor extends NTextEditor {
if (matches.length > 0) {
return matches[0].value;
} else {
return this.textInput.value;
const value = this.textInput.value;
if (this._visibleCol === 'id') {
// If the value is a valid number (non-NaN), save as a numeric rowId; else as text.
return +value || value;
}
return value;
}
}

Loading…
Cancel
Save