Add multiple source fields#223
Conversation
1ec5
left a comment
There was a problem hiding this comment.
This is good to go as soon as the localization issues are resolved. Thanks!
modules/presets/index.js
Outdated
| keys: ['source' + id, 'source' + id + ':url', 'source' + id + ':name', 'source' + id + ':date'], | ||
| key: id, | ||
| keys: [id, id + ':url', id + ':name', id + ':date'], | ||
| overrideLabel: 'Source ' + i, |
modules/presets/index.js
Outdated
| let id = 'source' + (i > 0 ? ':' + i.toString() : ''); | ||
| let previousId = 'source' + ((i-1) > 0 ? ':' + (i-1).toString() : ''); |
There was a problem hiding this comment.
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 the t function and it’ll do the right thing.
There was a problem hiding this comment.
This String.prototype.toString() is being used to define the source:2 key. If the "2" is localized, couldn't that cause problems? With the key ending up like source:٢
There was a problem hiding this comment.
Oh, you’re right, you’re only appending i to “Source” below. So as long as you pass i into the t() call for that field name, it should work fine.
This PR implements multiple source fields.


To use them, a user first has to write something in any of the inputs in the first "Source" field, then go to Add field -> Source 2. If something is written in any "Source 2" input, the user will be able to add "Source 3", and so on up to "Source 4".
The first source field will still be mapped to source=* / source:name=* , while the next source fields will be mapped to source:2=* / source:2:name=*