-
Notifications
You must be signed in to change notification settings - Fork 10
/
popupBody.js
45 lines (36 loc) · 1.2 KB
/
popupBody.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
define([
'public/v1/api'
], function(
api) {
return api.defineComponent(PopupBodyExample);
function PopupBodyExample() {
this.attributes({
model: undefined,
buttonSelector: '.btn'
})
this.after('initialize', function() {
this.on('updateModel', this.onUpdateModel);
this.on('click', {
buttonSelector: this.onClick
})
this.render(this.attr.model);
});
this.onUpdateModel = function(event, data) {
this.render(data.model);
}
this.render = function(model) {
var self = this,
$node = this.$node,
count = model.properties.length;
api.connect().then(function(c) {
$node.text('This element has ' +
c.formatters.string.plural(count, 'property', 'properties')
).append('<button class="btn btn-small">Search Related</button>')
self.trigger('positionDialog');
})
}
this.onClick = function(event) {
this.trigger('searchByRelatedEntity', { vertexIds: [this.attr.model.id] });
}
}
});