update manage events dialog

This commit is contained in:
rolux 2011-10-03 16:38:07 +00:00
parent 978c86d37e
commit 97788738b4
3 changed files with 70 additions and 64 deletions

View file

@ -1,4 +1,5 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript // vim: et:ts=4:sw=4:sts=4:ft=javascript
pandora.ui.eventsDialog = function() { pandora.ui.eventsDialog = function() {
var height = Math.round((window.innerHeight - 48) * 0.9), var height = Math.round((window.innerHeight - 48) * 0.9),
width = Math.round(window.innerWidth * 0.9), width = Math.round(window.innerWidth * 0.9),
@ -14,44 +15,7 @@ pandora.ui.eventsDialog = function() {
}) })
], ],
closeButton: true, closeButton: true,
content: pandora.$ui.eventsElement = Ox.TextList({ content: Ox.Element(),
columns: [
{
id: 'id',
title: 'ID',
operator: '+',
unique: true,
visible: false,
width: 16
},
{
id: 'name',
title: 'Name',
operator: '+',
visible: true,
width: 256
},
{
id: 'start',
operator: '+',
visible: true,
width: 256
},
{
id: 'end',
operator: '+',
visible: true,
width: 256
}
],
items: function(data, callback) {
pandora.api.findEvents(data, callback);
},
keys: ['name', 'start', 'end'],
sort: [
{key: 'name', operator: '+'}
]
}),
height: height, height: height,
maximizeButton: true, maximizeButton: true,
minHeight: 256, minHeight: 256,
@ -60,6 +24,26 @@ pandora.ui.eventsDialog = function() {
title: 'Manage Events', title: 'Manage Events',
width: width width: width
}); });
pandora.api.findEvents({
query: {conditions: [], operator: '&'}
}, function(result) {
pandora.api.findEvents({
query: {conditions: [], operator: '&'},
keys: [],
range: [0, result.data.items],
sort: [{key: 'name', operator: '+'}]
}, function(result) {
that.options({
content: Ox.ListCalendar({
height: height - 48,
events: result.data.items,
width: width
})
});
})
})
return that; return that;
}; };

View file

@ -1,4 +1,5 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript // vim: et:ts=4:sw=4:sts=4:ft=javascript
pandora.ui.placesDialog = function() { pandora.ui.placesDialog = function() {
var height = Math.round((window.innerHeight - 48) * 0.9), var height = Math.round((window.innerHeight - 48) * 0.9),
width = Math.round(window.innerWidth * 0.9), width = Math.round(window.innerWidth * 0.9),
@ -14,7 +15,7 @@ pandora.ui.placesDialog = function() {
}) })
], ],
closeButton: true, closeButton: true,
content: pandora.$ui.placesElement = Ox.ListMap({ content: Ox.ListMap({
height: height - 48, height: height - 48,
places: function(data, callback) { places: function(data, callback) {
return pandora.api.findPlaces(Ox.extend({ return pandora.api.findPlaces(Ox.extend({

View file

@ -4,10 +4,11 @@ pandora.ui.usersDialog = function() {
var height = Math.round((window.innerHeight - 48) * 0.9), var height = Math.round((window.innerHeight - 48) * 0.9),
width = Math.round(window.innerWidth * 0.9), width = Math.round(window.innerWidth * 0.9),
levelColors = { levelColors = {
'member': [128, 128, 0], 'guest': [64, 0, 0],
'friend': [0, 128, 0], 'member': [64, 64, 0],
'staff': [0, 128, 128], 'friend': [0, 64, 0],
'admin': [0, 0, 128] 'staff': [0, 64, 64],
'admin': [0, 0, 64]
}, },
numberOfUsers = 0, numberOfUsers = 0,
userLevels = ['member', 'friend', 'staff', 'admin'], userLevels = ['member', 'friend', 'staff', 'admin'],
@ -100,8 +101,8 @@ pandora.ui.usersDialog = function() {
$list = Ox.TextList({ $list = Ox.TextList({
columns: [ columns: [
{ {
clickable: true,
format: function(value) { format: function(value) {
Ox.print('&&', value)
return $('<img>') return $('<img>')
.attr({ .attr({
src: Ox.UI.getImageURL('symbolCheck') src: Ox.UI.getImageURL('symbolCheck')
@ -153,22 +154,24 @@ pandora.ui.usersDialog = function() {
{ {
align: 'center', align: 'center',
format: function(value) { format: function(value) {
var dark = 'rgb(' + levelColors[value].map(function(color) {
return color.toString()
}).join(', ') + ')',
light = 'rgb(' + levelColors[value].map(function(color) {
return (color + 128).toString()
}).join(', ') + ')';
return $('<div>') return $('<div>')
.css({ .css({
borderRadius: '4px', borderRadius: '4px',
padding: '0 3px 1px 3px', padding: '0 3px 1px 3px',
background: 'rgb(' + levelColors[value].map(function(color) { background: pandora.user.ui.theme == 'classic' ? light : dark,
return color.toString()
}).join(', ') + ')',
textAlign: 'center', textAlign: 'center',
color: 'rgb(' + levelColors[value].map(function(color) { color: pandora.user.ui.theme == 'classic' ? dark : light
return (color + 128).toString()
}).join(', ') + ')'
}) })
.html(Ox.toTitleCase(value)) .html(Ox.toTitleCase(value))
}, },
id: 'level', id: 'level',
operator: '+', operator: '-',
title: 'Level', title: 'Level',
visible: true, visible: true,
width: 60 width: 60
@ -215,7 +218,7 @@ pandora.ui.usersDialog = function() {
{ {
align: 'right', align: 'right',
id: 'ip', id: 'ip',
operator: '-', operator: '+',
title: 'IP Address', title: 'IP Address',
visible: true, visible: true,
width: 120 width: 120
@ -238,7 +241,7 @@ pandora.ui.usersDialog = function() {
}, },
{ {
id: 'useragent', id: 'useragent',
operator: '-', operator: '+',
title: 'User Agent', title: 'User Agent',
visible: true, visible: true,
width: 810 width: 810
@ -255,14 +258,12 @@ pandora.ui.usersDialog = function() {
] ]
}) })
.bindEvent({ .bindEvent({
click: function(data) {
// ...
},
init: function(data) { init: function(data) {
numberOfUsers = data.items; numberOfUsers = data.items;
$status.options({ $status.options({
title: Ox.formatNumber(numberOfUsers) title: Ox.formatNumber(numberOfUsers)
+ ' user' + (numberOfUsers == 1 ? '' : 's') + ' user' + (numberOfUsers == 1 ? '' : 's')
+ ' (' + Ox.formatNumber(numberOfUsers) + ' registered, 0 guests)'
}); });
}, },
select: function(data) { select: function(data) {
@ -350,12 +351,13 @@ pandora.ui.usersDialog = function() {
width: width width: width
}); });
function renderUserForm(data) { function renderUserForm(userData) {
var $checkbox; var $checkbox;
return Ox.Form({ return Ox.Form({
items: [ items: [
$checkbox = Ox.Checkbox({ $checkbox = Ox.Checkbox({
checked: !data.disabled, checked: !userData.disabled,
id: 'status',
label: 'Status', label: 'Status',
labelWidth: 80, labelWidth: 80,
title: 'Enabled', title: 'Enabled',
@ -364,13 +366,14 @@ pandora.ui.usersDialog = function() {
.bindEvent({ .bindEvent({
change: function(data) { change: function(data) {
// fixme: it would be really nice to have "this" here // fixme: it would be really nice to have "this" here
$checkbox.options({title: data.checked ? 'Enabled' : 'Disabled'}) $checkbox.options({title: userData.checked ? 'Enabled' : 'Disabled'})
} }
}), }),
Ox.Input({ Ox.Input({
id: 'username',
label: 'Username', label: 'Username',
labelWidth: 80, labelWidth: 80,
value: data.username, value: userData.username,
width: 240 width: 240
}) })
.bindEvent({ .bindEvent({
@ -379,9 +382,10 @@ pandora.ui.usersDialog = function() {
} }
}), }),
Ox.Input({ Ox.Input({
id: 'email',
label: 'E-Mail', label: 'E-Mail',
labelWidth: 80, labelWidth: 80,
value: data.email, value: userData.email,
width: 240 width: 240
}) })
.bindEvent({ .bindEvent({
@ -390,9 +394,10 @@ pandora.ui.usersDialog = function() {
} }
}), }),
Ox.Select({ Ox.Select({
id: 'level',
items: userLevels.map(function(level) { items: userLevels.map(function(level) {
return { return {
checked: level == data.level, checked: level == userData.level,
id: level, id: level,
title: Ox.toTitleCase(level) title: Ox.toTitleCase(level)
}; };
@ -408,16 +413,32 @@ pandora.ui.usersDialog = function() {
*/ */
Ox.Input({ Ox.Input({
height: 120, height: 120,
id: 'notes',
placeholder: 'Notes', placeholder: 'Notes',
type: 'textarea', type: 'textarea',
value: userData.notes,
width: 240 width: 240
}) })
.css({height: '240px'}) .css({height: '240px'})
], ],
width: 240 width: 240
}) })
.css({margin: '8px'}); .css({margin: '8px'})
.bindEvent({
change: function(event) {
var data = {id: userData.username}, key, value;
if (event.id == 'status') {
data.disabled = !event.data.checked;
} else if (event.id == 'level') {
data.level = event.data.selected[0].id;
} else {
data[event.id] = event.data.value;
}
pandora.api.editUser(data, function(result) {
// ...
});
}
});
} }
function updateList(key, value) { function updateList(key, value) {