Added 'noChildren' search condition and switched main items view to always use a search rather than getItems(), for reasons that will become clear soon

This commit is contained in:
Dan Stillman 2006-11-09 11:12:53 +00:00
parent a871f8977a
commit 7bb4091110
2 changed files with 44 additions and 17 deletions

View File

@ -669,9 +669,9 @@ Zotero.ItemGroup.prototype.getName = function()
Zotero.ItemGroup.prototype.getChildItems = function()
{
if(this.searchText)
{
var s = new Zotero.Search();
var s = new Zotero.Search();
if (this.searchText){
if (this.isCollection())
{
s.addCondition('collectionID', 'is', this.ref.getID(), true);
@ -681,23 +681,26 @@ Zotero.ItemGroup.prototype.getChildItems = function()
s.addCondition('savedSearchID', 'is', this.ref['id'], true);
}
s.addCondition('quicksearch', 'contains', this.searchText);
return Zotero.Items.get(s.search());
}
else
{
if(this.isCollection())
return Zotero.getItems(this.ref.getID());
else if(this.isLibrary())
return Zotero.getItems();
else if(this.isSearch())
{
var s = new Zotero.Search();
s.load(this.ref['id']);
return Zotero.Items.get(s.search());
if (this.isLibrary()){
s.addCondition('noChildren', 'true');
}
else
else if (this.isCollection()){
s.addCondition('noChildren', 'true');
s.addCondition('collectionID', 'is', this.ref.getID());
}
else if (this.isSearch()){
s.load(this.ref['id']);
}
else {
return null;
}
}
var ids = s.search();
return Zotero.Items.get(ids);
}
Zotero.ItemGroup.prototype.setSearch = function(searchText)

View File

@ -361,11 +361,14 @@ Zotero.Search.prototype._buildQuery = function(){
// Handle special conditions
else {
switch (data['name']){
case 'noChildren':
var noChildren = this._conditions[i]['operator']=='true';
// Search subfolders
case 'recursive':
var recursive = this._conditions[i]['operator']=='true';
continue;
// Join mode ('any' or 'all')
case 'joinMode':
var joinMode = this._conditions[i]['operator'].toUpperCase();
@ -388,8 +391,20 @@ Zotero.Search.prototype._buildQuery = function(){
}
}
if (noChildren){
sql += " WHERE (itemID NOT IN (SELECT itemID FROM itemNotes "
+ "WHERE sourceItemID IS NOT NULL) AND itemID NOT IN "
+ "(SELECT itemID FROM itemAttachments "
+ "WHERE sourceItemID IS NOT NULL))";
}
if (hasConditions){
sql += " WHERE ";
if (noChildren){
sql += " AND ";
}
else {
sql += " WHERE ";
}
for each(var condition in conditions){
var openParens = 0;
@ -820,7 +835,16 @@ Zotero.SearchConditions = new function(){
// Special conditions
//
// Search recursively
// Don't include child items
{
name: 'noChildren',
operators: {
true: true,
false: true
}
},
// Search recursively within collections
{
name: 'recursive',
operators: {