Skip to content

Commit 5a2ef19

Browse files
committed
Add hooks to add details to annotation popovers.
1 parent c8c64af commit 5a2ef19

File tree

3 files changed

+31
-17
lines changed

3 files changed

+31
-17
lines changed

histomicsui/web_client/templates/popover/annotationPopover.pug

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
- var annotationCount = 0;
33
each annotation in annotations
44

5-
// show at most 4 annotations
5+
//- show at most 4 annotations
66
if annotationCount < 4
77
- annotationCount += 1;
88
- var id = annotation.id;
@@ -23,15 +23,18 @@
2323
- var elementCount = 0;
2424
each element in elements[id]
2525

26-
// show at most 10 elements per annotation
26+
//- show at most 10 elements per annotation
2727
if elementCount < 10
2828
- elementCount += 1;
29-
- var type = element.get('type');
30-
- var props = elementProperties(element);
31-
.h-element-type
32-
= type
33-
table
34-
for value, key in props
35-
tr
36-
td #{key}
37-
td #{value}
29+
- var type = element.get('type');
30+
- var props = elementProperties(element);
31+
.h-element-type
32+
= type
33+
table
34+
for value, key in props
35+
tr
36+
td #{key}
37+
td #{value}
38+
- var add = elementAdditionalValues(element, annotation)
39+
if add
40+
| !{add}

histomicsui/web_client/views/popover/AnnotationPopover.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ var AnnotationPopover = View.extend({
106106
elements: {[annotation.id]: [element]},
107107
formatDate,
108108
users: this._users,
109-
elementProperties: (element) => this._elementProperties(element)
109+
elementProperties: (element) => this._elementProperties(element),
110+
elementAdditionalValues: (element, annotation) => this._elementAdditionalValues(element, annotation)
110111
})
111112
);
112113
}
@@ -158,10 +159,9 @@ var AnnotationPopover = View.extend({
158159
},
159160

160161
/**
161-
* Get an object containing elements that are to be
162-
* displayed to the user in a popover. This object is
163-
* cached on the model to avoid recomputing these properties
164-
* every time they are displayed.
162+
* Get an object containing elements that are to be displayed to the user
163+
* in a popover. This object is cached on the model to avoid recomputing
164+
* these properties every time they are displayed.
165165
*/
166166
_elementProperties(element) {
167167
// cache the popover properties to reduce
@@ -240,6 +240,17 @@ var AnnotationPopover = View.extend({
240240
return props;
241241
},
242242

243+
/**
244+
* Return additional HTML to add to element popovers.
245+
*a
246+
* @param {object} element The annotation element under the cursor.
247+
* @param {object} annotation The backbone annotation model.
248+
* @returns {string} An HTML string that will be added to the popover or
249+
* undefined.
250+
*/
251+
_elementAdditionalValues(element, annotation) {
252+
},
253+
243254
/**
244255
* Remove the hidden class on the popover element if this._visible()
245256
* returns true.

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extras =
4343
skipsdist = true
4444
skip_install = true
4545
deps =
46-
flake8<6
46+
flake8
4747
flake8-bugbear
4848
flake8-docstrings
4949
flake8-isort

0 commit comments

Comments
 (0)