fix info box for texts, redirect to main text page if text does not exist, dont fail if folder gets removed before init is called
This commit is contained in:
parent
da3f5855ab
commit
1751832dd0
5 changed files with 51 additions and 31 deletions
|
@ -11,6 +11,7 @@ from ox.django.decorators import login_required_json
|
||||||
from ox.django.http import HttpFileResponse
|
from ox.django.http import HttpFileResponse
|
||||||
from ox.django.shortcuts import render_to_json_response, get_object_or_404_json, json_response
|
from ox.django.shortcuts import render_to_json_response, get_object_or_404_json, json_response
|
||||||
from django.db.models import Count, Q, Sum, Max
|
from django.db.models import Count, Q, Sum, Max
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
from item import utils
|
from item import utils
|
||||||
import models
|
import models
|
||||||
|
|
|
@ -39,24 +39,27 @@ pandora.ui.allItems = function() {
|
||||||
})
|
})
|
||||||
.html(pandora.user.ui.section == 'items' ? 'All ' + pandora.site.itemName.plural
|
.html(pandora.user.ui.section == 'items' ? 'All ' + pandora.site.itemName.plural
|
||||||
: pandora.site.site.name + ' ' + Ox.toTitleCase(pandora.user.ui.section))
|
: pandora.site.site.name + ' ' + Ox.toTitleCase(pandora.user.ui.section))
|
||||||
.appendTo(that);
|
.appendTo(that),
|
||||||
|
$items,
|
||||||
|
$clickButton,
|
||||||
|
$uploadButton;
|
||||||
|
|
||||||
if (pandora.user.ui.section == 'items') {
|
if (pandora.user.ui.section == 'items') {
|
||||||
var $items = $('<div>')
|
$items = $('<div>')
|
||||||
.css({
|
.css({
|
||||||
float: 'left',
|
float: 'left',
|
||||||
width: '42px',
|
width: '42px',
|
||||||
margin: '1px 4px 1px 3px',
|
margin: '1px 4px 1px 3px',
|
||||||
textAlign: 'right'
|
textAlign: 'right'
|
||||||
})
|
})
|
||||||
.appendTo(that),
|
.appendTo(that);
|
||||||
$clickButton = Ox.Button({
|
$clickButton = Ox.Button({
|
||||||
style: 'symbol',
|
style: 'symbol',
|
||||||
title: 'click',
|
title: 'click',
|
||||||
type: 'image'
|
type: 'image'
|
||||||
})
|
})
|
||||||
.css({opacity: 0.25})
|
.css({opacity: 0.25})
|
||||||
.appendTo(that),
|
.appendTo(that);
|
||||||
$uploadButton = Ox.Button({
|
$uploadButton = Ox.Button({
|
||||||
style: 'symbol',
|
style: 'symbol',
|
||||||
title: 'upload',
|
title: 'upload',
|
||||||
|
@ -71,7 +74,7 @@ pandora.ui.allItems = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
that.update = function(items) {
|
that.update = function(items) {
|
||||||
$items.html(Ox.formatNumber(items));
|
$items && $items.html(Ox.formatNumber(items));
|
||||||
};
|
};
|
||||||
|
|
||||||
that.resizeElement = function(width) {
|
that.resizeElement = function(width) {
|
||||||
|
|
|
@ -355,13 +355,15 @@ pandora.ui.folderList = function(id) {
|
||||||
},
|
},
|
||||||
*/
|
*/
|
||||||
init: function(data) {
|
init: function(data) {
|
||||||
pandora.site.sectionFolders[ui.section][i].items = data.items;
|
if(pandora.site.sectionFolders[ui.section][i]) {
|
||||||
pandora.$ui.folder[i].$content.css({
|
pandora.site.sectionFolders[ui.section][i].items = data.items;
|
||||||
height: data.items * 16 + 'px'
|
pandora.$ui.folder[i].$content.css({
|
||||||
});
|
height: data.items * 16 + 'px'
|
||||||
pandora.$ui.folderList[id].css({
|
});
|
||||||
height: data.items * 16 + 'px'
|
pandora.$ui.folderList[id].css({
|
||||||
});
|
height: data.items * 16 + 'px'
|
||||||
|
});
|
||||||
|
}
|
||||||
pandora.resizeFolders();
|
pandora.resizeFolders();
|
||||||
},
|
},
|
||||||
move: function(data) {
|
move: function(data) {
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
pandora.ui.info = function() {
|
pandora.ui.info = function() {
|
||||||
|
|
||||||
var ui = pandora.user.ui,
|
var ui = pandora.user.ui,
|
||||||
|
folderItems = ui.section == 'items' ? 'Lists' : Ox.toTitleCase(ui.section),
|
||||||
|
folderItem = folderItems.slice(0, -1),
|
||||||
view = getView(),
|
view = getView(),
|
||||||
|
|
||||||
that = Ox.Element()
|
that = Ox.Element()
|
||||||
|
@ -25,7 +27,8 @@ pandora.ui.info = function() {
|
||||||
) {
|
) {
|
||||||
updateInfo();
|
updateInfo();
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
pandora_text: updateInfo
|
||||||
});
|
});
|
||||||
|
|
||||||
//pandora.$ui.leftPanel && resize();
|
//pandora.$ui.leftPanel && resize();
|
||||||
|
@ -40,7 +43,7 @@ pandora.ui.info = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getId() {
|
function getId() {
|
||||||
return ui.item || (
|
return ui[folderItem.toLowerCase()] || (
|
||||||
ui.listSelection.length
|
ui.listSelection.length
|
||||||
? ui.listSelection[ui.listSelection.length - 1]
|
? ui.listSelection[ui.listSelection.length - 1]
|
||||||
: null
|
: null
|
||||||
|
@ -48,9 +51,13 @@ pandora.ui.info = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getView() {
|
function getView() {
|
||||||
return !getId() ? 'list'
|
return ui.section == 'items'
|
||||||
: !ui.item && pandora.isClipView() ? 'poster'
|
? !getId()
|
||||||
: 'video';
|
? 'list'
|
||||||
|
: !ui.item && pandora.isClipView()
|
||||||
|
? 'poster'
|
||||||
|
: 'video'
|
||||||
|
: folderItem.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
function resizeInfo() {
|
function resizeInfo() {
|
||||||
|
@ -64,7 +71,7 @@ pandora.ui.info = function() {
|
||||||
var id = getId(),
|
var id = getId(),
|
||||||
previousView = view;
|
previousView = view;
|
||||||
view = getView();
|
view = getView();
|
||||||
if (view == 'list') {
|
if (view == 'list' || view == 'text') {
|
||||||
emptyInfo();
|
emptyInfo();
|
||||||
that.append(pandora.$ui.listInfo = pandora.ui.listInfo());
|
that.append(pandora.$ui.listInfo = pandora.ui.listInfo());
|
||||||
previousView == 'video' && resizeInfo();
|
previousView == 'video' && resizeInfo();
|
||||||
|
@ -147,7 +154,7 @@ pandora.ui.info = function() {
|
||||||
|
|
||||||
that.resizeInfo = function() {
|
that.resizeInfo = function() {
|
||||||
var view = getView();
|
var view = getView();
|
||||||
if (view == 'list') {
|
if (view == 'list' || view == 'text') {
|
||||||
pandora.$ui.listInfo.resizeInfo();
|
pandora.$ui.listInfo.resizeInfo();
|
||||||
} else if (view == 'poster') {
|
} else if (view == 'poster') {
|
||||||
pandora.$ui.posterInfo.resizeInfo();
|
pandora.$ui.posterInfo.resizeInfo();
|
||||||
|
@ -160,7 +167,7 @@ pandora.ui.info = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
that.updateListInfo = function() {
|
that.updateListInfo = function() {
|
||||||
getView() == 'list' && that.empty().append(
|
['list', 'text'].indexOf(getView()) > -1 && that.empty().append(
|
||||||
pandora.$ui.listInfo = pandora.ui.listInfo()
|
pandora.$ui.listInfo = pandora.ui.listInfo()
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -170,14 +177,16 @@ pandora.ui.info = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
pandora.ui.listInfo = function() {
|
pandora.ui.listInfo = function() {
|
||||||
|
var ui = pandora.user.ui,
|
||||||
var list = pandora.user.ui._list,
|
folderItems = ui.section == 'items' ? 'Lists' : Ox.toTitleCase(ui.section),
|
||||||
canEditFeaturedLists = pandora.site.capabilities.canEditFeaturedLists[pandora.user.level],
|
folderItem = folderItems.slice(0, -1),
|
||||||
|
list = pandora.user.ui.section == 'items' ? pandora.user.ui._list : ui[folderItem.toLowerCase()],
|
||||||
|
canEditFeaturedLists = pandora.site.capabilities['canEditFeatured' + folderItems][pandora.user.level],
|
||||||
that = $('<div>').css({padding: '16px', textAlign: 'center'}),
|
that = $('<div>').css({padding: '16px', textAlign: 'center'}),
|
||||||
$icon = Ox.Element('<img>')
|
$icon = Ox.Element('<img>')
|
||||||
.attr({
|
.attr({
|
||||||
src: list
|
src: list
|
||||||
? '/list/' + list + '/icon256.jpg?' + Ox.uid()
|
? '/' + folderItem.toLowerCase() + '/' + list + '/icon256.jpg?' + Ox.uid()
|
||||||
: '/static/png/icon.png'
|
: '/static/png/icon.png'
|
||||||
})
|
})
|
||||||
.css(getIconCSS())
|
.css(getIconCSS())
|
||||||
|
@ -190,7 +199,7 @@ pandora.ui.listInfo = function() {
|
||||||
//pandora.api.editList({id: list, description: 'foobbar'}, callback)
|
//pandora.api.editList({id: list, description: 'foobbar'}, callback)
|
||||||
//pandora.api.editPage({name: 'allItems', body: 'foobar'}, callback)
|
//pandora.api.editPage({name: 'allItems', body: 'foobar'}, callback)
|
||||||
if (list) {
|
if (list) {
|
||||||
pandora.api.findLists({
|
pandora.api['find' + folderItems]({
|
||||||
query: {conditions: [{key: 'id', value: list, operator: '=='}]},
|
query: {conditions: [{key: 'id', value: list, operator: '=='}]},
|
||||||
keys: ['description', 'status', 'name', 'user']
|
keys: ['description', 'status', 'name', 'user']
|
||||||
}, function(result) {
|
}, function(result) {
|
||||||
|
@ -232,7 +241,7 @@ pandora.ui.listInfo = function() {
|
||||||
submit: function(data) {
|
submit: function(data) {
|
||||||
data.value = Ox.decodeHTMLEntities(data.value);
|
data.value = Ox.decodeHTMLEntities(data.value);
|
||||||
if (data.value != item.name) {
|
if (data.value != item.name) {
|
||||||
pandora.api.editList({
|
pandora.api['edit' + folderItem]({
|
||||||
id: list,
|
id: list,
|
||||||
name: data.value
|
name: data.value
|
||||||
}, function(result) {
|
}, function(result) {
|
||||||
|
@ -278,12 +287,12 @@ pandora.ui.listInfo = function() {
|
||||||
},
|
},
|
||||||
submit: function(data) {
|
submit: function(data) {
|
||||||
if (data.value != item.description) {
|
if (data.value != item.description) {
|
||||||
pandora.api.editList({
|
pandora.api['edit' + folderItem]({
|
||||||
id: list,
|
id: list,
|
||||||
description: data.value
|
description: data.value
|
||||||
}, function(result) {
|
}, function(result) {
|
||||||
item.description = result.data.description;
|
item.description = result.data.description;
|
||||||
Ox.Request.clearCache('findLists');
|
Ox.Request.clearCache('find' + folderItems);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -293,7 +302,7 @@ pandora.ui.listInfo = function() {
|
||||||
that.append(
|
that.append(
|
||||||
$('<div>')
|
$('<div>')
|
||||||
.css({paddingTop: '16px'})
|
.css({paddingTop: '16px'})
|
||||||
.html('List not found')
|
.html(folderItem + ' not found')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -301,7 +310,10 @@ pandora.ui.listInfo = function() {
|
||||||
that.append(
|
that.append(
|
||||||
$('<div>')
|
$('<div>')
|
||||||
.css({fontWeight: 'bold'})
|
.css({fontWeight: 'bold'})
|
||||||
.html('All ' + pandora.site.itemName.plural)
|
.html(ui.section == 'items'
|
||||||
|
? 'All ' + pandora.site.itemName.plural
|
||||||
|
: pandora.site.site.name + ' ' + folderItems
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,9 @@ pandora.ui.text = function() {
|
||||||
|
|
||||||
function getText(id) {
|
function getText(id) {
|
||||||
pandora.api.getText({id: id}, function(result) {
|
pandora.api.getText({id: id}, function(result) {
|
||||||
if (result.data.type == 'pdf') {
|
if (!result.data) {
|
||||||
|
pandora.UI.set({text: ''});
|
||||||
|
} else if (result.data.type == 'pdf') {
|
||||||
$text && $text.remove();
|
$text && $text.remove();
|
||||||
$text = Ox.Editable({
|
$text = Ox.Editable({
|
||||||
clickLink: pandora.clickLink,
|
clickLink: pandora.clickLink,
|
||||||
|
|
Loading…
Reference in a new issue