diff --git a/app/assets/javascripts/highlightTags.js b/app/assets/javascripts/enhancedTextbox.js similarity index 98% rename from app/assets/javascripts/highlightTags.js rename to app/assets/javascripts/enhancedTextbox.js index 3658c94c4..8adb210f8 100644 --- a/app/assets/javascripts/highlightTags.js +++ b/app/assets/javascripts/enhancedTextbox.js @@ -7,7 +7,7 @@ const tagPattern = /\(\(([^\)\((\?)]+)(\?\?)?([^\)\(]*)\)\)/g; - Modules.HighlightTags = function() { + Modules.EnhancedTextbox = function() { this.start = function(textarea) { diff --git a/app/templates/components/textbox.html b/app/templates/components/textbox.html index 27f1ba378..6929de938 100644 --- a/app/templates/components/textbox.html +++ b/app/templates/components/textbox.html @@ -2,7 +2,7 @@ field, label=None, hint=False, - highlight_tags=False, + highlight_placeholders=False, autofocus=False, autosize=False, colour_preview=False, @@ -35,7 +35,7 @@ {% endif %} {% - if highlight_tags + if highlight_placeholders or autosize %} {% set field_class = 'form-control-{} textbox-highlight-textbox'.format(width) %} {% else %} @@ -48,8 +48,8 @@ %} {{ field( class=field_class, - data_module='highlight-tags' if highlight_tags or autosize else '', - data_highlight_placeholders='true' if highlight_tags else 'false', + data_module='enhanced-textbox' if highlight_placeholders or autosize else '', + data_highlight_placeholders='true' if highlight_placeholders else 'false', rows=rows|string, **kwargs ) }} diff --git a/app/templates/views/edit-email-template.html b/app/templates/views/edit-email-template.html index d09a81d99..ebe027946 100644 --- a/app/templates/views/edit-email-template.html +++ b/app/templates/views/edit-email-template.html @@ -20,8 +20,8 @@
{{ textbox(form.name, width='1-1', hint='Your recipients will not see this', rows=10) }} - {{ textbox(form.subject, width='1-1', highlight_tags=True, rows=2) }} - {{ textbox(form.template_content, highlight_tags=True, width='1-1', rows=8) }} + {{ textbox(form.subject, width='1-1', highlight_placeholders=True, rows=2) }} + {{ textbox(form.template_content, highlight_placeholders=True, width='1-1', rows=8) }} {% if current_user.platform_admin %} {{ radios(form.process_type) }} {% endif %} diff --git a/app/templates/views/edit-letter-template.html b/app/templates/views/edit-letter-template.html index 1e7184f07..ebda08d60 100644 --- a/app/templates/views/edit-letter-template.html +++ b/app/templates/views/edit-letter-template.html @@ -20,8 +20,8 @@
{{ textbox(form.name, width='1-1', hint='Your recipients will not see this', rows=10) }} - {{ textbox(form.subject, width='1-1', highlight_tags=True, rows=2) }} - {{ textbox(form.template_content, highlight_tags=True, width='1-1', rows=8) }} + {{ textbox(form.subject, width='1-1', highlight_placeholders=True, rows=2) }} + {{ textbox(form.template_content, highlight_placeholders=True, width='1-1', rows=8) }} {{ sticky_page_footer( 'Save' ) }} diff --git a/app/templates/views/edit-sms-template.html b/app/templates/views/edit-sms-template.html index 452cf4721..7e7e254f5 100644 --- a/app/templates/views/edit-sms-template.html +++ b/app/templates/views/edit-sms-template.html @@ -22,7 +22,7 @@ {{ textbox(form.name, width='1-1', hint='Your recipients will not see this') }}
- {{ textbox(form.template_content, highlight_tags=True, width='1-1', rows=5) }} + {{ textbox(form.template_content, highlight_placeholders=True, width='1-1', rows=5) }} {% if current_user.platform_admin %} {{ radios(form.process_type) }} {% endif %} diff --git a/app/templates/views/service-settings/letter-contact/add.html b/app/templates/views/service-settings/letter-contact/add.html index e284fa62d..d81c97219 100644 --- a/app/templates/views/service-settings/letter-contact/add.html +++ b/app/templates/views/service-settings/letter-contact/add.html @@ -24,7 +24,7 @@ hint='10 lines maximum', width='1-2', rows=10, - highlight_tags=True + highlight_placeholders=True ) }} {% if not first_contact_block %}
diff --git a/app/templates/views/service-settings/letter-contact/edit.html b/app/templates/views/service-settings/letter-contact/edit.html index b0fcbb80c..cb1a63b87 100644 --- a/app/templates/views/service-settings/letter-contact/edit.html +++ b/app/templates/views/service-settings/letter-contact/edit.html @@ -22,7 +22,7 @@ hint='10 lines maximum', width='1-2', rows=10, - highlight_tags=True + highlight_placeholders=True ) }} diff --git a/app/templates/views/service-settings/set-letter-contact-block.html b/app/templates/views/service-settings/set-letter-contact-block.html index 490c45271..c39064b2f 100644 --- a/app/templates/views/service-settings/set-letter-contact-block.html +++ b/app/templates/views/service-settings/set-letter-contact-block.html @@ -22,7 +22,7 @@ hint='10 lines maximum', width='1-1', rows=10, - highlight_tags=True + highlight_placeholders=True ) }} {{ page_footer('Save') }} {% endcall %} diff --git a/app/templates/views/styleguide.html b/app/templates/views/styleguide.html index 841d8fb97..83570143b 100644 --- a/app/templates/views/styleguide.html +++ b/app/templates/views/styleguide.html @@ -181,7 +181,7 @@

Textbox

{{ textbox(form.username) }} {{ textbox(form.password) }} - {{ textbox(form.message, highlight_tags=True) }} + {{ textbox(form.message, highlight_placeholders=True) }} {{ textbox(form.code, width='1-8') }}

File upload

diff --git a/gulpfile.js b/gulpfile.js index c10a41f28..7a709d142 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -82,7 +82,7 @@ const javascripts = () => { paths.src + 'javascripts/detailsPolyfill.js', paths.src + 'javascripts/apiKey.js', paths.src + 'javascripts/autofocus.js', - paths.src + 'javascripts/highlightTags.js', + paths.src + 'javascripts/enhancedTextbox.js', paths.src + 'javascripts/fileUpload.js', paths.src + 'javascripts/radioSelect.js', paths.src + 'javascripts/updateContent.js', diff --git a/package.json b/package.json index b6ebd1675..54eb79fd4 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ }, "scripts": { "test": "gulp lint && jest --config tests/javascripts/jest.config.js tests/javascripts", + "test-watch": "jest --watch --config tests/javascripts/jest.config.js tests/javascripts", "build": "gulp", "watch": "gulp watch" }, diff --git a/tests/app/main/views/test_templates.py b/tests/app/main/views/test_templates.py index 924636805..9e30730ef 100644 --- a/tests/app/main/views/test_templates.py +++ b/tests/app/main/views/test_templates.py @@ -346,6 +346,8 @@ def test_should_show_page_for_one_template( assert "Template <em>content</em> with & entity" in str( page.select_one('textarea') ) + assert page.select_one('textarea')['data-module'] == 'enhanced-textbox' + assert page.select_one('textarea')['data-highlight-placeholders'] == 'true' assert "priority" not in str(page.select_one('main')) mock_get_service_template.assert_called_with(SERVICE_ONE_ID, template_id, None) diff --git a/tests/javascripts/highlightTags.test.js b/tests/javascripts/enhancedTextbox.test.js similarity index 98% rename from tests/javascripts/highlightTags.test.js rename to tests/javascripts/enhancedTextbox.test.js index a14779230..7f6db2155 100644 --- a/tests/javascripts/highlightTags.test.js +++ b/tests/javascripts/enhancedTextbox.test.js @@ -1,14 +1,14 @@ const helpers = require('./support/helpers.js'); beforeAll(() => { - require('../../app/assets/javascripts/highlightTags.js'); + require('../../app/assets/javascripts/enhancedTextbox.js'); }); afterAll(() => { require('./support/teardown.js'); }); -describe('Highlight tags', () => { +describe('Enhanced textbox', () => { let input; let textarea; @@ -38,11 +38,11 @@ describe('Highlight tags', () => { document.body.innerHTML = `
- +
-
`;