Fixes #94, New independent notes do not appear in item view until clicking away from folder and back
Also fixes a lot of other issues regarding independant notes.
This commit is contained in:
parent
2dece39ad3
commit
0991ae230e
5 changed files with 47 additions and 23 deletions
|
@ -122,7 +122,7 @@ ScholarItemPane = new function()
|
||||||
label.setAttribute('crop','end');
|
label.setAttribute('crop','end');
|
||||||
|
|
||||||
box = document.createElement('box');
|
box = document.createElement('box');
|
||||||
box.setAttribute('onclick',"window.open('chrome://scholar/content/note.xul?item="+_itemBeingEdited.getID()+"¬e="+notes[i].getID()+"','','chrome,resizable,centerscreen');");
|
box.setAttribute('onclick',"ScholarPane.openNoteWindow("+notes[i].getID()+");");
|
||||||
box.setAttribute('class','clicky');
|
box.setAttribute('class','clicky');
|
||||||
box.appendChild(icon);
|
box.appendChild(icon);
|
||||||
box.appendChild(label);
|
box.appendChild(label);
|
||||||
|
@ -322,7 +322,7 @@ ScholarItemPane = new function()
|
||||||
|
|
||||||
function addNote()
|
function addNote()
|
||||||
{
|
{
|
||||||
window.open("chrome://scholar/content/note.xul?item="+_itemBeingEdited.getID(),'','chrome,resizable,centerscreen');
|
ScholarPane.openNoteWindow(_itemBeingEdited.getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
function _noteToTitle(text)
|
function _noteToTitle(text)
|
||||||
|
|
|
@ -51,7 +51,7 @@ Scholar.ItemTreeView.prototype.refresh = function()
|
||||||
var newRows = this._itemGroup.getChildItems();
|
var newRows = this._itemGroup.getChildItems();
|
||||||
for(var i = 0; i < newRows.length; i++)
|
for(var i = 0; i < newRows.length; i++)
|
||||||
if(newRows[i])
|
if(newRows[i])
|
||||||
this._showItem(new Scholar.ItemTreeView.TreeRow('item',newRows[i],0,false), i+1); //item ref, before row
|
this._showItem(new Scholar.ItemTreeView.TreeRow(newRows[i],0,false), i+1); //item ref, before row
|
||||||
|
|
||||||
this._refreshHashMap();
|
this._refreshHashMap();
|
||||||
}
|
}
|
||||||
|
@ -113,9 +113,9 @@ Scholar.ItemTreeView.prototype.notify = function(action, type, ids)
|
||||||
{
|
{
|
||||||
var item = Scholar.Items.get(ids);
|
var item = Scholar.Items.get(ids);
|
||||||
|
|
||||||
if((this._itemGroup.isLibrary() || item.inCollection(this._itemGroup.ref.getID())) && this._itemRowMap[ids] == null && !item.isNote())
|
if((this._itemGroup.isLibrary() || item.inCollection(this._itemGroup.ref.getID())) && this._itemRowMap[ids] == null && (!item.isNote() || !item.getNoteSource()))
|
||||||
{
|
{
|
||||||
this._showItem(new Scholar.ItemTreeView.TreeRow('item',item,0,false),this.rowCount);
|
this._showItem(new Scholar.ItemTreeView.TreeRow(item,0,false),this.rowCount);
|
||||||
this._treebox.rowCountChanged(this.rowCount-1,1);
|
this._treebox.rowCountChanged(this.rowCount-1,1);
|
||||||
|
|
||||||
madeChanges = true;
|
madeChanges = true;
|
||||||
|
@ -262,7 +262,7 @@ Scholar.ItemTreeView.prototype.toggleOpenState = function(row)
|
||||||
for(var i = 0; i < newRows.length; i++)
|
for(var i = 0; i < newRows.length; i++)
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
this._showItem(new Scholar.ItemTreeView.TreeRow('note',newRows[i],thisLevel+1,false), row+i+1); //item ref, before row
|
this._showItem(new Scholar.ItemTreeView.TreeRow(newRows[i],thisLevel+1,false), row+i+1); //item ref, before row
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -596,9 +596,8 @@ Scholar.ItemTreeView.prototype.getRowProperties = function(row, prop) { }
|
||||||
Scholar.ItemTreeView.prototype.getColumnProperties = function(col, prop) { }
|
Scholar.ItemTreeView.prototype.getColumnProperties = function(col, prop) { }
|
||||||
Scholar.ItemTreeView.prototype.getCellProperties = function(row, col, prop) { }
|
Scholar.ItemTreeView.prototype.getCellProperties = function(row, col, prop) { }
|
||||||
|
|
||||||
Scholar.ItemTreeView.TreeRow = function(type, ref, level, isOpen)
|
Scholar.ItemTreeView.TreeRow = function(ref, level, isOpen)
|
||||||
{
|
{
|
||||||
this.type = type; //either 'item' or 'note'
|
|
||||||
this.ref = ref; //the item/note associated with this
|
this.ref = ref; //the item/note associated with this
|
||||||
this.level = level;
|
this.level = level;
|
||||||
this.isOpen = isOpen;
|
this.isOpen = isOpen;
|
||||||
|
@ -614,11 +613,13 @@ Scholar.ItemTreeView.TreeRow.prototype.getField = function(field)
|
||||||
if(this.isNote() && field == 'title')
|
if(this.isNote() && field == 'title')
|
||||||
{
|
{
|
||||||
var t = this.ref.getNote();
|
var t = this.ref.getNote();
|
||||||
var n = t.indexOf("\n");
|
if(t)
|
||||||
if(n > -1)
|
{
|
||||||
t = t.substring(0,n);
|
var n = t.indexOf("\n");
|
||||||
return t;
|
if(n > -1)
|
||||||
|
t = t.substring(0,n);
|
||||||
|
return t;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,14 +15,26 @@ function onLoad()
|
||||||
|
|
||||||
params[b[i].substr(0,mid)] = b[i].substr(mid+1);
|
params[b[i].substr(0,mid)] = b[i].substr(mid+1);
|
||||||
}
|
}
|
||||||
item = Scholar.Items.get(params['item']);
|
var id = params['id'];
|
||||||
var noteID = params['note'];
|
|
||||||
|
|
||||||
document.getElementById('info-label').appendChild(document.createTextNode(item.getField('title') + " by " + item.getField('firstCreator')));
|
if(id && id != '' && id != 'undefined')
|
||||||
if(noteID)
|
|
||||||
{
|
{
|
||||||
note = Scholar.Items.get(noteID);
|
var ref = Scholar.Items.get(id);
|
||||||
_notesField.setAttribute('value',note.getNote());
|
if(ref.isNote())
|
||||||
|
{
|
||||||
|
note = ref;
|
||||||
|
if(note.getNoteSource())
|
||||||
|
item = Scholar.Items.get(note.getNoteSource());
|
||||||
|
|
||||||
|
_notesField.setAttribute('value',note.getNote());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
item = ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(item)
|
||||||
|
document.getElementById('info-label').appendChild(document.createTextNode(item.getField('title') + " by " + item.getField('firstCreator')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,13 +45,16 @@ function onUnload()
|
||||||
|
|
||||||
function save()
|
function save()
|
||||||
{
|
{
|
||||||
if(note)
|
if(note) //Update note
|
||||||
{
|
{
|
||||||
note.updateNote(_notesField.value);
|
note.updateNote(_notesField.value);
|
||||||
}
|
}
|
||||||
else
|
else //Create new note
|
||||||
{
|
{
|
||||||
var noteID = Scholar.Notes.add(_notesField.value,item.getID());
|
if(item)
|
||||||
|
var noteID = Scholar.Notes.add(_notesField.value,item.getID()); //attached to an item
|
||||||
|
else
|
||||||
|
var noteID = Scholar.Notes.add(_notesField.value); //independant note
|
||||||
note = Scholar.Items.get(noteID);
|
note = Scholar.Items.get(noteID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ var ScholarPane = new function()
|
||||||
this.getItemsView = getItemsView;
|
this.getItemsView = getItemsView;
|
||||||
this.buildCollectionContextMenu = buildCollectionContextMenu;
|
this.buildCollectionContextMenu = buildCollectionContextMenu;
|
||||||
this.buildItemContextMenu = buildItemContextMenu;
|
this.buildItemContextMenu = buildItemContextMenu;
|
||||||
|
this.openNoteWindow = openNoteWindow;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Called when the window is open
|
* Called when the window is open
|
||||||
|
@ -127,7 +128,7 @@ var ScholarPane = new function()
|
||||||
|
|
||||||
if(item.isNote())
|
if(item.isNote())
|
||||||
{
|
{
|
||||||
|
document.getElementById('scholar-view-note').lastChild.setAttribute('noteID',item.ref.getID());
|
||||||
document.getElementById('item-pane').selectedIndex = 2;
|
document.getElementById('item-pane').selectedIndex = 2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -229,6 +230,11 @@ var ScholarPane = new function()
|
||||||
else
|
else
|
||||||
menu.childNodes[2].setAttribute('label', Scholar.getString('pane.items.menu.remove'));
|
menu.childNodes[2].setAttribute('label', Scholar.getString('pane.items.menu.remove'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openNoteWindow(id)
|
||||||
|
{
|
||||||
|
window.open('chrome://scholar/content/note.xul?id='+id,'','chrome,resizable,centerscreen');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener("load", function(e) { ScholarPane.onLoad(e); }, false);
|
window.addEventListener("load", function(e) { ScholarPane.onLoad(e); }, false);
|
||||||
|
|
|
@ -70,6 +70,7 @@
|
||||||
<toolbarbutton id="tb-add" tooltiptext="&toolbar.newItem.label;" type="menu">
|
<toolbarbutton id="tb-add" tooltiptext="&toolbar.newItem.label;" type="menu">
|
||||||
<menupopup/>
|
<menupopup/>
|
||||||
</toolbarbutton>
|
</toolbarbutton>
|
||||||
|
<toolbarbutton label="New Note" oncommand="ScholarPane.openNoteWindow();"/>
|
||||||
<spacer flex="1"/>
|
<spacer flex="1"/>
|
||||||
<toolbarbutton id="tb-item-menu" type="menu" menu="scholar-itemmenu"/>
|
<toolbarbutton id="tb-item-menu" type="menu" menu="scholar-itemmenu"/>
|
||||||
<label value="&toolbar.search.label;" control="tb-search"/>
|
<label value="&toolbar.search.label;" control="tb-search"/>
|
||||||
|
@ -145,6 +146,7 @@
|
||||||
<tabbox id="scholar-view-item" flex="1"/>
|
<tabbox id="scholar-view-item" flex="1"/>
|
||||||
<vbox id="scholar-view-note" flex="1" pack="center" align="center">
|
<vbox id="scholar-view-note" flex="1" pack="center" align="center">
|
||||||
<label>Inline editing: coming soon</label>
|
<label>Inline editing: coming soon</label>
|
||||||
|
<button label="Edit in a separate window" oncommand="ScholarPane.openNoteWindow(this.getAttribute('noteID'));"/>
|
||||||
</vbox>
|
</vbox>
|
||||||
</deck>
|
</deck>
|
||||||
</hbox>
|
</hbox>
|
||||||
|
|
Loading…
Reference in a new issue