pandora/static/js/entityDialog.js

97 lines
2.7 KiB
JavaScript
Raw Normal View History

2014-11-20 10:03:07 +00:00
// vim: et:ts=4:sw=4:sts=4:ft=javascript
'use strict';
2014-12-16 19:55:05 +00:00
pandora.ui.entityDialog = function() {
2014-11-20 10:03:07 +00:00
2014-11-20 12:24:47 +00:00
var ui = pandora.user.ui,
2014-11-21 14:55:03 +00:00
$content = Ox.Element()
.css({overflowY: 'auto'}),
2014-11-20 12:24:47 +00:00
that = Ox.Dialog({
2014-12-17 15:33:58 +00:00
buttons: (pandora.site.capabilities.canManageEntities[pandora.user.level] ? [
2014-12-17 15:23:49 +00:00
Ox.Button({
id: 'edit',
title: Ox._('Edit Entity...')
})
.bindEvent({
click: function() {
2014-12-17 16:07:39 +00:00
var id = [ui.part.entities];
2014-12-17 15:23:49 +00:00
that.close();
2014-12-17 16:07:39 +00:00
pandora.api.getEntity({
id: id
}, function(result) {
var type = result.data.type;
pandora.UI.set(Ox.extend({
entitiesType: type
}, 'entitiesSelection.' + type, [id]));
});
2014-12-17 15:23:49 +00:00
pandora.$ui.entitiesDialog = pandora.ui.entitiesDialog().open();
}
}),
{}
] : []).concat([
Ox.Button({
id: 'close',
title: Ox._('Close')
})
.bindEvent({
click: function() {
that.close();
}
})
]),
2014-11-20 12:24:47 +00:00
closeButton: true,
content: $content,
fixedSize: true,
2014-11-21 14:55:03 +00:00
height: 416,
2014-12-17 15:31:55 +00:00
keys: {escape: 'close'},
2014-11-20 12:24:47 +00:00
padding: 0,
removeOnClose: true,
title: '',
2014-11-21 14:55:03 +00:00
width: 560,
2014-11-20 12:24:47 +00:00
})
.bindEvent({
close: function() {
2014-12-16 21:05:33 +00:00
pandora.UI.set({
entity: '',
page: ''
});
2014-11-20 12:24:47 +00:00
delete pandora.$ui.entityDialog;
},
2014-12-16 21:05:33 +00:00
'pandora_part.entities': function(data) {
2014-11-20 12:24:47 +00:00
if (data.value) {
setTitle();
setContent();
} else {
that.close();
}
}
});
2014-11-20 19:48:42 +00:00
setTitle();
setContent();
2014-11-20 12:24:47 +00:00
function setContent() {
2014-12-16 21:05:33 +00:00
ui.part.entities && pandora.entity({
id: ui.part.entities,
2014-11-20 12:24:47 +00:00
view: 'entity'
}, function(html) {
$content.html(html);
2014-12-17 16:00:55 +00:00
pandora.createLinks($content);
2014-11-20 12:24:47 +00:00
});
}
function setTitle() {
2014-12-17 15:23:49 +00:00
ui.part.entities && pandora.api.getEntity({
2014-12-16 21:05:33 +00:00
id: ui.part.entities
2014-11-20 19:48:42 +00:00
}, function(result) {
that.options({title: result.data.name});
2014-11-20 12:24:47 +00:00
});
}
return that;
2014-11-20 10:03:07 +00:00
2014-12-16 21:05:33 +00:00
};