Skip to content

Commit 4948547

Browse files
authored
Merge pull request #1128 from alphagov/2116-2-week-date
2116: Add option to auto populate reminder date with 2-weeks from today
2 parents ce2172c + 06c1e69 commit 4948547

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

accessibility_monitoring_platform/apps/common/templates/common/amp_date_widget_template.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@
2929
Populate date with one week from today
3030
</span>
3131
</p>
32+
<p class="govuk-body-m amp-margin-top-0 amp-margin-bottom-0">
33+
<span class="amp-control amp-populate-date-2-weeks" tabIndex="0"
34+
dayFieldId="{{ widget.subwidgets.0.attrs.id }}"
35+
monthFieldId="{{ widget.subwidgets.1.attrs.id }}"
36+
yearFieldId="{{ widget.subwidgets.2.attrs.id }}">
37+
Populate date with two weeks from today
38+
</span>
39+
</p>
3240
<p class="govuk-body-m amp-margin-top-0 amp-margin-bottom-0">
3341
<span class="amp-control amp-populate-date-4-weeks" tabIndex="0"
3442
dayFieldId="{{ widget.subwidgets.0.attrs.id }}"

accessibility_monitoring_platform/apps/common/tests/test_forms.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ def test_amp_date_widget_html_includes_populate_future_dates_controls():
138138
assert "amp-populate-date-today" not in html
139139
assert "Populate date with one week from today" in html
140140
assert "amp-populate-date-1-week" in html
141+
assert "Populate date with two weeks from today" in html
142+
assert "amp-populate-date-2-weeks" in html
141143
assert "Populate date with four weeks from today" in html
142144
assert "amp-populate-date-4-weeks" in html
143145
assert "Populate date with 12 weeks from today" in html

common/static/js/populate_date.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Populate date field with today.
33
*/
44
const oneWeekInDays = 7
5+
const twoWeeksInDays = oneWeekInDays * 2
56
const fourWeeksInDays = oneWeekInDays * 4
67
const twelveWeeksInDays = oneWeekInDays * 12
78

@@ -46,6 +47,13 @@ Array.from(populateDateWithOneWeekElements).forEach(function (populateDateElemen
4647
addPopulateDateListeners(populateDateElement, daysOffset)
4748
})
4849

50+
const populateDateWithTwoWeeksElements = document.getElementsByClassName('amp-populate-date-2-weeks')
51+
52+
Array.from(populateDateWithTwoWeeksElements).forEach(function (populateDateElement) {
53+
const daysOffset = twoWeeksInDays
54+
addPopulateDateListeners(populateDateElement, daysOffset)
55+
})
56+
4957
const populateDateWithFourWeeksElements = document.getElementsByClassName('amp-populate-date-4-weeks')
5058

5159
Array.from(populateDateWithFourWeeksElements).forEach(function (populateDateElement) {

0 commit comments

Comments
 (0)