clean up item.js

This commit is contained in:
rolux 2012-04-24 08:21:54 +00:00
parent 5b0a8ea03e
commit c0e95624df

View file

@ -64,60 +64,14 @@ pandora.ui.item = function() {
} else if (pandora.user.ui.itemView == 'info') { } else if (pandora.user.ui.itemView == 'info') {
if (pandora.user.level == 'admin' && false) { // FIXME!! pandora.$ui.contentPanel.replaceElement(1,
var $form, pandora.$ui.item = pandora.ui.infoView(result.data)
$edit = Ox.Element() .bindEvent({
.append($form = Ox.FormElementGroup({ resize: function() {
elements: Ox.map(pandora.site.sortKeys, function(key) { pandora.$ui.item.resize();
return Ox.Input({
id: key.id,
label: key.title,
labelWidth: 100,
value: result.data[key.id],
type: 'text',
width: 500
});
}),
separators: [
{title: '', width: 0}
]
}))
.append(Ox.Button({
title: 'Save',
type: 'text'
}).bindEvent({
click: function(data) {
// fixme: cleanup
var values = $form.value();
var changed = {};
Ox.map(pandora.site.itemKeys, function(key, i) {
if(values[i] && values[i] != ''+result.data[key.id]) {
if(Ox.isArray(key.type) && key.type[0] == 'string') {
changed[key.id] = values[i].split(', ');
} else {
changed[key.id] = values[i];
}
}
});
if(changed) {
pandora.api.edit(Ox.extend(changed, {id: pandora.user.ui.item}), function(result) {
//fixme just reload parts that need reloading
window.location.reload();
});
}
} }
})); })
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.item = $edit); );
} else {
pandora.$ui.contentPanel.replaceElement(1,
pandora.$ui.item = pandora.ui.infoView(result.data)
.bindEvent({
resize: function() {
pandora.$ui.item.resize();
}
})
);
}
} else if (pandora.user.ui.itemView == 'clips') { } else if (pandora.user.ui.itemView == 'clips') {
@ -157,12 +111,13 @@ pandora.ui.item = function() {
} else if (pandora.user.ui.itemView == 'data') { } else if (pandora.user.ui.itemView == 'data') {
var stats = Ox.Container(); pandora.$ui.item = Ox.TreeList({
Ox.TreeList({
data: result.data, data: result.data,
width: pandora.$ui.mainPanel.size(1) - Ox.UI.SCROLLBAR_SIZE width: pandora.$ui.mainPanel.size(1) - Ox.UI.SCROLLBAR_SIZE
}).appendTo(stats); });
pandora.$ui.contentPanel.replaceElement(1, stats); pandora.$ui.contentPanel.replaceElement(1,
Ox.Container().append(pandora.$ui.item)
);
} else if (pandora.user.ui.itemView == 'files') { } else if (pandora.user.ui.itemView == 'files') {