Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisj committed Sep 30, 2024
1 parent 5c5080e commit bcd391a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/annotation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ export function formatAnnotationPropertyValue(

export function parseAnnotationPropertyId(obj: unknown) {
const s = verifyString(obj);
if (s.match(/^[a-zA-Z0-9_ -]+$/) === null) {
if (s.match(/^[a-z][a-zA-Z0-9_]*$/) === null) {
throw new Error(`Invalid property identifier: ${JSON.stringify(obj)}`);
}
return s;
Expand Down
14 changes: 4 additions & 10 deletions src/layer/annotation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ import { VirtualList } from "#src/widget/virtual_list.js";

const POINTS_JSON_KEY = "points";
const ANNOTATIONS_JSON_KEY = "annotations";
// const TAGS_JSON_KEY = "tags";
const ANNOTATION_PROPERTIES_JSON_KEY = "annotationProperties";
const ANNOTATION_RELATIONSHIPS_JSON_KEY = "annotationRelationships";
const CROSS_SECTION_RENDER_SCALE_JSON_KEY = "crossSectionAnnotationSpacing";
Expand Down Expand Up @@ -515,7 +514,7 @@ class TagsTab extends Tab {
type: "uint8",
tag: value,
default: 0,
description: value,
description: undefined,
identifier: getUniqueTagPropertyId(localAnnotations),
});
}
Expand All @@ -531,13 +530,14 @@ class TagsTab extends Tab {
inputElement.required = true;
el.append(inputElement);
if (index === listSource.length - 1) {
// add new tag UI
el.classList.add("add");
// this is created just to match the width of the tool button
const tool = makeToolButton(this, layer.toolBinder, {
toolJson: `${TOOL_ID}_${"_invalid"}`,
});
el.prepend(tool);
inputElement.placeholder = "enter tag name";
inputElement.placeholder = "Tag name";
// select input when number of tags increases, this is useful for adding multiple tags in a row
if (previousListLength < listSource.length) {
setTimeout(() => {
Expand Down Expand Up @@ -577,7 +577,6 @@ class TagsTab extends Tab {
properties.changed.dispatch();
this.layer.manager.root.selectionState.changed.dispatch(); // TODO, this is probably not the best way to handle it
});
const end = document.createElement("div");
const deleteButton = makeDeleteButton({
title: "Delete tag",
onClick: (event) => {
Expand All @@ -590,8 +589,7 @@ class TagsTab extends Tab {
},
});
deleteButton.classList.add("neuroglancer-tag-list-entry-delete");
end.append(deleteButton);
el.append(end);
el.append(deleteButton);
}
return el;
},
Expand Down Expand Up @@ -1053,10 +1051,6 @@ export class AnnotationUserLayer extends Base {
x[SHADER_CONTROLS_JSON_KEY] =
this.annotationDisplayState.shaderControls.toJSON();
Object.assign(x, this.linkedSegmentationLayers.toJSON());
// if (this.tags.value.length) {
// x[TAGS_JSON_KEY] = this.tags.value.map((x) => x.value);
// console.log("FOO", x[TAGS_JSON_KEY]);
// }
return x;
}

Expand Down
7 changes: 6 additions & 1 deletion src/layer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,12 @@ export class UserLayer extends RefCounted {
const unregister = existingSignal.add(handler);
return () => {
const res = unregister();
// TODO delete from map? currently handlers is private
// TODO delete from layerEventListeners if no other handlers attached? currently Signal.handlers is private
/*
if (existingSignal.handlers.length === 0) {
layerEventListeners.delete(type);
}
*/
return res;
};
}
Expand Down

0 comments on commit bcd391a

Please sign in to comment.