mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-06-24 01:11:15 -04:00
Fix radios helpers
They were using a 'name' property which wasn't being set in the data. Radios share the same name attribute so they can get it from the parent group. Also includes fixes for tests where the original API is used.
This commit is contained in:
@@ -472,8 +472,8 @@ describe("Stick to top/bottom of window when scrolling", () => {
|
||||
// add another sticky element before the form footer
|
||||
radios = helpers.getRadioGroup({
|
||||
cssClasses: ['js-stick-at-top-when-scrolling'],
|
||||
name: 'send-time',
|
||||
label: 'send time',
|
||||
name: 'choose-send-time',
|
||||
label: 'Choose send time',
|
||||
fields: [
|
||||
{
|
||||
label: 'Now',
|
||||
@@ -604,7 +604,7 @@ describe("Stick to top/bottom of window when scrolling", () => {
|
||||
}
|
||||
});
|
||||
|
||||
radios.querySelector('fieldset').insertAdjacentHTML('beforeend', helpers.getRadios(fields));
|
||||
radios.querySelector('fieldset').insertAdjacentHTML('beforeend', helpers.getRadios(fields, 'days'));
|
||||
|
||||
radios.offsetHeight = 475;
|
||||
|
||||
@@ -1146,8 +1146,8 @@ describe("Stick to top/bottom of window when scrolling", () => {
|
||||
// add another sticky element before the form footer
|
||||
radios = helpers.getRadioGroup({
|
||||
cssClasses: ['js-stick-at-bottom-when-scrolling'],
|
||||
name: 'send-time',
|
||||
label: 'Send time',
|
||||
name: 'choose-send-time',
|
||||
label: 'Choose send time',
|
||||
fields: [
|
||||
{
|
||||
label: 'Now',
|
||||
@@ -1280,7 +1280,7 @@ describe("Stick to top/bottom of window when scrolling", () => {
|
||||
}
|
||||
});
|
||||
|
||||
radios.querySelector('fieldset').insertAdjacentHTML('beforeend', helpers.getRadios(fields));
|
||||
radios.querySelector('fieldset').insertAdjacentHTML('beforeend', helpers.getRadios(fields, 'days'));
|
||||
|
||||
radios.offsetHeight = 475;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// helpers for generating patterns of HTML
|
||||
|
||||
function getRadios (fields) {
|
||||
function getRadios (fields, name) {
|
||||
const result = '';
|
||||
|
||||
return fields.map((field, idx) => {
|
||||
@@ -8,8 +8,8 @@ function getRadios (fields) {
|
||||
|
||||
return `
|
||||
<div class="multiple-choice">
|
||||
<input id="choose-${field.name}-1" name="choose-${field.name}-1" type="radio" value="${field.value}" ${field.checked ? 'checked' : ''}>
|
||||
<label class="block-label" for="choose-${field.name}-1">
|
||||
<input id="${name}-1" name="${name}" type="radio" value="${field.value}" ${field.checked ? 'checked' : ''}>
|
||||
<label class="block-label" for="${name}-1">
|
||||
${field.label}
|
||||
</label>
|
||||
</div>`;
|
||||
@@ -22,11 +22,11 @@ function getRadioGroup (data) {
|
||||
data.cssClasses.forEach(cssClass => radioGroup.classList.add(cssClass));
|
||||
radioGroup.innerHTML = `
|
||||
<div class="form-group ">
|
||||
<fieldset id="choose-${data.name}">
|
||||
<fieldset id="${data.name}">
|
||||
<legend class="form-label">
|
||||
Choose ${data.label}
|
||||
${data.label}
|
||||
</legend>
|
||||
${getRadios(data.fields)}
|
||||
${getRadios(data.fields, data.name)}
|
||||
</fieldset>
|
||||
</div>`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user