Created
May 29, 2021 22:48
-
-
Save jdlrobson/d4d1cc997edb138015ae05989ffb3dfd to your computer and use it in GitHub Desktop.
Suggested changes for #5186
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/openlibrary/plugins/openlibrary/js/edit.js b/openlibrary/plugins/openlibrary/js/edit.js | |
index 95e467078..7ab4eea08 100644 | |
--- a/openlibrary/plugins/openlibrary/js/edit.js | |
+++ b/openlibrary/plugins/openlibrary/js/edit.js | |
@@ -62,16 +62,16 @@ export function initIdentifierValidation() { | |
} | |
const label = $('#select-id').find(`option[value='${data.name}']`).html(); | |
if (data.value == '') { | |
- return error('#id-errors', 'id-value', dataConfig['You need to give a value to ID.'].replace(/ID/, label)); | |
+ return error('#id-errors', 'id-value', dataConfig.emptyIDError.replace(/ID/, label)); | |
} | |
if (['ocaid'].includes(data.name) && /\s/g.test(data.value)) { | |
- return error('#id-errors', 'id-value', dataConfig['ID ids cannot contain whitespace.'].replace(/ID/, label)); | |
+ return error('#id-errors', 'id-value', dataConfig.whitespaceIDError.replace(/ID/, label)); | |
} | |
if (data.name == 'isbn_10' && data.value.length != 10) { | |
- return error('#id-errors', 'id-value', dataConfig['ID must be exactly 10 characters [0-9] or X.'].replace(/ID/, label)); | |
+ return error('#id-errors', 'id-value', dataConfig.isbn10Error.replace(/ID/, label)); | |
} | |
if (data.name == 'isbn_13' && data.value.replace(/-/g, '').length != 13) { | |
- return error('#id-errors', 'id-value', dataConfig['ID must be exactly 13 digits [0-9]. For example: 978-1-56619-909-4'].replace(/ID/, label)); | |
+ return error('#id-errors', 'id-value', dataConfig.isbn13Error.replace(/ID/, label)); | |
} | |
$('id-errors').hide(); | |
return true; | |
diff --git a/openlibrary/templates/books/edit/edition.html b/openlibrary/templates/books/edit/edition.html | |
index c8638694c..64d9101b8 100644 | |
--- a/openlibrary/templates/books/edit/edition.html | |
+++ b/openlibrary/templates/books/edit/edition.html | |
@@ -403,7 +403,13 @@ $jsdef render_work_autocomplete_item(item): | |
</div> | |
</fieldset> | |
-$ config = ({'Please select an identifier.': _('Please select an identifier.'), 'You need to give a value to ID.': _('You need to give a value to ID.'), 'ID ids cannot contain whitespace.': _('ID ids cannot contain whitespace.'), 'ID must be exactly 10 characters [0-9] or X.': _('ID must be exactly 10 characters [0-9] or X.'), 'ID must be exactly 13 digits [0-9]. For example: 978-1-56619-909-4': _('ID must be exactly 13 digits [0-9]. For example: 978-1-56619-909-4')}) | |
+$ config = ({ | |
+$ 'Please select an identifier.': _('Please select an identifier.'), | |
+$ 'emptyIDError': _('You need to give a value to ID.'), | |
+$ 'whitespaceIDError': _('ID ids cannot contain whitespace.'), | |
+$ 'isbn10Error': _('ID must be exactly 10 characters [0-9] or X.'), | |
+$ 'isbn13Error': _('ID must be exactly 13 digits [0-9]. For example: 978-1-56619-909-4') | |
+$ }) | |
<fieldset class="major" id="identifiers" data-config="$dumps(config)"> | |
<legend>$_("ID Numbers")</legend> | |
<div class="formBack"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment