Closes #91, Add dialog to delete child notes when a source is deleted
Closes #146, ScholarPane.selectItem(id) Closes #147, "Edit in a Separate Window" on a note should select the note's parent item. Addresses #143, Scholar toolbar button to save current page as an independent file in the selected project. - Standalone Files are now added to the current Project. Files added to an item are now actually attached to the item.
This commit is contained in:
parent
426b839e5f
commit
0632cbf5e4
4 changed files with 81 additions and 15 deletions
|
@ -39,10 +39,10 @@
|
||||||
<label id="editpane-files-label"/>
|
<label id="editpane-files-label"/>
|
||||||
<button id="tb-item-files-add" type="menu" label="Add">
|
<button id="tb-item-files-add" type="menu" label="Add">
|
||||||
<menupopup>
|
<menupopup>
|
||||||
<menuitem class="menuitem-iconic" id="tb-item-files-file" label="Add File..." oncommand="ScholarPane.addFileFromDialog();"/>
|
<menuitem class="menuitem-iconic" id="tb-item-files-file" label="Add File..." oncommand="ScholarItemPane.addFileFromDialog();"/>
|
||||||
<menuitem class="menuitem-iconic" id="tb-item-files-link" label="Add Linked File..." oncommand="ScholarPane.addFileFromDialog(true);"/>
|
<menuitem class="menuitem-iconic" id="tb-item-files-link" label="Add Linked File..." oncommand="ScholarItemPane.addFileFromDialog(true);"/>
|
||||||
<menuitem class="menuitem-iconic" id="tb-item-files-snapshot" label="Snapshot Current Page" oncommand="ScholarPane.addFileFromPage();"/>
|
<menuitem class="menuitem-iconic" id="tb-item-files-snapshot" label="Snapshot Current Page" oncommand="ScholarItemPane.addFileFromPage();"/>
|
||||||
<menuitem class="menuitem-iconic" id="tb-item-files-web-link" label="Link to Current Page" oncommand="ScholarPane.addFileFromPage(true);"/>
|
<menuitem class="menuitem-iconic" id="tb-item-files-web-link" label="Link to Current Page" oncommand="ScholarItemPane.addFileFromPage(true);"/>
|
||||||
</menupopup>
|
</menupopup>
|
||||||
</button>
|
</button>
|
||||||
</hbox>
|
</hbox>
|
||||||
|
|
|
@ -141,8 +141,7 @@ Scholar.ItemTreeView.prototype.notify = function(action, type, ids)
|
||||||
|
|
||||||
if(action == 'add')
|
if(action == 'add')
|
||||||
{
|
{
|
||||||
this.selection.select(this._itemRowMap[item.getID()]);
|
this.selectItem(this._itemRowMap[item.getID()]);
|
||||||
this._treebox.ensureRowIsVisible(this._itemRowMap[item.getID()]);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -415,10 +414,27 @@ Scholar.ItemTreeView.prototype.sort = function()
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Select an item
|
||||||
|
*/
|
||||||
|
Scholar.ItemTreeView.prototype.selectItem = function(id)
|
||||||
|
{
|
||||||
|
var item = Scholar.Items.get(id);
|
||||||
|
var row = this._itemRowMap[item.getID()];
|
||||||
|
if(row == null)
|
||||||
|
{
|
||||||
|
this.toggleOpenState(this._itemRowMap[item.getSource()]); //opens the parent of the item
|
||||||
|
row = this._itemRowMap[item.getID()];
|
||||||
|
}
|
||||||
|
|
||||||
|
this.selection.select(row);
|
||||||
|
this._treebox.ensureRowIsVisible(row);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Delete the selection
|
* Delete the selection
|
||||||
*/
|
*/
|
||||||
Scholar.ItemTreeView.prototype.deleteSelection = function()
|
Scholar.ItemTreeView.prototype.deleteSelection = function(eraseChildren)
|
||||||
{
|
{
|
||||||
if(this.selection.count == 0)
|
if(this.selection.count == 0)
|
||||||
return;
|
return;
|
||||||
|
@ -445,7 +461,7 @@ Scholar.ItemTreeView.prototype.deleteSelection = function()
|
||||||
for (var i=0; i<items.length; i++)
|
for (var i=0; i<items.length; i++)
|
||||||
{
|
{
|
||||||
if(this._itemGroup.isLibrary() || !items[i].isRegularItem()) //erase item from DB
|
if(this._itemGroup.isLibrary() || !items[i].isRegularItem()) //erase item from DB
|
||||||
items[i].ref.erase();
|
items[i].ref.erase(eraseChildren);
|
||||||
else if(this._itemGroup.isCollection())
|
else if(this._itemGroup.isCollection())
|
||||||
this._itemGroup.ref.removeItem(items[i].ref.getID());
|
this._itemGroup.ref.removeItem(items[i].ref.getID());
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ var ScholarPane = new function()
|
||||||
this.search = search;
|
this.search = search;
|
||||||
this.getCollectionsView = getCollectionsView;
|
this.getCollectionsView = getCollectionsView;
|
||||||
this.getItemsView = getItemsView;
|
this.getItemsView = getItemsView;
|
||||||
|
this.selectItem = selectItem;
|
||||||
this.getSelectedCollection = getSelectedCollection;
|
this.getSelectedCollection = getSelectedCollection;
|
||||||
this.getSelectedItems = getSelectedItems;
|
this.getSelectedItems = getSelectedItems;
|
||||||
this.buildCollectionContextMenu = buildCollectionContextMenu;
|
this.buildCollectionContextMenu = buildCollectionContextMenu;
|
||||||
|
@ -180,6 +181,10 @@ var ScholarPane = new function()
|
||||||
noteEditor.item = null;
|
noteEditor.item = null;
|
||||||
noteEditor.note = item.ref;
|
noteEditor.note = item.ref;
|
||||||
document.getElementById('scholar-view-note').lastChild.setAttribute('noteID',item.ref.getID());
|
document.getElementById('scholar-view-note').lastChild.setAttribute('noteID',item.ref.getID());
|
||||||
|
if(item.ref.getSource() != null)
|
||||||
|
document.getElementById('scholar-view-note').lastChild.setAttribute('sourceID',item.ref.getSource());
|
||||||
|
else
|
||||||
|
document.getElementById('scholar-view-note').lastChild.removeAttribute('sourceID');
|
||||||
document.getElementById('item-pane').selectedIndex = 2;
|
document.getElementById('item-pane').selectedIndex = 2;
|
||||||
}
|
}
|
||||||
else if(item.isFile())
|
else if(item.isFile())
|
||||||
|
@ -210,8 +215,15 @@ var ScholarPane = new function()
|
||||||
|
|
||||||
function deleteSelectedItem()
|
function deleteSelectedItem()
|
||||||
{
|
{
|
||||||
if(itemsView && itemsView.selection.count > 0 && confirm(Scholar.getString('pane.items.delete')))
|
if(itemsView && itemsView.selection.count > 0)
|
||||||
itemsView.deleteSelection();
|
{
|
||||||
|
var eraseChildren = {};
|
||||||
|
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||||
|
.getService(Components.interfaces.nsIPromptService);
|
||||||
|
|
||||||
|
if(promptService.confirmCheck(window, 'Delete Item', Scholar.getString('pane.items.delete'), 'Erase attached notes and files', eraseChildren))
|
||||||
|
itemsView.deleteSelection(eraseChildren.value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteSelectedCollection()
|
function deleteSelectedCollection()
|
||||||
|
@ -257,6 +269,28 @@ var ScholarPane = new function()
|
||||||
return itemsView;
|
return itemsView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function selectItem(id)
|
||||||
|
{
|
||||||
|
if(itemsView)
|
||||||
|
{
|
||||||
|
if(!itemsView._itemGroup.isLibrary())
|
||||||
|
{
|
||||||
|
//select the Library if the item is not in the current collection
|
||||||
|
|
||||||
|
var item = Scholar.Items.get(id);
|
||||||
|
var collectionID = itemsView._itemGroup.ref.getID();
|
||||||
|
if(!item.isRegularItem())
|
||||||
|
{
|
||||||
|
if(!Scholar.Items.get(item.getSource()).inCollection(collectionID))
|
||||||
|
collectionsView.selection.select(0);
|
||||||
|
}
|
||||||
|
else if(!item.inCollection(collectionID))
|
||||||
|
collectionsView.selection.select(0);
|
||||||
|
}
|
||||||
|
itemsView.selectItem(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getSelectedCollection()
|
function getSelectedCollection()
|
||||||
{
|
{
|
||||||
if(collectionsView.selection.count > 0 && collectionsView.selection.currentIndex != -1)
|
if(collectionsView.selection.count > 0 && collectionsView.selection.currentIndex != -1)
|
||||||
|
@ -358,19 +392,35 @@ var ScholarPane = new function()
|
||||||
|
|
||||||
if(fp.show() == nsIFilePicker.returnOK)
|
if(fp.show() == nsIFilePicker.returnOK)
|
||||||
{
|
{
|
||||||
|
var fileID;
|
||||||
if(link)
|
if(link)
|
||||||
Scholar.Files.linkFromFile(fp.file, id);
|
fileID = Scholar.Files.linkFromFile(fp.file, id);
|
||||||
else
|
else
|
||||||
Scholar.Files.importFromFile(fp.file, id);
|
fileID = Scholar.Files.importFromFile(fp.file, id);
|
||||||
|
|
||||||
|
if(fileID && !id)
|
||||||
|
{
|
||||||
|
var c = getSelectedCollection();
|
||||||
|
if(c)
|
||||||
|
c.addItem(fileID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addFileFromPage(link, id)
|
function addFileFromPage(link, id)
|
||||||
{
|
{
|
||||||
|
var fileID;
|
||||||
if(link)
|
if(link)
|
||||||
Scholar.Files.linkFromDocument(window.content.document, id);
|
fileID = Scholar.Files.linkFromDocument(window.content.document, id);
|
||||||
else
|
else
|
||||||
Scholar.Files.importFromDocument(window.content.document, id);
|
fileID = Scholar.Files.importFromDocument(window.content.document, id);
|
||||||
|
|
||||||
|
if(fileID && !id)
|
||||||
|
{
|
||||||
|
var c = getSelectedCollection();
|
||||||
|
if(c)
|
||||||
|
c.addItem(fileID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -180,7 +180,7 @@
|
||||||
<deck id="scholar-view-item" flex="1"/>
|
<deck id="scholar-view-item" flex="1"/>
|
||||||
<vbox id="scholar-view-note" flex="1">
|
<vbox id="scholar-view-note" flex="1">
|
||||||
<noteeditor id="scholar-note-editor" flex="1"/>
|
<noteeditor id="scholar-note-editor" flex="1"/>
|
||||||
<button label="Edit in a separate window" oncommand="ScholarPane.openNoteWindow(this.getAttribute('noteID'));"/>
|
<button label="Edit in a separate window" oncommand="ScholarPane.openNoteWindow(this.getAttribute('noteID')); if(this.hasAttribute('sourceID')) ScholarPane.selectItem(this.getAttribute('sourceID'));"/>
|
||||||
</vbox>
|
</vbox>
|
||||||
<vbox id="scholar-view-file" flex="1">
|
<vbox id="scholar-view-file" flex="1">
|
||||||
<label id="scholar-file-label"/>
|
<label id="scholar-file-label"/>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue