Fixes #447, Disable tags and related on abstracts
New methods: Item.removeAllRelated() Item.removeAllTags() Also: - Tag selector didn't initialize properly if it was closed when Firefox was started - Items pane would lose open state of items and current scroll position when an item was edited while the tag selector was open -- added save/rememberOpenState() and save/rememberFirstRow() to fix this, and these could also fairly easily be used to remember the open state while switching between collections
This commit is contained in:
parent
be2abdf397
commit
1b675ecc7e
|
@ -23,7 +23,12 @@
|
|||
<bindings xmlns="http://www.mozilla.org/xbl"
|
||||
xmlns:xbl="http://www.mozilla.org/xbl"
|
||||
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<binding id="note-editor">
|
||||
<resources>
|
||||
<stylesheet src="chrome://zotero/skin/bindings/noteeditor.css"/>
|
||||
</resources>
|
||||
|
||||
<implementation>
|
||||
<field name="itemRef">null</field>
|
||||
<property name="item" onget="return this.itemRef;">
|
||||
|
@ -103,8 +108,7 @@
|
|||
</body>
|
||||
</method>
|
||||
</implementation>
|
||||
<handlers>
|
||||
</handlers>
|
||||
|
||||
<content>
|
||||
<xul:vbox xbl:inherits="flex">
|
||||
<xul:label id="citeLabel"/>
|
||||
|
|
|
@ -301,8 +301,6 @@
|
|||
<parameter name="clear"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
Zotero.debug(clear);
|
||||
|
||||
var textbox = this.id('tags-search');
|
||||
var t = textbox.inputField;
|
||||
|
||||
|
|
|
@ -39,6 +39,10 @@ function onLoad()
|
|||
var id = params['id'];
|
||||
var collectionID = params['coll'];
|
||||
|
||||
if (params['abstract']) {
|
||||
noteEditor.setAttribute('abstract', true);
|
||||
}
|
||||
|
||||
if(id && id != '' && id != 'undefined')
|
||||
{
|
||||
var ref = Zotero.Items.get(id);
|
||||
|
|
|
@ -322,7 +322,6 @@ var ZoteroPane = new function()
|
|||
// If showing, set scope to items in current view
|
||||
// and focus filter textbox
|
||||
if (collapsed) {
|
||||
tagSelector.init();
|
||||
_setTagScope();
|
||||
tagSelector.focusTextbox();
|
||||
}
|
||||
|
@ -406,6 +405,7 @@ var ZoteroPane = new function()
|
|||
{
|
||||
document.getElementById('zotero-view-note-button').removeAttribute('sourceID');
|
||||
}
|
||||
document.getElementById('zotero-note-editor').setAttribute('abstract', item.ref.isAbstract());
|
||||
document.getElementById('zotero-item-pane-content').selectedIndex = 2;
|
||||
}
|
||||
else if(item.isAttachment())
|
||||
|
@ -1180,7 +1180,15 @@ var ZoteroPane = new function()
|
|||
|
||||
function openNoteWindow(id, parent)
|
||||
{
|
||||
window.open('chrome://zotero/content/note.xul?v=1'+(id ? '&id='+id : '')+(parent ? '&coll='+parent : ''),'','chrome,resizable,centerscreen');
|
||||
if (id) {
|
||||
var item = Zotero.Items.get(id)
|
||||
}
|
||||
if (item) {
|
||||
var isAbstract = item.isAbstract();
|
||||
}
|
||||
window.open('chrome://zotero/content/note.xul?v=1' + (id ? '&id=' + id : '')
|
||||
+ (parent ? '&coll=' + parent : '') + (isAbstract ? '&abstract=1' : ''),
|
||||
'', 'chrome,resizable,centerscreen');
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1249,6 +1249,9 @@ Zotero.Item.prototype.setAbstract = function(set) {
|
|||
var sql = "UPDATE itemNotes SET isAbstract=? WHERE itemID=?";
|
||||
Zotero.DB.valueQuery(sql, [set ? 1 : null, this.getID()]);
|
||||
|
||||
this.removeAllRelated();
|
||||
this.removeAllTags();
|
||||
|
||||
Zotero.DB.commitTransaction();
|
||||
|
||||
this._noteIsAbstract = !!set;
|
||||
|
@ -1531,6 +1534,10 @@ Zotero.Item.prototype.addTag = function(tag){
|
|||
throw ('Cannot add tag to unsaved item in Item.addTag()');
|
||||
}
|
||||
|
||||
if (this.isAbstract()) {
|
||||
throw ('Cannot add tag to abstract note');
|
||||
}
|
||||
|
||||
if (!tag){
|
||||
Zotero.debug('Not saving empty tag in Item.addTag()', 2);
|
||||
return false;
|
||||
|
@ -1559,6 +1566,10 @@ Zotero.Item.prototype.addTagByID = function(tagID) {
|
|||
throw ('Cannot add tag to unsaved item in Item.addTagByID()');
|
||||
}
|
||||
|
||||
if (this.isAbstract()) {
|
||||
throw ('Cannot add tag to abstract note');
|
||||
}
|
||||
|
||||
if (!tagID) {
|
||||
Zotero.debug('Not saving nonexistent tag in Item.addTagByID()', 2);
|
||||
return false;
|
||||
|
@ -1644,6 +1655,18 @@ Zotero.Item.prototype.removeTag = function(tagID){
|
|||
Zotero.Notifier.trigger('modify', 'item', this.getID());
|
||||
}
|
||||
|
||||
Zotero.Item.prototype.removeAllTags = function(){
|
||||
if (!this.getID()) {
|
||||
throw ('Cannot remove tags on unsaved item');
|
||||
}
|
||||
|
||||
Zotero.DB.beginTransaction();
|
||||
Zotero.DB.query("DELETE FROM itemTags WHERE itemID=?", this.getID());
|
||||
Zotero.Tags.purge();
|
||||
Zotero.DB.commitTransaction();
|
||||
Zotero.Notifier.trigger('modify', 'item', this.getID());
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Methods dealing with See Also links
|
||||
|
@ -1656,6 +1679,10 @@ Zotero.Item.prototype.addSeeAlso = function(itemID){
|
|||
return false;
|
||||
}
|
||||
|
||||
if (this.isAbstract()) {
|
||||
throw ('Cannot add Related item to abstract note');
|
||||
}
|
||||
|
||||
Zotero.DB.beginTransaction();
|
||||
|
||||
if (!Zotero.Items.get(itemID)){
|
||||
|
@ -1682,6 +1709,10 @@ Zotero.Item.prototype.addSeeAlso = function(itemID){
|
|||
}
|
||||
|
||||
Zotero.Item.prototype.removeSeeAlso = function(itemID){
|
||||
if (!this.getID()) {
|
||||
throw ('Cannot remove related item of unsaved item');
|
||||
}
|
||||
|
||||
Zotero.DB.beginTransaction();
|
||||
var sql = "DELETE FROM itemSeeAlso WHERE itemID=? AND linkedItemID=?";
|
||||
Zotero.DB.query(sql, [this.getID(), itemID]);
|
||||
|
@ -1691,6 +1722,22 @@ Zotero.Item.prototype.removeSeeAlso = function(itemID){
|
|||
Zotero.Notifier.trigger('modify', 'item', [this.getID(), itemID]);
|
||||
}
|
||||
|
||||
Zotero.Item.prototype.removeAllRelated = function() {
|
||||
if (!this.getID()) {
|
||||
throw ('Cannot remove related items of unsaved item');
|
||||
}
|
||||
|
||||
Zotero.DB.beginTransaction();
|
||||
var relateds = this.getSeeAlso();
|
||||
Zotero.DB.query("DELETE FROM itemSeeAlso WHERE itemID=?", this.getID());
|
||||
Zotero.DB.query("DELETE FROM itemSeeAlso WHERE linkedItemID=?", this.getID());
|
||||
Zotero.DB.commitTransaction();
|
||||
|
||||
if (relateds) {
|
||||
Zotero.Notifier.trigger('modify', 'item', relateds);
|
||||
}
|
||||
}
|
||||
|
||||
Zotero.Item.prototype.getSeeAlso = function(){
|
||||
// Check both ways, using a UNION to take advantage of indexes
|
||||
var sql ="SELECT linkedItemID FROM itemSeeAlso WHERE itemID=?1 UNION "
|
||||
|
|
|
@ -671,6 +671,8 @@ Zotero.ItemTreeView.prototype.deleteSelection = function(eraseChildren, force)
|
|||
Zotero.ItemTreeView.prototype.setFilter = function(type, data) {
|
||||
this.selection.selectEventsSuppressed = true;
|
||||
var savedSelection = this.saveSelection();
|
||||
var savedOpenState = this.saveOpenState();
|
||||
var savedFirstRow = this.saveFirstRow();
|
||||
|
||||
switch (type) {
|
||||
case 'search':
|
||||
|
@ -688,7 +690,9 @@ Zotero.ItemTreeView.prototype.setFilter = function(type, data) {
|
|||
|
||||
this.sort();
|
||||
|
||||
this.rememberOpenState(savedOpenState);
|
||||
this.rememberSelection(savedSelection);
|
||||
this.rememberFirstRow(savedFirstRow);
|
||||
this.selection.selectEventsSuppressed = false;
|
||||
this._treebox.invalidate();
|
||||
//Zotero.debug('Running callbacks in itemTreeView.setFilter()', 4);
|
||||
|
@ -790,6 +794,41 @@ Zotero.ItemTreeView.prototype.rememberSelection = function(selection)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
Zotero.ItemTreeView.prototype.saveOpenState = function() {
|
||||
var ids = [];
|
||||
for (var i=0, len=this.rowCount; i<len; i++) {
|
||||
if (this.isContainer(i) && this.isContainerOpen(i)) {
|
||||
ids.push(this._getItemAtRow(i).ref.getID());
|
||||
}
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
|
||||
Zotero.ItemTreeView.prototype.rememberOpenState = function(ids) {
|
||||
for each(var id in ids) {
|
||||
var row = this._itemRowMap[id];
|
||||
if (!row || !this.isContainer(row) || this.isContainerOpen(row)) {
|
||||
continue;
|
||||
}
|
||||
this.toggleOpenState(row);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Zotero.ItemTreeView.prototype.saveFirstRow = function() {
|
||||
return this._getItemAtRow(this._treebox.getFirstVisibleRow()).ref.getID();
|
||||
}
|
||||
|
||||
|
||||
Zotero.ItemTreeView.prototype.rememberFirstRow = function(firstRow) {
|
||||
if (this._itemRowMap[firstRow]) {
|
||||
this._treebox.scrollToRow(this._itemRowMap[firstRow]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Returns an array of item ids of visible items in current sort order
|
||||
*/
|
||||
|
|
4
chrome/skin/default/zotero/bindings/noteeditor.css
Normal file
4
chrome/skin/default/zotero/bindings/noteeditor.css
Normal file
|
@ -0,0 +1,4 @@
|
|||
noteeditor[abstract="true"] #links
|
||||
{
|
||||
display: none;
|
||||
}
|
Loading…
Reference in New Issue
Block a user