Added isInTheLast search condition and interface support
This commit is contained in:
parent
e73285ffc5
commit
f91134edd7
|
@ -173,4 +173,62 @@
|
|||
</xul:textbox>
|
||||
</content>
|
||||
</binding>
|
||||
|
||||
|
||||
|
||||
<binding id="search-in-the-last">
|
||||
<implementation>
|
||||
<property name="value">
|
||||
<getter>
|
||||
<![CDATA[
|
||||
var menulist = document.getAnonymousNodes(this)[0].firstChild.nextSibling;
|
||||
|
||||
return document.getAnonymousNodes(this)[0].firstChild.value + ' ' +
|
||||
menulist.firstChild.childNodes[menulist.selectedIndex].getAttribute('value')
|
||||
]]>
|
||||
</getter>
|
||||
<setter>
|
||||
<![CDATA[
|
||||
var [num, units] = val.split(' ');
|
||||
document.getAnonymousNodes(this)[0].firstChild.setAttribute('value', num);
|
||||
|
||||
var menulist = document.getAnonymousNodes(this)[0].firstChild.nextSibling;
|
||||
var menupopup = menulist.firstChild;
|
||||
|
||||
for (var i=0; i<menupopup.childNodes.length; i++){
|
||||
if (menupopup.childNodes[i].value == units)
|
||||
{
|
||||
var selectThis = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
menulist.selectedIndex = selectThis;
|
||||
|
||||
return val;
|
||||
]]>
|
||||
</setter>
|
||||
</property>
|
||||
<method name="id">
|
||||
<parameter name="id"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
return document.getAnonymousNodes(this)[0].getElementsByAttribute('id',id)[0];
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
</implementation>
|
||||
|
||||
<content>
|
||||
<xul:hbox xbl:inherits="flex">
|
||||
<xul:textbox/>
|
||||
<xul:menulist label="days">
|
||||
<xul:menupopup>
|
||||
<xul:menuitem label="&zotero.search.date.units.days;" value="days" selected="true"/>
|
||||
<xul:menuitem label="&zotero.search.date.units.months;" value="months"/>
|
||||
<xul:menuitem label="&zotero.search.date.units.years;" value="years"/>
|
||||
</xul:menupopup>
|
||||
</xul:menulist>
|
||||
</xul:hbox>
|
||||
</content>
|
||||
</binding>
|
||||
</bindings>
|
||||
|
|
|
@ -90,13 +90,12 @@
|
|||
var conditionsBox = this.id('conditions');
|
||||
this.search.removeCondition(id);
|
||||
|
||||
for(var i = 0, len=conditionsBox.childNodes.length; i < len; i++)
|
||||
if(conditionsBox.childNodes[i].conditionID == id)
|
||||
{
|
||||
for (var i = 0, len=conditionsBox.childNodes.length; i < len; i++){
|
||||
if (conditionsBox.childNodes[i].conditionID == id){
|
||||
conditionsBox.removeChild(conditionsBox.childNodes[i]);
|
||||
|
||||
i = len;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
conditionsBox.childNodes[0].id('remove').hidden = (conditionsBox.childNodes.length == 1);
|
||||
]]>
|
||||
|
@ -188,7 +187,7 @@
|
|||
<field name="dontupdate"/>
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
var operators = new Array('is', 'isNot', 'contains', 'doesNotContain', 'isLessThan', 'isGreaterThan', 'isBefore', 'isAfter');
|
||||
var operators = new Array('is', 'isNot', 'contains', 'doesNotContain', 'isLessThan', 'isGreaterThan', 'isBefore', 'isAfter', 'isInTheLast');
|
||||
var operatorsList = this.id('operatorsmenu');
|
||||
|
||||
for(var i in operators)
|
||||
|
@ -257,7 +256,7 @@
|
|||
}
|
||||
|
||||
this.createValueMenu(merged);
|
||||
return;
|
||||
break;
|
||||
|
||||
case 'itemTypeID':
|
||||
var types = Zotero.ItemTypes.getTypes();
|
||||
|
@ -269,25 +268,64 @@
|
|||
delete types[i]['id'];
|
||||
}
|
||||
this.createValueMenu(types);
|
||||
return;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (operatorsList.value=='isInTheLast')
|
||||
{
|
||||
this.id('value-date-age').value = this.value;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// If switching from menu to textbox, clear value
|
||||
if (this.id('valuefield').hidden){
|
||||
this.value = '';
|
||||
this.id('valuefield').value = '';
|
||||
}
|
||||
// If switching between textbox conditions, get loaded value for new one
|
||||
else {
|
||||
this.id('valuefield').value = this.value;
|
||||
}
|
||||
|
||||
// Update field drop-down if applicable
|
||||
this.id('valuefield').update(conditionsMenu.value, this.mode);
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise use a text field
|
||||
this.onOperatorSelected();
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
<method name="onOperatorSelected">
|
||||
<body>
|
||||
<![CDATA[
|
||||
var conditionsMenu = this.id('conditionsmenu');
|
||||
var operatorsList = this.id('operatorsmenu');
|
||||
|
||||
// If switching between menu and textbox, clear value
|
||||
if (this.id('valuefield').hidden){
|
||||
this.value = '';
|
||||
this.id('valuefield').value = '';
|
||||
}
|
||||
else {
|
||||
this.id('valuefield').value = this.value;
|
||||
// Drop-down menu
|
||||
if (conditionsMenu.value=='collectionID' || conditionsMenu.value=='itemTypeID')
|
||||
{
|
||||
this.id('valuefield').hidden = true;
|
||||
this.id('valuemenu').hidden = false;
|
||||
this.id('value-date-age').hidden = true;
|
||||
}
|
||||
|
||||
// Update field drop-down if applicable
|
||||
this.id('valuefield').update(conditionsMenu.value, this.mode);
|
||||
// Textbox + units dropdown for isInTheLast operator
|
||||
if (operatorsList.value=='isInTheLast')
|
||||
{
|
||||
this.id('valuefield').hidden = true;
|
||||
this.id('valuemenu').hidden = true;
|
||||
this.id('value-date-age').hidden = false;
|
||||
}
|
||||
|
||||
this.id('valuefield').hidden = false;
|
||||
this.id('valuemenu').hidden = true;
|
||||
// Textbox
|
||||
else
|
||||
{
|
||||
this.id('valuefield').hidden = false;
|
||||
this.id('valuemenu').hidden = true;
|
||||
this.id('value-date-age').hidden = true;
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
@ -310,8 +348,6 @@
|
|||
{
|
||||
this.id('valuemenu').value = this.value;
|
||||
}
|
||||
this.id('valuefield').hidden = true;
|
||||
this.id('valuemenu').hidden = false;
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
@ -372,6 +408,11 @@
|
|||
}
|
||||
}
|
||||
|
||||
else if (!this.id('value-date-age').hidden)
|
||||
{
|
||||
var value = this.id('value-date-age').value;
|
||||
}
|
||||
|
||||
// Handle special C1234 and S5678 form for
|
||||
// collections and searches
|
||||
else if (this.id('conditionsmenu').value=='collectionID')
|
||||
|
@ -429,13 +470,14 @@
|
|||
<xul:menulist id="conditionsmenu" oncommand="this.parentNode.parentNode.onConditionSelected();">
|
||||
<xul:menupopup/>
|
||||
</xul:menulist>
|
||||
<xul:menulist id="operatorsmenu">
|
||||
<xul:menulist id="operatorsmenu" oncommand="this.parentNode.parentNode.onOperatorSelected()">
|
||||
<xul:menupopup/>
|
||||
</xul:menulist>
|
||||
<xul:zoterosearchtextbox id="valuefield" flex="1"/>
|
||||
<xul:menulist id="valuemenu" flex="1" hidden="true">
|
||||
<xul:menupopup/>
|
||||
</xul:menulist>
|
||||
<xul:zoterosearchagefield id="value-date-age" hidden="true"/>
|
||||
<xul:toolbarbutton id="remove" class="zotero-clicky" label="-" oncommand="this.parentNode.parentNode.onRemoveClicked();"/>
|
||||
<xul:toolbarbutton id="add" class="zotero-clicky" label="+" oncommand="this.parentNode.parentNode.onAddClicked();"/>
|
||||
</xul:hbox>
|
||||
|
|
|
@ -556,6 +556,11 @@ Zotero.Search.prototype._buildQuery = function(){
|
|||
condSQL += '>?';
|
||||
condSQLParams.push({string:condition['value']});
|
||||
break;
|
||||
|
||||
case 'isInTheLast':
|
||||
condSQL += ">DATE('NOW', ?)";
|
||||
condSQLParams.push({string: '-' + condition['value']});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -672,6 +677,7 @@ Zotero.SearchConditions = new function(){
|
|||
isGreaterThan: true,
|
||||
isBefore: true,
|
||||
isAfter: true,
|
||||
isInTheLast: true,
|
||||
|
||||
// Special
|
||||
any: true,
|
||||
|
@ -770,10 +776,11 @@ Zotero.SearchConditions = new function(){
|
|||
is: true,
|
||||
isNot: true,
|
||||
isBefore: true,
|
||||
isAfter: true
|
||||
isAfter: true,
|
||||
isInTheLast: true
|
||||
},
|
||||
table: 'items',
|
||||
field: 'DATE(dateAdded)'
|
||||
field: 'dateAdded'
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -782,10 +789,11 @@ Zotero.SearchConditions = new function(){
|
|||
is: true,
|
||||
isNot: true,
|
||||
isBefore: true,
|
||||
isAfter: true
|
||||
isAfter: true,
|
||||
isInTheLast: true
|
||||
},
|
||||
table: 'items',
|
||||
field: 'DATE(dateModified)'
|
||||
field: 'dateModified'
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -865,10 +873,11 @@ Zotero.SearchConditions = new function(){
|
|||
is: true,
|
||||
isNot: true,
|
||||
isBefore: true,
|
||||
isAfter: true
|
||||
isAfter: true,
|
||||
isInTheLast: true
|
||||
},
|
||||
table: 'itemData',
|
||||
field: 'DATE(value)',
|
||||
field: 'SUBSTR(value, 1, 10)', // use only beginning of multipart dates
|
||||
aliases: ['accessDate', 'date'],
|
||||
template: true // mark for special handling
|
||||
},
|
||||
|
|
|
@ -9,3 +9,7 @@
|
|||
<!ENTITY zotero.search.textModes.phraseBinary "Phrase (incl. binary files)">
|
||||
<!ENTITY zotero.search.textModes.regexp "Regexp">
|
||||
<!ENTITY zotero.search.textModes.regexpCS "Regexp (case-sensitive)">
|
||||
|
||||
<!ENTITY zotero.search.date.units.days "days">
|
||||
<!ENTITY zotero.search.date.units.months "months">
|
||||
<!ENTITY zotero.search.date.units.years "years">
|
||||
|
|
|
@ -211,6 +211,7 @@ searchOperator.isLessThan = is less than
|
|||
searchOperator.isGreaterThan = is greater than
|
||||
searchOperator.isBefore = is before
|
||||
searchOperator.isAfter = is after
|
||||
searchOperator.isInTheLast = is in the last
|
||||
|
||||
searchConditions.collectionID = Collection
|
||||
searchConditions.itemTypeID = Item Type
|
||||
|
|
|
@ -105,6 +105,13 @@ zoterosearchtextbox .toolbarbutton-menu-dropmarker
|
|||
padding:0 2px;
|
||||
}
|
||||
|
||||
zoterosearchagefield
|
||||
{
|
||||
-moz-binding: url('chrome://zotero/content/bindings/searchtextbox.xml#search-in-the-last');
|
||||
}
|
||||
|
||||
|
||||
|
||||
#zotero-editpane-dynamic-fields row, tagsbox row
|
||||
{
|
||||
margin:0 0 1px;
|
||||
|
|
Loading…
Reference in New Issue
Block a user