make rights levels editable

This commit is contained in:
rolux 2011-10-23 09:13:57 +00:00
parent ea52870db6
commit a13c8b8545
3 changed files with 61 additions and 23 deletions

View file

@ -14,6 +14,7 @@
*/ */
"capabilities": { "capabilities": {
"canDeleteItems": {"admin": true}, "canDeleteItems": {"admin": true},
"canDownloadVideo": {"guest": 0, "member": 0, "friend": 3, "staff": 4, "admin": 4},
"canEditMetadata": {"staff": true, "admin": true}, "canEditMetadata": {"staff": true, "admin": true},
"canPlayClips": {"guest": 2, "member": 2, "friend": 3, "staff": 4, "admin": 4}, "canPlayClips": {"guest": 2, "member": 2, "friend": 3, "staff": 4, "admin": 4},
"canPlayVideo": {"guest": 1, "member": 1, "friend": 3, "staff": 4, "admin": 4}, "canPlayVideo": {"guest": 1, "member": 1, "friend": 3, "staff": 4, "admin": 4},
@ -527,11 +528,11 @@
], ],
"rightsLevel": {"member": 5, "staff": 4, "admin": 3}, "rightsLevel": {"member": 5, "staff": 4, "admin": 3},
"rightsLevels": [ "rightsLevels": [
{"name": "Public", "color": [128, 255, 128], "description": "Everyone can see and play."}, {"name": "Public", "color": [128, 255, 128], "description": "Everyone can play and download."},
{"name": "Relaxed", "color": [192, 255, 128], "description": "Guests can't play video."}, {"name": "Relaxed", "color": [192, 255, 128], "description": "Only friends, staff and admins can download."},
{"name": "Regular", "color": [255, 255, 128], "description": "Guests can't play clips, members can't play video."}, {"name": "Regular", "color": [255, 255, 128], "description": "Only friends, staff and admins can play video."},
{"name": "Restricted", "color": [255, 192, 128], "description": "Only friend, staff and admin can see and play."}, {"name": "Restricted", "color": [255, 192, 128], "description": "Only friends, staff and admins can play clips."},
{"name": "Private", "color": [255, 128, 128], "description": "Only staff and admin can see and play."} {"name": "Private", "color": [255, 128, 128], "description": "Only staff and admins can see."}
], ],
"sendReferrer": false, "sendReferrer": false,
"site": { "site": {

View file

@ -59,6 +59,9 @@ pandora.UI = (function() {
add['lists.' + that.encode(list)] = {}; add['lists.' + that.encode(list)] = {};
} }
if (list != self.previousUI._list) { if (list != self.previousUI._list) {
if (!pandora.user.ui.lists[list]) {
add['lists.' + that.encode(list)] = {};
}
Ox.forEach(listSettings, function(listSetting, setting) { Ox.forEach(listSettings, function(listSetting, setting) {
if (!pandora.user.ui.lists[list]) { if (!pandora.user.ui.lists[list]) {
// add default list setting and copy to settings // add default list setting and copy to settings

View file

@ -351,30 +351,54 @@ pandora.ui.infoView = function(data) {
$('<div>').css({height: '8px'}).appendTo($text); $('<div>').css({height: '8px'}).appendTo($text);
['hue', 'saturation', 'lightness'].forEach(function(key) { ['hue', 'saturation', 'lightness', 'volume'].forEach(function(key) {
$('<div>') $('<div>')
.css({marginBottom: '4px'}) .css({marginBottom: '4px'})
.append(formatKey(key, true)) .append(formatKey(key, true))
.append(Ox.formatColor(data[key] || 0, key)) .append(Ox.formatColor(data[key] || 0, key == 'volume' ? 'lightness' : key))
.appendTo($statistics); .appendTo($statistics);
}); });
var rightsLevel = pandora.site.rightsLevels[data['rightsLevel']]; var rightsLevelCSS = getRightsLevelCSS(data.rightsLevel),
$rightsLevel, $rightsLevelSelect, $rightsLevelDescription;
if (canEdit) {
$rightsLevel = $('<div>');
$rightsLevelSelect = Ox.Select({
items: pandora.site.rightsLevels.map(function(rightsLevel, i) {
return {id: i, title: rightsLevel.name, checked: i == data.rightsLevel};
}),
width: 128
})
.css(Ox.extend({
marginBottom: '4px'
}, rightsLevelCSS))
.bindEvent({
change: function(event) {
var rightsLevel = event.selected[0].id;
$rightsLevelSelect.css(getRightsLevelCSS(rightsLevel));
$rightsLevelDescription.html(pandora.site.rightsLevels[rightsLevel].description);
pandora.api.edit({id: data.id, rightsLevel: rightsLevel}, function(result) {
// ...
});
}
})
.appendTo($rightsLevel);
$rightsLevelDescription = $('<div>')
.css({})
.html(pandora.site.rightsLevels[data.rightsLevel].description)
.appendTo($rightsLevel)
} else {
$rightsLevel = $('<div>')
.css(Ox.extend({
paddingLeft: '3px',
borderRadius: '4px'
}, rightsLevelCSS))
.html(pandora.site.rightsLevels[data.rightsLevel].name);
}
$('<div>') $('<div>')
.css({marginBottom: '4px'}) .css({marginBottom: '4px'})
.append(formatKey('Rights Level', true)) .append(formatKey('Rights Level', true))
.append( .append($rightsLevel)
$('<div>')
.css({
paddingLeft: '3px',
borderRadius: '4px',
backgroundColor: 'rgb(' + rightsLevel.color.map(function(value) {
return value - 128;
}).join(', ') + ')',
color: 'rgb(' + rightsLevel.color.join(', ') + ')'
})
.html(rightsLevel.name)
)
.appendTo($statistics); .appendTo($statistics);
if (canEdit) { if (canEdit) {
@ -407,6 +431,16 @@ pandora.ui.infoView = function(data) {
}).join(', '); }).join(', ');
} }
function getRightsLevelCSS(rightsLevel) {
rightsLevel = pandora.site.rightsLevels[rightsLevel];
return {
background: 'rgb(' + rightsLevel.color.map(function(value) {
return value - 128;
}).join(', ') + ')',
color: 'rgb(' + rightsLevel.color.join(', ') + ')'
};
}
pandora.createLinks($text); pandora.createLinks($text);
function renderList() { function renderList() {