Proper fix for getDirection() problems
Hopefully the last fix for my edits to 181afb9
(#4534)
Follow-up to the previous two commits
This commit is contained in:
parent
531e8697be
commit
f5af1898fd
2 changed files with 11 additions and 12 deletions
|
@ -433,13 +433,11 @@ Zotero.ItemFields = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var fieldName = this.getName(fieldName);
|
var fieldName = this.getName(fieldName);
|
||||||
if (!fieldName) {
|
if (fieldName) {
|
||||||
return 'auto';
|
let baseField = this.getBaseIDFromTypeAndField(itemTypeID, fieldName);
|
||||||
}
|
if (baseField) {
|
||||||
|
fieldName = this.getName(baseField);
|
||||||
var baseField = this.getBaseIDFromTypeAndField(itemTypeID, fieldName);
|
}
|
||||||
if (baseField) {
|
|
||||||
fieldName = this.getName(baseField);
|
|
||||||
}
|
}
|
||||||
switch (fieldName) {
|
switch (fieldName) {
|
||||||
// Certain fields containing IDs, numbers, and data: always LTR
|
// Certain fields containing IDs, numbers, and data: always LTR
|
||||||
|
@ -466,7 +464,8 @@ Zotero.ItemFields = new function() {
|
||||||
case 'extra':
|
case 'extra':
|
||||||
return 'ltr';
|
return 'ltr';
|
||||||
|
|
||||||
// Everything else: guess based on the language if we have one; otherwise auto
|
// Everything else (including false): guess based on the language if we have one;
|
||||||
|
// otherwise auto
|
||||||
default:
|
default:
|
||||||
if (itemLanguage) {
|
if (itemLanguage) {
|
||||||
let languageCode = Zotero.Utilities.Item.languageToISO6391(itemLanguage);
|
let languageCode = Zotero.Utilities.Item.languageToISO6391(itemLanguage);
|
||||||
|
|
|
@ -46,12 +46,12 @@ describe("Zotero.ItemFields", function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("#getDirection()", function () {
|
describe("#getDirection()", function () {
|
||||||
it("should return 'auto' for non-field", function () {
|
|
||||||
assert.equal(Zotero.ItemFields.getDirection('book', 'creator-0-lastName', ''), 'auto');
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should follow app locale for primary field", function () {
|
it("should follow app locale for primary field", function () {
|
||||||
assert.equal(Zotero.ItemFields.getDirection('book', 'dateAdded', ''), Zotero.dir)
|
assert.equal(Zotero.ItemFields.getDirection('book', 'dateAdded', ''), Zotero.dir)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should use item language for non-field", function () {
|
||||||
|
assert.equal(Zotero.ItemFields.getDirection('book', 'creator-0-lastName', 'ar'), 'rtl');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue