(core) Readonly editors

Summary:
Grist should not prevent read-only viewers from opening cell editors since they usually provide much more information than is visible in a cell.

Every editor was enhanced with a read-only mode that provides the same information available for an editor but doesn't allow to change the underlying data.

Test Plan: Browser tests

Reviewers: dsagal

Reviewed By: dsagal

Differential Revision: https://phab.getgrist.com/D2842
This commit is contained in:
Jarosław Sadziński
2021-06-17 18:41:07 +02:00
parent d3dc910784
commit 698c9d4e40
21 changed files with 356 additions and 141 deletions

View File

@@ -130,6 +130,22 @@ function attr(attrName, valueOrFunc) {
}
exports.attr = attr;
/**
* Sets or removes a boolean attribute of a DOM element. According to the spec, empty string is a
* valid true value for the attribute, and the false value is indicated by the attribute's absence.
* @param {String} attrName The name of the attribute to bind, e.g. 'href'.
* @param {Object} valueOrFunc An observable, a constant, or a function for a computed observable.
*/
function boolAttr(attrName, valueOrFunc) {
return makeBinding(valueOrFunc, function(elem, value) {
if (!value) {
elem.removeAttribute(attrName);
} else {
elem.setAttribute(attrName, '');
}
});
}
exports.boolAttr = boolAttr;
/**
* Keeps the style property `property` of a DOM element in sync with an observable value.