Closes #330, Attachment title should be editable

Currently uses an annoying popup window, since the code used in the regular metadata pane has too much baggage to use here -- it really should be abstracted into an XBL binding, but that won't be an easy feat

Also fixes SQL error opening popup notes and JS strict warnings when saving them
This commit is contained in:
Dan Stillman 2006-10-04 06:57:49 +00:00
parent 47b765121f
commit 5c6fcf8e28
2 changed files with 26 additions and 4 deletions

View File

@ -29,17 +29,17 @@ function onLoad()
if(ref.isNote()) if(ref.isNote())
{ {
noteEditor.note = ref; noteEditor.note = ref;
window.title = "Edit Note"; document.title = "Edit Note";
} }
else else
{ {
noteEditor.item = ref; noteEditor.item = ref;
window.title = "Add Note"; document.title = "Add Note";
} }
} }
else else
{ {
window.title = "Add Note"; document.title = "Add Note";
if(collectionID && collectionID != '' && collectionID != 'undefined') if(collectionID && collectionID != '' && collectionID != 'undefined')
noteEditor.collection = Zotero.Collections.get(collectionID); noteEditor.collection = Zotero.Collections.get(collectionID);
} }

View File

@ -244,14 +244,22 @@ var ZoteroPane = new function()
noteEditor.item = null; noteEditor.item = null;
noteEditor.note = item.ref; noteEditor.note = item.ref;
document.getElementById('zotero-view-note-button').setAttribute('noteID',item.ref.getID()); document.getElementById('zotero-view-note-button').setAttribute('noteID',item.ref.getID());
if(item.ref.getSource() != null) if(item.ref.getSource())
{
document.getElementById('zotero-view-note-button').setAttribute('sourceID',item.ref.getSource()); document.getElementById('zotero-view-note-button').setAttribute('sourceID',item.ref.getSource());
}
else else
{
document.getElementById('zotero-view-note-button').removeAttribute('sourceID'); document.getElementById('zotero-view-note-button').removeAttribute('sourceID');
}
document.getElementById('item-pane').selectedIndex = 2; document.getElementById('item-pane').selectedIndex = 2;
} }
else if(item.isAttachment()) else if(item.isAttachment())
{ {
// DEBUG: this is annoying -- we really want to use an abstracted
// version of createValueElement() from itemPane.js
// (ideally in an XBL binding)
// Wrap title to multiple lines if necessary // Wrap title to multiple lines if necessary
var label = document.getElementById('zotero-attachment-label'); var label = document.getElementById('zotero-attachment-label');
while (label.hasChildNodes()) while (label.hasChildNodes())
@ -259,6 +267,7 @@ var ZoteroPane = new function()
label.removeChild(label.firstChild); label.removeChild(label.firstChild);
} }
var val = item.getField('title'); var val = item.getField('title');
var firstSpace = val.indexOf(" "); var firstSpace = val.indexOf(" ");
// Crop long uninterrupted text // Crop long uninterrupted text
if ((firstSpace == -1 && val.length > 29 ) || firstSpace > 29) if ((firstSpace == -1 && val.length > 29 ) || firstSpace > 29)
@ -272,6 +281,18 @@ var ZoteroPane = new function()
label.appendChild(document.createTextNode(val)); label.appendChild(document.createTextNode(val));
} }
// For the time being, use a silly little popup
label.className = 'clicky';
label.onclick = function(event){
var newTitle = prompt(Zotero.getString('itemFields.title') + ':', val);
if (newTitle && newTitle != val)
{
item.ref.setField('title', newTitle);
item.ref.save();
}
}
// Metadata for URL's // Metadata for URL's
if (item.ref.getAttachmentLinkMode() == Zotero.Attachments.LINK_MODE_LINKED_URL if (item.ref.getAttachmentLinkMode() == Zotero.Attachments.LINK_MODE_LINKED_URL
|| item.ref.getAttachmentLinkMode() == Zotero.Attachments.LINK_MODE_IMPORTED_URL) || item.ref.getAttachmentLinkMode() == Zotero.Attachments.LINK_MODE_IMPORTED_URL)
@ -334,6 +355,7 @@ var ZoteroPane = new function()
} }
/* /*
* _force_ deletes item from DB even if removing from a collection or search * _force_ deletes item from DB even if removing from a collection or search
*/ */