Use only SQL portion of dates to sort
This commit is contained in:
parent
89dbc278bd
commit
820d1cf28f
1 changed files with 19 additions and 3 deletions
|
@ -934,6 +934,23 @@ Zotero.ItemTreeView.prototype.sort = function(itemID)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (columnField) {
|
switch (columnField) {
|
||||||
|
case 'date':
|
||||||
|
fieldA = a.getField('date', true, true).substr(0, 10);
|
||||||
|
fieldB = b.getField('date', true, true).substr(0, 10);
|
||||||
|
|
||||||
|
// Display rows with empty values last
|
||||||
|
cmp = (fieldA == '' && fieldB != '') ? -1 :
|
||||||
|
(fieldA != '' && fieldB == '') ? 1 : 0;
|
||||||
|
if (cmp) {
|
||||||
|
return cmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmp = (fieldA > fieldB) ? -1 : (fieldA < fieldB) ? 1 : 0;
|
||||||
|
if (cmp) {
|
||||||
|
return cmp;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 'type':
|
case 'type':
|
||||||
var typeA = Zotero.getString('itemTypes.'+Zotero.ItemTypes.getName(a.ref.itemTypeID));
|
var typeA = Zotero.getString('itemTypes.'+Zotero.ItemTypes.getName(a.ref.itemTypeID));
|
||||||
var typeB = Zotero.getString('itemTypes.'+Zotero.ItemTypes.getName(b.ref.itemTypeID));
|
var typeB = Zotero.getString('itemTypes.'+Zotero.ItemTypes.getName(b.ref.itemTypeID));
|
||||||
|
@ -988,7 +1005,6 @@ Zotero.ItemTreeView.prototype.sort = function(itemID)
|
||||||
return cmp;
|
return cmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
//cmp = (fieldA > fieldB) ? -1 : (fieldA < fieldB) ? 1 : 0;
|
|
||||||
cmp = collation.compareString(1, fieldB, fieldA);
|
cmp = collation.compareString(1, fieldB, fieldA);
|
||||||
if (cmp) {
|
if (cmp) {
|
||||||
return cmp;
|
return cmp;
|
||||||
|
@ -996,8 +1012,8 @@ Zotero.ItemTreeView.prototype.sort = function(itemID)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (columnField != 'date') {
|
if (columnField != 'date') {
|
||||||
fieldA = a.getField('date', true, true);
|
fieldA = a.getField('date', true, true).substr(0, 10);
|
||||||
fieldB = b.getField('date', true, true);
|
fieldB = b.getField('date', true, true).substr(0, 10);
|
||||||
|
|
||||||
// Display rows with empty values last
|
// Display rows with empty values last
|
||||||
cmp = (fieldA == '' && fieldB != '') ? -1 :
|
cmp = (fieldA == '' && fieldB != '') ? -1 :
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue