-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add multiple source fields #223
Changes from 2 commits
da502df
60c767b
6fbf70e
577fb55
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -60,6 +60,22 @@ function addHistoricalFields(fields) { | |||||||||
fields.source.type = 'source'; | ||||||||||
fields.source.source = false; | ||||||||||
fields.source.keys = ['source', 'source:url', 'source:name', 'source:date']; | ||||||||||
|
||||||||||
for (let i = 1; i < 4; i++){ | ||||||||||
let id = 'source' + (i > 0 ? ':' + i.toString() : ''); | ||||||||||
let previousId = 'source' + ((i-1) > 0 ? ':' + (i-1).toString() : ''); | ||||||||||
fields[id] = { | ||||||||||
...fields.source, | ||||||||||
key: id, | ||||||||||
keys: [id, id + ':url', id + ':name', id + ':date'], | ||||||||||
overrideLabel: 'Source ' + i, | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This still needs to be localized. You can define a format string in the localization and pass in the number as a parameter to replace the token in the format string: Lines 766 to 767 in cb779ea
Line 5 in cb779ea
Line 219 in cb779ea
/ref #224 |
||||||||||
prerequisiteTag: { | ||||||||||
keys: [ | ||||||||||
previousId, | ||||||||||
previousId + ':url', | ||||||||||
previousId + ':name', | ||||||||||
previousId + ':date']}}; | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
fields.license = { | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor:
String.prototype.toString()
is suitable for Western languages, but not for some other languages we support, like Persian.Number.prototype.toLocaleString
automatically adapts the number to the given writing system. Fortunately, you can just pass a number into thet
function and it’ll do the right thing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
String.prototype.toString()
is being used to define thesource:2
key. If the "2" is localized, couldn't that cause problems? With the key ending up likesource:٢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, you’re right, you’re only appending
i
to “Source” below. So as long as you passi
into thet()
call for that field name, it should work fine.