Don't sort Year column by full date
This commit is contained in:
parent
398cf765f5
commit
6ea38df873
1 changed files with 17 additions and 3 deletions
|
@ -1259,6 +1259,7 @@ Zotero.ItemTreeView.prototype.sort = function(itemID)
|
||||||
var collation = Zotero.getLocaleCollation();
|
var collation = Zotero.getLocaleCollation();
|
||||||
|
|
||||||
// Year is really the date field truncated
|
// Year is really the date field truncated
|
||||||
|
var originalColumnField = columnField;
|
||||||
if (columnField == 'year') {
|
if (columnField == 'year') {
|
||||||
columnField = 'date';
|
columnField = 'date';
|
||||||
}
|
}
|
||||||
|
@ -1284,7 +1285,7 @@ Zotero.ItemTreeView.prototype.sort = function(itemID)
|
||||||
|
|
||||||
// Get the display field for a row (which might be a placeholder title)
|
// Get the display field for a row (which might be a placeholder title)
|
||||||
var getField;
|
var getField;
|
||||||
switch (columnField) {
|
switch (originalColumnField) {
|
||||||
case 'title':
|
case 'title':
|
||||||
getField = function (row) {
|
getField = function (row) {
|
||||||
var field;
|
var field;
|
||||||
|
@ -1331,6 +1332,19 @@ Zotero.ItemTreeView.prototype.sort = function(itemID)
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'year':
|
||||||
|
getField = function (row) {
|
||||||
|
var val = row.getField(columnField, unformatted);
|
||||||
|
if (val) {
|
||||||
|
val = val.substr(0, 4);
|
||||||
|
if (val == '0000') {
|
||||||
|
val = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
getField = function (row) row.getField(columnField, unformatted);
|
getField = function (row) row.getField(columnField, unformatted);
|
||||||
}
|
}
|
||||||
|
@ -1348,8 +1362,8 @@ Zotero.ItemTreeView.prototype.sort = function(itemID)
|
||||||
|
|
||||||
switch (columnField) {
|
switch (columnField) {
|
||||||
case 'date':
|
case 'date':
|
||||||
fieldA = a.getField('date', true).substr(0, 10);
|
fieldA = getField(a).substr(0, 10);
|
||||||
fieldB = b.getField('date', true).substr(0, 10);
|
fieldB = getField(b).substr(0, 10);
|
||||||
|
|
||||||
cmp = strcmp(fieldA, fieldB);
|
cmp = strcmp(fieldA, fieldB);
|
||||||
if (cmp !== 0) {
|
if (cmp !== 0) {
|
||||||
|
|
Loading…
Reference in a new issue