documents panel: make title editable

This commit is contained in:
rolux 2014-01-18 00:43:50 +00:00
parent 94ded9d96b
commit be27aa8208

View file

@ -474,7 +474,7 @@ pandora.ui.documentsPanel = function(options) {
} }
function renderData() { function renderData() {
var $title, $description, var $name, $description,
item = $list.value($list.options('selected')[0]), item = $list.value($list.options('selected')[0]),
editable = item.user == pandora.user.username editable = item.user == pandora.user.username
|| pandora.site.capabilities.canEditDocuments[pandora.user.level], || pandora.site.capabilities.canEditDocuments[pandora.user.level],
@ -482,28 +482,36 @@ pandora.ui.documentsPanel = function(options) {
width = ui.documentSize - 16 - Ox.UI.SCROLLBAR_SIZE; width = ui.documentSize - 16 - Ox.UI.SCROLLBAR_SIZE;
return isItemView return isItemView
? Ox.Element() ? Ox.Element()
.css({textAlign: 'center'})
.append( .append(
Ox.$('<div>').css({height: '16px'}) Ox.$('<div>').css({height: '8px'})
) )
.append( .append(
$title = Ox.EditableContent({ $name = Ox.EditableContent({
editable: false, editable: editable,
value: item.name, value: item.name,
width: width width: width
}) })
.css({ .css({
margin: '0 4px',
textAlign: 'center', textAlign: 'center',
fontWeight: 'bold' fontWeight: 'bold'
}) })
.bindEvent({ .bindEvent({
edit: function() { edit: function() {
$title.options({ $name.options({
width: that.width() width: that.width()
}); });
}, },
submit: function() { submit: function(data) {
// ... pandora.api.editDocument({
name: data.value,
id: item.id,
item: ui.item,
}, function(result) {
$name.options({value: result.data.name});
Ox.Request.clearCache('findDocuments');
$list.reloadList();
});
} }
}) })
) )
@ -512,6 +520,7 @@ pandora.ui.documentsPanel = function(options) {
) )
.append( .append(
$description = Ox.EditableContent({ $description = Ox.EditableContent({
editable: editable,
format: function(value) { format: function(value) {
return '<div class="OxLight" style="text-align: center">' return '<div class="OxLight" style="text-align: center">'
+ value + '</div>'; + value + '</div>';
@ -523,7 +532,7 @@ pandora.ui.documentsPanel = function(options) {
width: width width: width
}) })
.css({ .css({
marginLeft: '8px', margin: '0 8px',
textAlign: 'center' textAlign: 'center'
}) })
.bindEvent({ .bindEvent({