2011-10-11 11:29:05 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
2011-11-05 17:04:10 +00:00
|
|
|
'use strict';
|
2011-10-11 11:29:05 +00:00
|
|
|
pandora.ui.namesDialog = function() {
|
|
|
|
|
2011-10-11 17:25:06 +00:00
|
|
|
// FIXME: add cache invalidation
|
|
|
|
|
2011-10-11 11:29:05 +00:00
|
|
|
var height = Math.round((window.innerHeight - 48) * 0.9),
|
2014-09-26 12:12:25 +00:00
|
|
|
width = 576 + Ox.UI.SCROLLBAR_SIZE,
|
2011-10-11 11:29:05 +00:00
|
|
|
|
|
|
|
$findInput = Ox.Input({
|
|
|
|
changeOnKeypress: true,
|
|
|
|
clear: true,
|
2014-02-13 16:24:52 +00:00
|
|
|
placeholder: Ox._('Find'),
|
2011-10-11 11:29:05 +00:00
|
|
|
width: 192
|
|
|
|
})
|
2011-10-11 16:20:41 +00:00
|
|
|
.css({float: 'right', margin: '4px'})
|
2011-10-11 11:29:05 +00:00
|
|
|
.bindEvent({
|
|
|
|
change: function(data) {
|
2011-10-11 16:20:41 +00:00
|
|
|
var query = {
|
|
|
|
conditions: [
|
2015-04-20 08:13:56 +00:00
|
|
|
{
|
|
|
|
key: 'name',
|
|
|
|
operator: '=',
|
|
|
|
value: data.value
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'sortname',
|
|
|
|
operator: '=',
|
|
|
|
value: data.value
|
|
|
|
}
|
2011-10-11 16:20:41 +00:00
|
|
|
],
|
|
|
|
operator: '|'
|
|
|
|
};
|
|
|
|
$list.options({
|
2012-06-20 10:47:15 +00:00
|
|
|
query: query,
|
2011-10-29 17:46:46 +00:00
|
|
|
});
|
2011-10-11 11:29:05 +00:00
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
2012-06-27 07:41:39 +00:00
|
|
|
$list = Ox.TableList({
|
2011-10-11 11:29:05 +00:00
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
id: 'id',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('ID'),
|
2011-10-11 11:29:05 +00:00
|
|
|
visible: false,
|
2011-10-11 16:01:33 +00:00
|
|
|
width: 0
|
2011-10-11 11:29:05 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'name',
|
|
|
|
operator: '+',
|
|
|
|
removable: false,
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Name'),
|
2011-10-11 11:29:05 +00:00
|
|
|
visible: true,
|
2011-10-11 16:01:33 +00:00
|
|
|
width: 256
|
2011-10-11 11:29:05 +00:00
|
|
|
},
|
|
|
|
{
|
2011-10-11 16:01:33 +00:00
|
|
|
editable: true,
|
|
|
|
id: 'sortname',
|
2011-10-11 11:29:05 +00:00
|
|
|
operator: '+',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Sort Name'),
|
|
|
|
tooltip: Ox._('Edit Sort Name'),
|
2011-10-11 11:29:05 +00:00
|
|
|
visible: true,
|
2011-10-11 16:01:33 +00:00
|
|
|
width: 256
|
2011-10-11 11:29:05 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'numberofnames',
|
|
|
|
align: 'right',
|
|
|
|
operator: '-',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Names'),
|
2011-10-11 11:29:05 +00:00
|
|
|
visible: true,
|
2011-10-11 16:01:33 +00:00
|
|
|
width: 64
|
2011-10-11 11:29:05 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
columnsVisible: true,
|
|
|
|
items: pandora.api.findNames,
|
|
|
|
max: 1,
|
|
|
|
scrollbarVisible: true,
|
2012-06-27 22:24:02 +00:00
|
|
|
sort: [{key: 'sortname', operator: '+'}],
|
|
|
|
unique: 'id'
|
2011-10-11 11:29:05 +00:00
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
init: function(data) {
|
2013-07-18 08:14:14 +00:00
|
|
|
$status.html(
|
|
|
|
Ox.toTitleCase(Ox.formatCount(data.items, 'name'))
|
|
|
|
);
|
2011-10-11 11:29:05 +00:00
|
|
|
},
|
2011-10-11 17:25:06 +00:00
|
|
|
open: function(data) {
|
2012-05-22 13:15:16 +00:00
|
|
|
$list.find('.OxItem.OxSelected > .OxCell.OxColumnSortname')
|
2011-11-08 18:16:48 +00:00
|
|
|
.trigger('mousedown')
|
|
|
|
.trigger('mouseup');
|
2011-10-11 17:25:06 +00:00
|
|
|
},
|
2011-10-11 18:13:51 +00:00
|
|
|
select: function(data) {
|
|
|
|
$findButton.options({disabled: !data.ids.length});
|
|
|
|
},
|
2011-10-11 16:01:33 +00:00
|
|
|
submit: function(data) {
|
2011-10-11 17:25:06 +00:00
|
|
|
Ox.Request.clearCache('findNames');
|
2011-10-11 16:01:33 +00:00
|
|
|
pandora.api.editName({
|
|
|
|
id: data.id,
|
2011-10-11 16:58:12 +00:00
|
|
|
sortname: data.value
|
2011-10-11 16:01:33 +00:00
|
|
|
});
|
2011-10-11 11:29:05 +00:00
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
2011-10-11 18:13:51 +00:00
|
|
|
$findButton = Ox.Button({
|
|
|
|
disabled: true,
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Find'),
|
2012-05-26 15:46:24 +00:00
|
|
|
width: 48
|
2011-10-11 18:13:51 +00:00
|
|
|
}).bindEvent({
|
|
|
|
click: function() {
|
|
|
|
that.close();
|
2013-07-14 15:36:49 +00:00
|
|
|
pandora.UI.set({find: {
|
2011-10-11 18:13:51 +00:00
|
|
|
conditions: [{
|
|
|
|
key: 'name',
|
2015-04-20 08:13:56 +00:00
|
|
|
value: $list.value(
|
|
|
|
$list.options('selected'), 'name'
|
|
|
|
),
|
2011-10-11 18:13:51 +00:00
|
|
|
operator: '='
|
|
|
|
}],
|
|
|
|
operator: '&'
|
2013-07-14 15:36:49 +00:00
|
|
|
}});
|
2012-06-11 08:50:03 +00:00
|
|
|
pandora.$ui.findElement.updateElement();
|
2011-10-11 18:13:51 +00:00
|
|
|
}
|
|
|
|
}),
|
2011-10-29 17:46:46 +00:00
|
|
|
|
2011-10-11 11:29:05 +00:00
|
|
|
that = Ox.Dialog({
|
2012-09-15 12:14:12 +00:00
|
|
|
buttons: [
|
|
|
|
Ox.Button({
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Manage Titles...')
|
2012-09-15 12:14:12 +00:00
|
|
|
}).bindEvent({
|
|
|
|
click: function() {
|
|
|
|
that.close();
|
|
|
|
(pandora.$ui.titlesDialog || (
|
|
|
|
pandora.$ui.titlesDialog = pandora.ui.titlesDialog()
|
|
|
|
)).open();
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
{},
|
|
|
|
$findButton,
|
|
|
|
Ox.Button({
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Done'),
|
2012-09-15 12:14:12 +00:00
|
|
|
width: 48
|
|
|
|
}).bindEvent({
|
|
|
|
click: function() {
|
|
|
|
that.close();
|
|
|
|
}
|
|
|
|
})
|
2011-10-11 11:29:05 +00:00
|
|
|
],
|
2012-09-15 12:14:12 +00:00
|
|
|
closeButton: true,
|
|
|
|
content: Ox.SplitPanel({
|
|
|
|
elements: [
|
|
|
|
{
|
|
|
|
element: Ox.Bar({size: 24})
|
|
|
|
.append($status)
|
|
|
|
.append(
|
|
|
|
$findInput
|
|
|
|
),
|
|
|
|
size: 24
|
|
|
|
},
|
|
|
|
{
|
|
|
|
element: $list
|
|
|
|
}
|
|
|
|
],
|
|
|
|
orientation: 'vertical'
|
|
|
|
}),
|
|
|
|
height: height,
|
|
|
|
maximizeButton: true,
|
|
|
|
minHeight: 256,
|
|
|
|
minWidth: 512,
|
|
|
|
padding: 0,
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Manage Names'),
|
2012-09-15 12:14:12 +00:00
|
|
|
width: width
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
resizeend: function(data) {
|
2014-09-26 12:12:25 +00:00
|
|
|
var width = (data.width - 64 - Ox.UI.SCROLLBAR_SIZE) / 2;
|
2012-09-15 12:14:12 +00:00
|
|
|
[
|
|
|
|
{id: 'name', width: Math.ceil(width)},
|
|
|
|
{id: 'sortname', width: Math.floor(width)}
|
|
|
|
].forEach(function(column) {
|
|
|
|
$list.resizeColumn(column.id, column.width);
|
|
|
|
});
|
|
|
|
}
|
2011-10-11 11:29:05 +00:00
|
|
|
}),
|
2011-10-11 16:13:21 +00:00
|
|
|
|
2012-09-15 12:14:12 +00:00
|
|
|
$status = $('<div>')
|
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
top: '4px',
|
|
|
|
left: '128px',
|
|
|
|
right: '128px',
|
|
|
|
bottom: '4px',
|
|
|
|
paddingTop: '2px',
|
|
|
|
fontSize: '9px',
|
|
|
|
textAlign: 'center'
|
|
|
|
})
|
|
|
|
.appendTo(that.find('.OxButtonsbar'));
|
2011-10-11 11:29:05 +00:00
|
|
|
|
|
|
|
return that;
|
|
|
|
|
|
|
|
};
|