Make additional fields available as columns with a submenu (fixes #84)

This commit is contained in:
gracile-fr 2012-03-24 19:39:14 +01:00
parent 83073fd72b
commit 18111dd15d
6 changed files with 435 additions and 7 deletions

View file

@ -0,0 +1,152 @@
<?xml version="1.0"?>
<!--
***** BEGIN LICENSE BLOCK *****
Copyright © 2009 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
-->
<!DOCTYPE bindings SYSTEM "chrome://zotero/locale/zotero.dtd">
<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="extended-columnpicker" display="xul:button"
extends="chrome://global/content/bindings/tree.xml#tree-base">
<content>
<xul:image class="tree-columnpicker-icon"/>
<xul:menupopup anonid="zotero-items-column-main-menu">
<xul:menuseparator/>
<xul:menu label="&zotero.items.moreColumns.label;">
<xul:menupopup anonid="zotero-items-column-sub-menu"/>
</xul:menu>
<xul:menuseparator/>
<xul:menuitem anonid="menuitem"
label="&zotero.items.restoreColumnOrder.label;"/>
</xul:menupopup>
</content>
<implementation implements="nsIAccessibleProvider">
<property name="accessibleType" readonly="true">
<getter>
return Components.interfaces.nsIAccessibleProvider.XULButton;
</getter>
</property>
<method name="buildPopup">
<parameter name="aPopup"/>
<parameter name="bPopup"/>
<body>
<![CDATA[
// We no longer cache the picker content, remove the old content.
while (aPopup.childNodes.length > 4) {
aPopup.removeChild(aPopup.firstChild);
}
while (bPopup.childNodes.length > 0) {
bPopup.removeChild(bPopup.firstChild);
}
var refChild = aPopup.firstChild;
var refChild2 = bPopup.firstChild;
var tree = this.parentNode.parentNode;
for (var currCol = tree.columns.getFirstColumn(); currCol;
currCol = currCol.getNext()) {
var currElement = currCol.element;
// Construct an entry for each column in the row, unless
// it is not being shown.
if ((!currElement.hasAttribute("ignoreincolumnpicker")) &&
(!currElement.hasAttribute("submenu"))) {
var popupChild = document.createElement("menuitem");
popupChild.setAttribute("type", "checkbox");
var columnName = currElement.getAttribute("display") ||
currElement.getAttribute("label");
popupChild.setAttribute("label", columnName);
popupChild.setAttribute("colindex", currCol.index);
if (currElement.getAttribute("hidden") != "true") {
popupChild.setAttribute("checked", "true");
}
if (currCol.primary) {
popupChild.setAttribute("disabled", "true");
}
aPopup.insertBefore(popupChild, refChild);
}
//Idem for the submenu
if ((!currElement.hasAttribute("ignoreincolumnpicker")) &&
(currElement.hasAttribute("submenu"))) {
var popupChild = document.createElement("menuitem");
popupChild.setAttribute("type", "checkbox");
var columnName = currElement.getAttribute("display") ||
currElement.getAttribute("label");
popupChild.setAttribute("label", columnName);
popupChild.setAttribute("colindex", currCol.index);
if (currElement.getAttribute("hidden") != "true") {
popupChild.setAttribute("checked", "true");
}
bPopup.insertBefore(popupChild, refChild2);
}
}
]]>
</body>
</method>
</implementation>
<handlers>
<handler event="command">
<![CDATA[
if (event.originalTarget == this) {
var popup = document.getAnonymousElementByAttribute(this, "anonid",
"zotero-items-column-main-menu");
var popup2 = document.getAnonymousElementByAttribute(this, "anonid",
"zotero-items-column-sub-menu");
this.buildPopup(popup, popup2);
popup.showPopup(this, -1, -1, "popup", "bottomright", "topright");
}
else {
var tree = this.parentNode.parentNode;
tree.stopEditing(true);
var menuitem = document.getAnonymousElementByAttribute(this, "anonid", "menuitem");
if (event.originalTarget == menuitem) {
tree.columns.restoreNaturalOrder();
tree._ensureColumnOrder();
}
else {
var colindex = event.originalTarget.getAttribute("colindex");
var column = tree.columns[colindex];
if (column) {
var element = column.element;
if (element.getAttribute("hidden") == "true") {
element.setAttribute("hidden", "false");
}
else {
element.setAttribute("hidden", "true");
}
}
}
}
]]>
</handler>
</handlers>
</binding>
</bindings>

View file

@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0"?>
<!--
***** BEGIN LICENSE BLOCK *****
@ -78,7 +78,7 @@
<tree id="zotero-items-tree"
enableColumnDrag="true" flex="1" seltype="single"
onselect="Zotero_Citation_Dialog.treeItemSelected();">
<treecols>
<treecols id="zotero-items-columns-header">
<treecol
id="zotero-items-column-title" primary="true"
label="&zotero.items.title_column;"
@ -136,11 +136,13 @@
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-callNumber" hidden="true"
submenu="true"
label="&zotero.items.callNumber_column;"
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-rights" hidden="true"
submenu="true"
label="&zotero.items.rights_column;"
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
@ -153,6 +155,89 @@
id="zotero-items-column-dateModified" hidden="true"
label="&zotero.items.dateModified_column;"
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-archive" hidden="true"
submenu="true"
label="&zotero.items.archive_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-archiveLocation" hidden="true"
submenu="true"
label="&zotero.items.archiveLocation_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-place" hidden="true"
submenu="true"
label="&zotero.items.place_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-volume" hidden="true"
submenu="true"
label="&zotero.items.volume_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-edition" hidden="true"
submenu="true"
label="&zotero.items.edition_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-pages" hidden="true"
submenu="true"
label="&zotero.items.pages_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-issue" hidden="true"
submenu="true"
label="&zotero.items.issue_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-series" hidden="true"
submenu="true"
label="&zotero.items.series_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-seriesTitle" hidden="true"
submenu="true"
label="&zotero.items.seriesTitle_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-court" hidden="true"
submenu="true"
label="&zotero.items.court_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-medium" hidden="true"
submenu="true"
label="&zotero.items.medium_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-genre" hidden="true"
submenu="true"
label="&zotero.items.genre_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-system" hidden="true"
submenu="true"
label="&zotero.items.system_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-extra" hidden="true"
label="&zotero.items.extra_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
</treecols>
<treechildren/>
</tree>

View file

@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0"?>
<!--
***** BEGIN LICENSE BLOCK *****
@ -70,7 +70,7 @@
<tree id="zotero-items-tree"
enableColumnDrag="true" flex="1" seltype="multiple"
onselect="onItemSelected();">
<treecols>
<treecols id="zotero-items-columns-header">
<treecol
id="zotero-items-column-title" primary="true"
label="&zotero.items.title_column;"
@ -128,11 +128,13 @@
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-callNumber" hidden="true"
submenu="true"
label="&zotero.items.callNumber_column;"
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-rights" hidden="true"
submenu="true"
label="&zotero.items.rights_column;"
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
@ -146,6 +148,89 @@
label="&zotero.items.dateModified_column;"
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-archive" hidden="true"
submenu="true"
label="&zotero.items.archive_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-archiveLocation" hidden="true"
submenu="true"
label="&zotero.items.archiveLocation_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-place" hidden="true"
submenu="true"
label="&zotero.items.place_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-volume" hidden="true"
submenu="true"
label="&zotero.items.volume_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-edition" hidden="true"
submenu="true"
label="&zotero.items.edition_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-pages" hidden="true"
submenu="true"
label="&zotero.items.pages_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-issue" hidden="true"
submenu="true"
label="&zotero.items.issue_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-series" hidden="true"
submenu="true"
label="&zotero.items.series_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-seriesTitle" hidden="true"
submenu="true"
label="&zotero.items.seriesTitle_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-court" hidden="true"
submenu="true"
label="&zotero.items.court_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-medium" hidden="true"
submenu="true"
label="&zotero.items.medium_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-genre" hidden="true"
submenu="true"
label="&zotero.items.genre_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-system" hidden="true"
submenu="true"
label="&zotero.items.system_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-extra" hidden="true"
label="&zotero.items.extra_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-hasAttachment"
class="treecol-image"

View file

@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0"?>
<!--
***** BEGIN LICENSE BLOCK *****
@ -341,7 +341,7 @@
ondragdrop="return ZoteroPane_Local.itemsView.onDrop(event)"
oncommand="ZoteroPane_Local.serializePersist()"
flex="1">
<treecols>
<treecols id="zotero-items-columns-header">
<treecol
id="zotero-items-column-title" primary="true"
label="&zotero.items.title_column;"
@ -399,11 +399,13 @@
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-callNumber" hidden="true"
submenu="true"
label="&zotero.items.callNumber_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-rights" hidden="true"
submenu="true"
label="&zotero.items.rights_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
@ -417,6 +419,89 @@
label="&zotero.items.dateModified_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-archive" hidden="true"
submenu="true"
label="&zotero.items.archive_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-archiveLocation" hidden="true"
submenu="true"
label="&zotero.items.archiveLocation_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-place" hidden="true"
submenu="true"
label="&zotero.items.place_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-volume" hidden="true"
submenu="true"
label="&zotero.items.volume_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-edition" hidden="true"
submenu="true"
label="&zotero.items.edition_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-pages" hidden="true"
submenu="true"
label="&zotero.items.pages_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-issue" hidden="true"
submenu="true"
label="&zotero.items.issue_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-series" hidden="true"
submenu="true"
label="&zotero.items.series_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-seriesTitle" hidden="true"
submenu="true"
label="&zotero.items.seriesTitle_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-court" hidden="true"
submenu="true"
label="&zotero.items.court_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-medium" hidden="true"
submenu="true"
label="&zotero.items.medium_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-genre" hidden="true"
submenu="true"
label="&zotero.items.genre_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-system" hidden="true"
submenu="true"
label="&zotero.items.system_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-extra" hidden="true"
label="&zotero.items.extra_column;"
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-hasAttachment"
class="treecol-image"

View file

@ -1,4 +1,4 @@
<!ENTITY zotero.general.optional "(Optional)">
<!ENTITY zotero.general.optional "(Optional)">
<!ENTITY zotero.general.note "Note:">
<!ENTITY zotero.general.selectAll "Select All">
<!ENTITY zotero.general.deselectAll "Deselect All">
@ -56,6 +56,22 @@
<!ENTITY zotero.items.rights_column "Rights">
<!ENTITY zotero.items.dateAdded_column "Date Added">
<!ENTITY zotero.items.dateModified_column "Date Modified">
<!ENTITY zotero.items.extra_column "Extra">
<!ENTITY zotero.items.archive_column "Archive">
<!ENTITY zotero.items.archiveLocation_column "Loc. in Archive">
<!ENTITY zotero.items.place_column "Place">
<!ENTITY zotero.items.volume_column "Volume">
<!ENTITY zotero.items.edition_column "Edition">
<!ENTITY zotero.items.pages_column "Pages">
<!ENTITY zotero.items.issue_column "Issue">
<!ENTITY zotero.items.series_column "Series">
<!ENTITY zotero.items.seriesTitle_column "Series Title">
<!ENTITY zotero.items.court_column "Court">
<!ENTITY zotero.items.medium_column "Medium/Format">
<!ENTITY zotero.items.genre_column "Genre">
<!ENTITY zotero.items.system_column "System">
<!ENTITY zotero.items.moreColumns.label "More Columns">
<!ENTITY zotero.items.restoreColumnOrder.label "Restore Column Order">
<!ENTITY zotero.items.menu.showInLibrary "Show in Library">
<!ENTITY zotero.items.menu.attach.note "Add Note">

View file

@ -151,6 +151,11 @@ zoteroguidancepanel
-moz-binding: url('chrome://zotero/content/bindings/guidancepanel.xml#guidancepanel');
}
#zotero-items-columns-header > treecolpicker
{
-moz-binding: url('chrome://zotero/content/bindings/columnpicker.xml#extended-columnpicker');
}
label.zotero-text-link {
-moz-binding: url('chrome://zotero/content/bindings/text-link.xml#text-link');
-moz-user-focus: normal;