2014-11-19 16:04:45 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
pandora.ui.entitiesDialog = function(options) {
|
|
|
|
|
|
|
|
var dialogHeight = Math.round((window.innerHeight - 48) * 0.9),
|
|
|
|
dialogWidth = Math.round(window.innerWidth * 0.9),
|
|
|
|
|
2014-11-19 17:55:43 +00:00
|
|
|
type = pandora.site.entities[0].id,
|
|
|
|
|
|
|
|
$entitiesSelect = Ox.Select({
|
|
|
|
items: pandora.site.entities.map(function(type) {
|
|
|
|
return {
|
|
|
|
id: type.id,
|
|
|
|
title: type.title
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
width: 248
|
2014-11-19 16:04:45 +00:00
|
|
|
})
|
|
|
|
.bindEvent({
|
2014-11-19 17:55:43 +00:00
|
|
|
change: function(data) {
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
margin: '4px'
|
|
|
|
}),
|
|
|
|
|
|
|
|
$toolbar = Ox.Bar({size: 24})
|
|
|
|
.append($entitiesSelect),
|
|
|
|
|
|
|
|
$findInput = Ox.Input({
|
|
|
|
clear: true,
|
|
|
|
placeholder: 'Find',
|
|
|
|
width: 248
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
margin: '4px'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
submit: function() {
|
|
|
|
|
|
|
|
}
|
2014-11-19 16:04:45 +00:00
|
|
|
}),
|
|
|
|
|
2014-11-19 17:55:43 +00:00
|
|
|
$listBar = Ox.Bar({size: 24})
|
|
|
|
.append($findInput),
|
|
|
|
|
|
|
|
$list = Ox.TableList({
|
|
|
|
columns: [
|
2014-11-19 17:57:38 +00:00
|
|
|
{id: 'id', title: 'ID', operator: '+'},
|
2014-11-19 17:55:43 +00:00
|
|
|
{id: 'name', title: 'Name', operator: '+', visible: true, width: 256}
|
|
|
|
],
|
|
|
|
items: function(options, callback) {
|
|
|
|
pandora.api.findEntities({
|
|
|
|
query: {
|
|
|
|
conditions: [
|
|
|
|
{key: 'type', operator: '==', value: type}
|
|
|
|
].concat(options.query.conditions),
|
|
|
|
operator: '&'
|
|
|
|
},
|
|
|
|
sort: options.sort,
|
|
|
|
range: options.range
|
|
|
|
}, callback);
|
|
|
|
},
|
|
|
|
sort: [{key: 'name', operator: '+'}],
|
|
|
|
scrollbarVisible: true,
|
|
|
|
unique: 'id',
|
|
|
|
width: 256
|
|
|
|
}),
|
2014-11-19 16:04:45 +00:00
|
|
|
|
2014-11-19 17:55:43 +00:00
|
|
|
$listStatus = Ox.Element()
|
|
|
|
.css({
|
|
|
|
fontSize: '9px',
|
|
|
|
marginTop: '2px',
|
|
|
|
textAlign: 'center'
|
|
|
|
})
|
|
|
|
.html(Ox._('Loading...')),
|
2014-11-19 16:04:45 +00:00
|
|
|
|
2014-11-19 17:55:43 +00:00
|
|
|
$listStatusbar = Ox.Bar({size: 16})
|
|
|
|
.append($listStatus),
|
2014-11-19 16:04:45 +00:00
|
|
|
|
|
|
|
$listPanel = Ox.SplitPanel({
|
|
|
|
elements: [
|
|
|
|
{element: $findbar, size: 24},
|
2014-11-19 17:55:43 +00:00
|
|
|
{element: $list},
|
|
|
|
{element: $listStatusbar, size: 16}
|
2014-11-19 16:04:45 +00:00
|
|
|
],
|
|
|
|
orientation: 'vertical'
|
|
|
|
}),
|
|
|
|
|
|
|
|
$leftPanel = Ox.SplitPanel({
|
|
|
|
elements: [
|
2014-11-19 17:55:43 +00:00
|
|
|
{element: $listbar, size: 24},
|
2014-11-19 16:04:45 +00:00
|
|
|
{element: $listPanel}
|
|
|
|
],
|
|
|
|
orientation: 'vertical'
|
|
|
|
}),
|
|
|
|
|
|
|
|
$entity = Ox.Element(),
|
|
|
|
|
2014-11-19 17:55:43 +00:00
|
|
|
$itemMenu = Ox.MenuButton({
|
|
|
|
items: [
|
|
|
|
{'id': 'add', title: Ox._('Add Entity'), keyboard: 'control n'},
|
|
|
|
{'id': 'delete', title: Ox._('Delete Entity'), keyboard: 'delete'}
|
|
|
|
],
|
|
|
|
title: 'set',
|
|
|
|
tooltip: Ox._('Options'),
|
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
margin: '4px'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
click: function(data) {
|
|
|
|
if (data.id == 'add') {
|
|
|
|
// ...
|
|
|
|
} else if (data.id == 'delete') {
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
$itemBar = Ox.Bar({size: 24})
|
|
|
|
.append($itemMenu),
|
|
|
|
|
|
|
|
$itemStatus = Ox.Element()
|
|
|
|
.css({
|
|
|
|
fontSize: '9px',
|
|
|
|
marginTop: '2px',
|
|
|
|
textAlign: 'center'
|
|
|
|
})
|
|
|
|
.html(Ox._('No entity selected')),
|
|
|
|
|
|
|
|
$itemStatusbar = Ox.Bar({size: 16})
|
|
|
|
.append($itemStatus),
|
2014-11-19 16:04:45 +00:00
|
|
|
|
2014-11-19 17:55:43 +00:00
|
|
|
$itemPanel = Ox.SplitPanel({
|
2014-11-19 16:04:45 +00:00
|
|
|
elements: [
|
2014-11-19 17:55:43 +00:00
|
|
|
{element: $itemBar, size: 24},
|
|
|
|
{element: Ox.Element()},
|
|
|
|
{element: $itemStatusbar, size: 16}
|
2014-11-19 16:04:45 +00:00
|
|
|
],
|
|
|
|
orientation: 'vertical'
|
|
|
|
}),
|
|
|
|
|
|
|
|
$content = Ox.SplitPanel({
|
|
|
|
elements: [
|
|
|
|
{
|
|
|
|
element: $leftPanel,
|
|
|
|
resizable: true,
|
|
|
|
resize: [256, 384, 512],
|
|
|
|
size: 256
|
|
|
|
},
|
|
|
|
{
|
|
|
|
element: $entity
|
|
|
|
},
|
|
|
|
{
|
2014-11-19 17:55:43 +00:00
|
|
|
element: $itemPanel,
|
2014-11-19 16:04:45 +00:00
|
|
|
resizable: true,
|
|
|
|
resize: [256, 384, 512],
|
|
|
|
size: 256
|
|
|
|
}
|
|
|
|
],
|
|
|
|
orientation: 'horizontal'
|
2014-11-19 17:55:43 +00:00
|
|
|
}),
|
2014-11-19 16:04:45 +00:00
|
|
|
|
2014-11-19 17:55:43 +00:00
|
|
|
that = Ox.Dialog({
|
|
|
|
buttons: [
|
|
|
|
Ox.Button({
|
|
|
|
title: Ox._('Manage Documents...')
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
click: function() {
|
|
|
|
that.close();
|
|
|
|
(pandora.$ui.documentsDialog || (
|
|
|
|
pandora.$ui.documentsDialog = pandora.ui.documentsDialog()
|
|
|
|
)).open();
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
{},
|
|
|
|
Ox.Button({
|
|
|
|
title: Ox._('Done'),
|
|
|
|
width: 48
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
click: function() {
|
|
|
|
that.close();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
],
|
|
|
|
closeButton: true,
|
|
|
|
content: $content,
|
|
|
|
height: dialogHeight,
|
|
|
|
maximizeButton: true,
|
|
|
|
minHeight: 256,
|
|
|
|
minWidth: 512,
|
|
|
|
padding: 0,
|
|
|
|
removeOnClose: true,
|
|
|
|
title: Ox._('Manage Entities'),
|
|
|
|
width: dialogWidth
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
// resize: ...
|
|
|
|
});
|
2014-11-19 16:04:45 +00:00
|
|
|
|
|
|
|
return that;
|
|
|
|
|
|
|
|
};
|