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): def json(self, keys=None, user=None):
if not keys: 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 = {} response = {}
for key in keys: for key in keys:
if key == 'items': if key == 'items':

View file

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

View file

@ -199,58 +199,69 @@ pandora.ui.listGeneralPanel = function(listData) {
submit: editName submit: editName
}) })
.appendTo(that), .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'),
labelWidth: 80,
value: listData.items,
width: 320
})
: Ox.Select({
items: pandora.site.textRightsLevels.map(function(rightsLevel, i) {
console.log(listData);
return {
id: i,
title: rightsLevel.name,
};
}),
label: Ox._('Rights Level'),
labelWidth: 80,
value: listData.rightslevel,
width: 320
})
.bindEvent({
change: editRightsLevel
})
)
.css({position: 'absolute', left: '160px', top: '40px'})
.appendTo(that),
$statusSelect = (listData.status == 'featured'
? Ox.Input({ ? Ox.Input({
disabled: true, disabled: true,
label: Ox._('Items'), label: Ox._('Status'),
labelWidth: 80, labelWidth: 80,
value: listData.items, value: 'Featured',
width: 320 width: 320
}) })
.css({position: 'absolute', left: '160px', top: '40px'})
.appendTo(that)
: Ox.Select({ : Ox.Select({
items: pandora.site.textRightsLevels.map(function(rightsLevel, i) { items: [
console.log(listData); {id: 'private', title: Ox._('Private')},
return { {id: 'public', title: Ox._('Public')}
id: i, ],
title: rightsLevel.name, label: Ox._('Status'),
};
}),
label: Ox._('Rights Level'),
labelWidth: 80, labelWidth: 80,
value: listData.rightslevel, value: listData.status,
width: 320 width: 320
}) })
.css({position: 'absolute', left: '160px', top: '40px'})
.bindEvent({ .bindEvent({
change: editRightsLevel change: editStatus
}) })
.appendTo(that), )
$statusSelect = listData.status == 'featured'
? Ox.Input({
disabled: true,
label: Ox._('Status'),
labelWidth: 80,
value: 'Featured',
width: 320
})
.css({position: 'absolute', left: '160px', top: '64px'}) .css({position: 'absolute', left: '160px', top: '64px'})
.appendTo(that)
: Ox.Select({
items: [
{id: 'private', title: Ox._('Private')},
{id: 'public', title: Ox._('Public')}
],
label: Ox._('Status'),
labelWidth: 80,
value: listData.status,
width: 320
})
.css({position: 'absolute', left: '160px', top: '64px'})
.bindEvent({
change: editStatus
})
.appendTo(that), .appendTo(that),
$subscribersInput = Ox.Input({ $subscribersInput = Ox.Input({
disabled: true, disabled: true,
@ -333,7 +344,23 @@ pandora.ui.listGeneralPanel = function(listData) {
}, function(result) { }, function(result) {
Ox.Request.clearCache('getText'); Ox.Request.clearCache('getText');
//fixme: reload text and folder list //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() { function getDescriptionHeight() {