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:
parent
24f81cdeae
commit
9efd77724d
3 changed files with 83 additions and 48 deletions
|
@ -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':
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -199,7 +199,20 @@ 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({
|
? Ox.Input({
|
||||||
disabled: true,
|
disabled: true,
|
||||||
label: Ox._('Items'),
|
label: Ox._('Items'),
|
||||||
|
@ -207,8 +220,6 @@ pandora.ui.listGeneralPanel = function(listData) {
|
||||||
value: listData.items,
|
value: listData.items,
|
||||||
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: pandora.site.textRightsLevels.map(function(rightsLevel, i) {
|
||||||
console.log(listData);
|
console.log(listData);
|
||||||
|
@ -222,12 +233,13 @@ pandora.ui.listGeneralPanel = function(listData) {
|
||||||
value: listData.rightslevel,
|
value: listData.rightslevel,
|
||||||
width: 320
|
width: 320
|
||||||
})
|
})
|
||||||
.css({position: 'absolute', left: '160px', top: '40px'})
|
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
change: editRightsLevel
|
change: editRightsLevel
|
||||||
})
|
})
|
||||||
|
)
|
||||||
|
.css({position: 'absolute', left: '160px', top: '40px'})
|
||||||
.appendTo(that),
|
.appendTo(that),
|
||||||
$statusSelect = listData.status == 'featured'
|
$statusSelect = (listData.status == 'featured'
|
||||||
? Ox.Input({
|
? Ox.Input({
|
||||||
disabled: true,
|
disabled: true,
|
||||||
label: Ox._('Status'),
|
label: Ox._('Status'),
|
||||||
|
@ -235,8 +247,6 @@ pandora.ui.listGeneralPanel = function(listData) {
|
||||||
value: 'Featured',
|
value: 'Featured',
|
||||||
width: 320
|
width: 320
|
||||||
})
|
})
|
||||||
.css({position: 'absolute', left: '160px', top: '64px'})
|
|
||||||
.appendTo(that)
|
|
||||||
: Ox.Select({
|
: Ox.Select({
|
||||||
items: [
|
items: [
|
||||||
{id: 'private', title: Ox._('Private')},
|
{id: 'private', title: Ox._('Private')},
|
||||||
|
@ -247,10 +257,11 @@ pandora.ui.listGeneralPanel = function(listData) {
|
||||||
value: listData.status,
|
value: listData.status,
|
||||||
width: 320
|
width: 320
|
||||||
})
|
})
|
||||||
.css({position: 'absolute', left: '160px', top: '64px'})
|
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
change: editStatus
|
change: editStatus
|
||||||
})
|
})
|
||||||
|
)
|
||||||
|
.css({position: 'absolute', left: '160px', top: '64px'})
|
||||||
.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() {
|
||||||
|
|
Loading…
Reference in a new issue