(core) Refactor more value parsing code into common

Summary:
Following discussion in https://phab.getgrist.com/D3164:

- Change createParser to accept docData and one or two metadata row IDs and let it extract the metadata, so it's more easily usable in the server.
- Change ViewFieldRec.valueParser observable to a function createValueParser.

Test Plan: Existing tests.

Reviewers: dsagal

Reviewed By: dsagal

Differential Revision: https://phab.getgrist.com/D3172
This commit is contained in:
Alex Hall
2021-12-08 00:37:53 +02:00
parent 4164d89b84
commit 6b448567c9
5 changed files with 53 additions and 25 deletions

View File

@@ -372,7 +372,7 @@ BaseView.prototype._parsePasteForView = function(data, fields) {
});
const updateColIds = updateCols.map(c => c && c.colId());
const updateColTypes = updateCols.map(c => c && c.type());
const parsers = fields.map(field => field && field.valueParser() || (x => x));
const parsers = fields.map(field => field && field.createValueParser() || (x => x));
const docIdHash = tableUtil.getDocIdHash();
const richData = data.map((col, idx) => {