From a13c8b85452b8624b68ec52a3f479fe4e9c0ff03 Mon Sep 17 00:00:00 2001 From: rolux Date: Sun, 23 Oct 2011 09:13:57 +0000 Subject: [PATCH] make rights levels editable --- pandora/0xdb.jsonc | 11 ++--- static/js/pandora/UI.js | 3 ++ static/js/pandora/ui/infoView.js | 70 ++++++++++++++++++++++++-------- 3 files changed, 61 insertions(+), 23 deletions(-) diff --git a/pandora/0xdb.jsonc b/pandora/0xdb.jsonc index b733f5b1..20f5107d 100644 --- a/pandora/0xdb.jsonc +++ b/pandora/0xdb.jsonc @@ -14,6 +14,7 @@ */ "capabilities": { "canDeleteItems": {"admin": true}, + "canDownloadVideo": {"guest": 0, "member": 0, "friend": 3, "staff": 4, "admin": 4}, "canEditMetadata": {"staff": true, "admin": true}, "canPlayClips": {"guest": 2, "member": 2, "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}, "rightsLevels": [ - {"name": "Public", "color": [128, 255, 128], "description": "Everyone can see and play."}, - {"name": "Relaxed", "color": [192, 255, 128], "description": "Guests can't play video."}, - {"name": "Regular", "color": [255, 255, 128], "description": "Guests can't play clips, members can't play video."}, - {"name": "Restricted", "color": [255, 192, 128], "description": "Only friend, staff and admin can see and play."}, - {"name": "Private", "color": [255, 128, 128], "description": "Only staff and admin can see and play."} + {"name": "Public", "color": [128, 255, 128], "description": "Everyone can play and download."}, + {"name": "Relaxed", "color": [192, 255, 128], "description": "Only friends, staff and admins can download."}, + {"name": "Regular", "color": [255, 255, 128], "description": "Only friends, staff and admins can play video."}, + {"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 admins can see."} ], "sendReferrer": false, "site": { diff --git a/static/js/pandora/UI.js b/static/js/pandora/UI.js index c176c452..6bb282a5 100644 --- a/static/js/pandora/UI.js +++ b/static/js/pandora/UI.js @@ -59,6 +59,9 @@ pandora.UI = (function() { add['lists.' + that.encode(list)] = {}; } if (list != self.previousUI._list) { + if (!pandora.user.ui.lists[list]) { + add['lists.' + that.encode(list)] = {}; + } Ox.forEach(listSettings, function(listSetting, setting) { if (!pandora.user.ui.lists[list]) { // add default list setting and copy to settings diff --git a/static/js/pandora/ui/infoView.js b/static/js/pandora/ui/infoView.js index c15da527..699b6b09 100644 --- a/static/js/pandora/ui/infoView.js +++ b/static/js/pandora/ui/infoView.js @@ -351,30 +351,54 @@ pandora.ui.infoView = function(data) { $('
').css({height: '8px'}).appendTo($text); - ['hue', 'saturation', 'lightness'].forEach(function(key) { + ['hue', 'saturation', 'lightness', 'volume'].forEach(function(key) { $('
') - .css({marginBottom: '4px'}) - .append(formatKey(key, true)) - .append(Ox.formatColor(data[key] || 0, key)) - .appendTo($statistics); + .css({marginBottom: '4px'}) + .append(formatKey(key, true)) + .append(Ox.formatColor(data[key] || 0, key == 'volume' ? 'lightness' : key)) + .appendTo($statistics); }); - var rightsLevel = pandora.site.rightsLevels[data['rightsLevel']]; + var rightsLevelCSS = getRightsLevelCSS(data.rightsLevel), + $rightsLevel, $rightsLevelSelect, $rightsLevelDescription; + if (canEdit) { + $rightsLevel = $('
'); + $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 = $('
') + .css({}) + .html(pandora.site.rightsLevels[data.rightsLevel].description) + .appendTo($rightsLevel) + } else { + $rightsLevel = $('
') + .css(Ox.extend({ + paddingLeft: '3px', + borderRadius: '4px' + }, rightsLevelCSS)) + .html(pandora.site.rightsLevels[data.rightsLevel].name); + } $('
') .css({marginBottom: '4px'}) .append(formatKey('Rights Level', true)) - .append( - $('
') - .css({ - paddingLeft: '3px', - borderRadius: '4px', - backgroundColor: 'rgb(' + rightsLevel.color.map(function(value) { - return value - 128; - }).join(', ') + ')', - color: 'rgb(' + rightsLevel.color.join(', ') + ')' - }) - .html(rightsLevel.name) - ) + .append($rightsLevel) .appendTo($statistics); if (canEdit) { @@ -407,6 +431,16 @@ pandora.ui.infoView = function(data) { }).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); function renderList() {