dont show username for own and featured lists, fixes #456 check for canEditFeaturedList to enable edit link, fixes #447

This commit is contained in:
j 2012-02-16 02:59:44 +05:30
parent eb0e9a79f7
commit 7f01785590
2 changed files with 16 additions and 11 deletions

View file

@ -1,8 +1,8 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript
'use strict';
pandora.ui.folderList = function(id) {
// FIXME: use canEditFeaturedLists capability, not 'admin'
var i = Ox.getIndexById(pandora.site.sectionFolders[pandora.user.ui.section], id),
canEditFeaturedLists = pandora.site.capabilities.canEditFeaturedLists[pandora.user.level],
that;
if (pandora.user.ui.section == 'items') {
var columns, items;
@ -10,7 +10,7 @@ pandora.ui.folderList = function(id) {
columns = [
{
clickable: function(data) {
return data.user == pandora.user.username;
return data.user == pandora.user.username || (id == 'featured' && canEditFeaturedLists);
},
format: function(value, data) {
return $('<img>').attr({
@ -25,7 +25,10 @@ pandora.ui.folderList = function(id) {
id: 'user',
operator: '+',
tooltip: function(data) {
return data.user == pandora.user.username ? 'Edit Icon' : '';
return data.user == pandora.user.username
|| (id == 'featured' && canEditFeaturedLists)
? 'Edit Icon'
: '';
},
visible: true,
width: 16
@ -104,7 +107,7 @@ pandora.ui.folderList = function(id) {
height: '10px',
padding: '3px',
opacity: value == 'private' ? 0.25 : 1
})
});
},
id: 'status',
operator: '+',
@ -240,7 +243,7 @@ pandora.ui.folderList = function(id) {
pageLength: 1000,
//selected: pandora.getListData().folder == id ? [pandora.user.ui._list] : [],
sort: [{key: 'position', operator: '+'}],
sortable: id != 'featured' || pandora.user.level == 'admin'
sortable: id != 'featured' || canEditFeaturedLists
})
.css({
left: 0,
@ -276,7 +279,7 @@ pandora.ui.folderList = function(id) {
});
});
}
} else if (id == 'favorite' || (id == 'featured' && pandora.user.level == 'admin')) {
} else if (id == 'favorite' || (id == 'featured' && canEditFeaturedLists)) {
// this makes the button trigger a change event,
// which is already being handled in folders.js
pandora.$ui.manageListsButton[id].options({value: true});
@ -321,7 +324,7 @@ pandora.ui.folderList = function(id) {
Ox.Request.clearCache(); // fixme: remove
that.reloadList();
});
} else if (id == 'featured' && pandora.user.level == 'admin') {
} else if (id == 'featured' && canEditFeaturedLists) {
that.options({selected: []});
pandora.api.editList({
id: data.ids[0],

View file

@ -137,7 +137,8 @@ pandora.ui.info = function() {
pandora.ui.listInfo = function() {
var list = pandora.user.ui._list,
editable = list.split(':')[0] == pandora.user.username,
canEditFeaturedLists = pandora.site.capabilities.canEditFeaturedLists[pandora.user.level],
editable = list.split(':')[0] == pandora.user.username || canEditFeaturedLists,
that = $('<div>').css({padding: '16px', textAlign: 'center'}),
$icon = Ox.Element({
element: '<img>',
@ -164,16 +165,17 @@ pandora.ui.listInfo = function() {
if (list) {
pandora.api.findLists({
query: {conditions: [{key: 'id', value: list, operator: '=='}]},
keys: ['description', 'name', 'user']
keys: ['description', 'status', 'name', 'user']
}, function(result) {
if (result.data.items.length) {
var item = result.data.items[0],
editable = item.user == pandora.user.username;
editable = item.user == pandora.user.username
|| (item.status == 'featured' && canEditFeaturedLists);
that.append(
$title = Ox.Editable({
editable: editable,
format: function(value) {
return Ox.encodeHTML(item.user + ': ' + value)
return Ox.encodeHTML(editable ? value : item.user + ': ' + value)
},
tooltip: editable ? 'Doubleclick to edit title' : '',
value: item.name,