add option to select default view for list in dialog and use if user has no list settings, fixes #2636

This commit is contained in:
j 2015-01-02 00:26:04 +01:00
parent 24f81cdeae
commit 9efd77724d
3 changed files with 83 additions and 48 deletions

View file

@ -196,7 +196,7 @@ class List(models.Model):
def json(self, keys=None, user=None):
if not keys:
keys=['id', 'name', 'user', 'type', 'query', 'status', 'subscribed', 'posterFrames', 'description']
keys=['id', 'name', 'user', 'type', 'query', 'status', 'subscribed', 'posterFrames', 'description', 'view']
response = {}
for key in keys:
if key == 'items':

View file

@ -106,7 +106,7 @@ pandora.ui.folderList = function(id, section) {
operator: '+',
tooltip: function(data) {
return data.type == 'static'
? (data.user == pandora.user.username ? Ox._('Edit Default View') : Ox._('Default View: ...'))
? (data.user == pandora.user.username ? Ox._('Edit {0}', [Ox._(folderItem)]) : '')
: data.type == 'smart'
? (data.user == pandora.user.username ? Ox._('Edit Query') : Ox._('Show Query'))
: data.type.toUpperCase();
@ -264,7 +264,8 @@ pandora.ui.folderList = function(id, section) {
columns: columns,
droppable: id != 'volumes',
items: items,
keys: ['modified'].concat(section != 'texts' ? ['query', 'name'] : ['rightslevel']),
keys: ['modified'].concat(section != 'texts'
? ['query', 'name', 'view'] : ['rightslevel']),
max: 1,
min: 0,
pageLength: 1000,
@ -314,6 +315,8 @@ pandora.ui.folderList = function(id, section) {
} else if (data.key == 'type') {
if (that.value(data.id, 'type') == 'smart') {
pandora.$ui.listDialog = pandora.ui.listDialog('query').open();
} else {
pandora.$ui.listDialog = pandora.ui.listDialog('general').open();
}
} else if (data.key == 'status') {
var status = that.value(data.id, data.key) == 'private' ? 'public' : 'private';
@ -334,7 +337,7 @@ pandora.ui.folderList = function(id, section) {
pandora.api['unsubscribeFrom' + folderItem]({
id: data.ids[0]
}, function(result) {
Ox.Request.clearCache(); // fixme: remove
Ox.Request.clearCache('findList');
that.reloadList();
});
} else if (id == 'featured' && canEditFeatured) {
@ -343,9 +346,9 @@ pandora.ui.folderList = function(id, section) {
id: data.ids[0],
status: 'public'
}, function(result) {
Ox.Request.clearCache('findList');
// fixme: duplicated
if (result.data.user == pandora.user.username || result.data.subscribed) {
Ox.Request.clearCache(); // fixme: remove
pandora.$ui.folderList[
result.data.user == pandora.user.username ? 'personal' : 'favorite'
].reloadList();
@ -402,10 +405,15 @@ pandora.ui.folderList = function(id, section) {
pandora.UI.set({
find: {
conditions: list ? [
{key: 'list', value: data.ids[0], operator: '=='}
{key: 'list', value: list, operator: '=='}
] : [],
operator: '&'
}
},
listView: list
? pandora.user.ui.lists[list]
? pandora.user.ui.lists[list].view
: that.value(list).view
: void 0
});
} else {
pandora.UI.set(section.slice(0, -1), list);

View file

@ -199,7 +199,20 @@ pandora.ui.listGeneralPanel = function(listData) {
submit: editName
})
.appendTo(that),
$itemsInput = ui.section != 'texts'
$select = (ui.section == 'items'
? Ox.Select({
items: pandora.site.listViews.map(function(view) {
return {id: view.id, title: view.title};
}),
label: Ox._('View'),
labelWidth: 80,
value: listData.view,
width: 320
})
.bindEvent({
change: editView
})
: ui.section != 'texts'
? Ox.Input({
disabled: true,
label: Ox._('Items'),
@ -207,8 +220,6 @@ pandora.ui.listGeneralPanel = function(listData) {
value: listData.items,
width: 320
})
.css({position: 'absolute', left: '160px', top: '40px'})
.appendTo(that)
: Ox.Select({
items: pandora.site.textRightsLevels.map(function(rightsLevel, i) {
console.log(listData);
@ -222,12 +233,13 @@ pandora.ui.listGeneralPanel = function(listData) {
value: listData.rightslevel,
width: 320
})
.css({position: 'absolute', left: '160px', top: '40px'})
.bindEvent({
change: editRightsLevel
})
)
.css({position: 'absolute', left: '160px', top: '40px'})
.appendTo(that),
$statusSelect = listData.status == 'featured'
$statusSelect = (listData.status == 'featured'
? Ox.Input({
disabled: true,
label: Ox._('Status'),
@ -235,8 +247,6 @@ pandora.ui.listGeneralPanel = function(listData) {
value: 'Featured',
width: 320
})
.css({position: 'absolute', left: '160px', top: '64px'})
.appendTo(that)
: Ox.Select({
items: [
{id: 'private', title: Ox._('Private')},
@ -247,10 +257,11 @@ pandora.ui.listGeneralPanel = function(listData) {
value: listData.status,
width: 320
})
.css({position: 'absolute', left: '160px', top: '64px'})
.bindEvent({
change: editStatus
})
)
.css({position: 'absolute', left: '160px', top: '64px'})
.appendTo(that),
$subscribersInput = Ox.Input({
disabled: true,
@ -333,7 +344,23 @@ pandora.ui.listGeneralPanel = function(listData) {
}, function(result) {
Ox.Request.clearCache('getText');
//fixme: reload text and folder list
$itemsInput.value(result.data.rightslevel);
$select.value(result.data.rightslevel);
});
}
function editView(data) {
var view = data.value;
pandora.api.editList({
id: listData.id,
view: view
}, function(result) {
$select.value(result.data.view);
Ox.Request.clearCache('findList');
pandora.$ui.folderList[
result.data.status == 'featured'
? 'featured'
: result.data.user == pandora.user.username
? 'personal' : 'favorite'
].reloadList();
});
}
function getDescriptionHeight() {