display featured edits on home screen

This commit is contained in:
rolux 2014-02-09 08:45:13 +00:00
parent 9c4b31c453
commit 47f59c26ae
2 changed files with 50 additions and 34 deletions

View file

@ -314,24 +314,25 @@ pandora.ui.home = function() {
keys: ['description', 'modified', 'name', 'user'], keys: ['description', 'modified', 'name', 'user'],
sort: [{key: 'position', operator: '+'}] sort: [{key: 'position', operator: '+'}]
}, },
items, lists, texts; items, lists, edits, texts;
pandora.api.findLists(find, function(result) { pandora.api.findLists(find, function(result) {
lists = result.data.items.length; lists = result.data.items.length;
items = result.data.items.map(function(item) { items = result.data.items.map(function(item) {
return Ox.extend(item, {type: 'list'}); return Ox.extend(item, {type: 'list'});
}); });
pandora.api.findEdits(find, function(result) {
edits = result.data.items.length;
items = items.concat(result.data.items.map(function(item) {
return Ox.extend(item, {type: 'edit'});
}));
pandora.api.findTexts(find, function(result) { pandora.api.findTexts(find, function(result) {
texts = result.data.items.length texts = result.data.items.length;
items = items.concat(result.data.items.map(function(item) { items = items.concat(result.data.items.map(function(item) {
return Ox.extend(item, {type: 'text'}); return Ox.extend(item, {type: 'text'});
})); }));
$features.empty(); $features.empty();
show(); show();
return; });
if (featured.lists.length) {
top += 24;
}
show('texts');
}); });
}); });
function show() { function show() {
@ -347,11 +348,16 @@ pandora.ui.home = function() {
$label = Ox.Label({ $label = Ox.Label({
textAlign: 'center', textAlign: 'center',
title: '<b>' + Ox._('Featured ' + ( title: '<b>' + Ox._('Featured ' + (
lists == 1 && texts == 0 ? 'List' lists == 1 && edits == 0 && texts == 0 ? 'List'
: lists == 0 && texts == 1 ? 'Text' : lists == 0 && edits == 1 && texts == 0 ? 'Edit'
: texts == 0 ? 'Lists' : lists == 0 && edits == 0 && texts == 1 ? 'Text'
: lists == 0 ? 'Texts' : edits == 0 && texts == 0 ? 'Lists'
: 'Lists and Texts' : lists == 0 && texts == 0 ? 'Edits'
: lists == 0 && edits == 0 ? 'Texts'
: texts == 0 ? 'Lists and Edits'
: edits == 0 ? 'Lists and Texts'
: lists == 0 ? 'Edits and Texts'
: 'Lists, Edits and Texts'
)) + '</b>', )) + '</b>',
width: 512 width: 512
}) })
@ -602,7 +608,7 @@ pandora.ui.home = function() {
function openItem(i) { function openItem(i) {
that.fadeOutScreen(); that.fadeOutScreen();
pandora.UI.set(Ox.extend({ pandora.UI.set(Ox.extend({
section: items[i].type == 'list' ? 'items' : 'texts', section: items[i].type == 'list' ? 'items' : items[i].type + 's',
page: '' page: ''
}, items[i].type == 'list' ? { }, items[i].type == 'list' ? {
find: { find: {
@ -614,6 +620,8 @@ pandora.ui.home = function() {
}], }],
operator: '&' operator: '&'
} }
} : items[i].type == 'edit' ? {
edit: items[i].user + ':' + items[i].name
} : { } : {
text: items[i].user + ':' + items[i].name text: items[i].user + ':' + items[i].name
})); }));

View file

@ -286,24 +286,25 @@ pandora.ui.home = function() {
keys: ['description', 'modified', 'name', 'user'], keys: ['description', 'modified', 'name', 'user'],
sort: [{key: 'position', operator: '+'}] sort: [{key: 'position', operator: '+'}]
}, },
items, lists, texts; items, lists, edits, texts;
pandora.api.findLists(find, function(result) { pandora.api.findLists(find, function(result) {
lists = result.data.items.length; lists = result.data.items.length;
items = result.data.items.map(function(item) { items = result.data.items.map(function(item) {
return Ox.extend(item, {type: 'list'}); return Ox.extend(item, {type: 'list'});
}); });
pandora.api.findEdits(find, function(result) {
edits = result.data.items.length;
items = items.concat(result.data.items.map(function(item) {
return Ox.extend(item, {type: 'edit'});
}));
pandora.api.findTexts(find, function(result) { pandora.api.findTexts(find, function(result) {
texts = result.data.items.length texts = result.data.items.length;
items = items.concat(result.data.items.map(function(item) { items = items.concat(result.data.items.map(function(item) {
return Ox.extend(item, {type: 'text'}); return Ox.extend(item, {type: 'text'});
})); }));
$features.empty(); $features.empty();
show(); show();
return; });
if (featured.lists.length) {
top += 24;
}
show('texts');
}); });
}); });
function show() { function show() {
@ -319,11 +320,16 @@ pandora.ui.home = function() {
$label = Ox.Label({ $label = Ox.Label({
textAlign: 'center', textAlign: 'center',
title: '<b>' + Ox._('Featured ' + ( title: '<b>' + Ox._('Featured ' + (
lists == 1 && texts == 0 ? 'List' lists == 1 && edits == 0 && texts == 0 ? 'List'
: lists == 0 && texts == 1 ? 'Text' : lists == 0 && edits == 1 && texts == 0 ? 'Edit'
: texts == 0 ? 'Lists' : lists == 0 && edits == 0 && texts == 1 ? 'Text'
: lists == 0 ? 'Texts' : edits == 0 && texts == 0 ? 'Lists'
: 'Lists and Texts' : lists == 0 && texts == 0 ? 'Edits'
: lists == 0 && edits == 0 ? 'Texts'
: texts == 0 ? 'Lists and Edits'
: edits == 0 ? 'Lists and Texts'
: lists == 0 ? 'Edits and Texts'
: 'Lists, Edits and Texts'
)) + '</b>', )) + '</b>',
width: 512 width: 512
}) })
@ -574,7 +580,7 @@ pandora.ui.home = function() {
function openItem(i) { function openItem(i) {
that.fadeOutScreen(); that.fadeOutScreen();
pandora.UI.set(Ox.extend({ pandora.UI.set(Ox.extend({
section: items[i].type == 'list' ? 'items' : 'texts', section: items[i].type == 'list' ? 'items' : items[i].type + 's',
page: '' page: ''
}, items[i].type == 'list' ? { }, items[i].type == 'list' ? {
find: { find: {
@ -586,6 +592,8 @@ pandora.ui.home = function() {
}], }],
operator: '&' operator: '&'
} }
} : items[i].type == 'edit' ? {
edit: items[i].user + ':' + items[i].name
} : { } : {
text: items[i].user + ':' + items[i].name text: items[i].user + ':' + items[i].name
})); }));