Skip to content

Commit 38b8a3c

Browse files
committed
Move decision responsibility entirely to Tooltip view (#448 #494)
1 parent 1e9c434 commit 38b8a3c

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

frontend/src/label/label-view.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,7 @@ export default class LabelView extends View<FlatItem> {
3737
}
3838

3939
addTooltip(): void {
40-
const cls = this.model.get('class');
41-
if (
42-
typeof this.toolTipSetting === 'string' &&
43-
(cls.has(skos.definition) || cls.has(rdfs.comment))
44-
) {
40+
if (typeof this.toolTipSetting === 'string') {
4541
attachTooltip(this, {
4642
direction: this.toolTipSetting,
4743
model: this.model,

frontend/src/tooltip/tooltip-view.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,20 @@ export class Tooltip extends View<FlatItem> {
4747
constructor(options?: ViewOptions) {
4848
super(options);
4949
this.preferredDirection = options && options.direction || 'right';
50-
this.model.when('class', this.render, this);
50+
this.model.when('classLabel', this.render, this);
5151
}
5252

5353
render(): this {
5454
const cls = this.model.get('class');
5555
const languageOption = { '@language': i18next.language };
5656
const definition = cls.get(skos.definition, languageOption);
5757
const comment = definition || cls.get(rdfs.comment, languageOption);
58-
this.$el.attr(
59-
'data-tooltip',
60-
definition && definition[0] || comment && comment[0]
61-
);
58+
const text = definition && definition[0] || comment && comment[0];
59+
if (text) {
60+
this.$el.attr('data-tooltip', text);
61+
} else {
62+
this.$el.removeClass('tooltip');
63+
}
6264
return this;
6365
}
6466

0 commit comments

Comments
 (0)