categorical UI improvements (#1649)

* return undefined for unknown fields

* memoize fetch response

* handle rename of user annotation

* performance and cleanup

* fix snapshots

* fix comment

* lint
This commit is contained in:
Bruce Martin
2020-07-20 08:52:41 -07:00
committed by GitHub
parent 410566f5e1
commit 2715157793
13 changed files with 274 additions and 229 deletions
@@ -18,13 +18,24 @@ categorical annotations to be writable.
*/
export function isCategoricalAnnotation(schema, name) {
/* we treat any string, categorical or boolean as a categorical */
const { type } = schema.annotations.obsByName[name];
/*
we treat any string, categorical or boolean as a categorical.
Return true/false/undefined (for unkonwn fields)
*/
const colSchema = schema.annotations.obsByName[name];
if (colSchema === undefined) return undefined;
const { type } = colSchema;
return type === "string" || type === "boolean" || type === "categorical";
}
export function isContinuousAnnotation(schema, name) {
return !isCategoricalAnnotation(schema, name);
/*
Return true/false/undefined
*/
const colSchema = schema.annotations.obsByName[name];
if (colSchema === undefined) return undefined;
const { type } = colSchema;
return !(type === "string" || type === "boolean" || type === "categorical");
}
function _isUserAnnotation(schema, name) {