-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show IP ranges and other improvements (#1326)
* Added IP ranges as a hint when adding new ones to an app. Upgraded govuk-frontend and moj-frontend to latest versions * Formatted large ip allowlists so they drop down a line rather than extend over the page * Made formatting simpler. Formatted ip allow list display page a bit better. Fixed styling issues caused by govuk upgrade * Added functionality to show/hide forms marked with data-show-if-selected. Works with checkboxes and radio buttons * reverted to old hint as fixed in html * Removed js from super linter * updated dockerfile to build css correctly * updated dockerfile to import js files * Removed CSS linting * Updated favicon location * Replaced unused class with govuk visually hidden
- Loading branch information
1 parent
a5e8593
commit 2374de6
Showing
19 changed files
with
186 additions
and
54 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{% macro govukHint(params) %} | ||
<span {%- if params.id %} id="{{ params.id }}"{% endif %} class="govuk-hint {%- if params.classes %} {{ params.classes }}{% endif %}" | ||
<div {%- if params.id %} id="{{ params.id }}"{% endif %} class="govuk-hint {%- if params.classes %} {{ params.classes }}{% endif %}" | ||
{%- for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %}> | ||
{{ params.html|default(params.text)|safe }} | ||
</span> | ||
</div> | ||
{% endmacro %} |
38 changes: 38 additions & 0 deletions
38
controlpanel/frontend/static/javascripts/modules/toggle-checkbox-form.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
moj.Modules.toggleCheckboxForm = { | ||
subFormClass: 'checkbox-subform', | ||
selector: 'data-show-if-selected', | ||
hiddenClass: 'govuk-!-display-none', | ||
|
||
init() { | ||
const panels = document.querySelectorAll(`.${this.subFormClass}`); | ||
if (panels) { | ||
this.bindEvents(panels); | ||
} | ||
}, | ||
|
||
bindEvents(panels) { | ||
|
||
panels.forEach(panel => { | ||
const attribute = panel.getAttribute(this.selector); | ||
var formItem = document.querySelector(`[value=${attribute}]`); | ||
|
||
this.setVisibility(panel, formItem.checked); | ||
|
||
formItem.addEventListener('change', () => { | ||
this.togglePanel(panel); | ||
}); | ||
}); | ||
}, | ||
|
||
togglePanel(panel) { | ||
panel.classList.toggle(this.hiddenClass); | ||
}, | ||
|
||
setVisibility(panel, show) { | ||
if (show) { | ||
panel.classList.remove(this.hiddenClass); | ||
} else { | ||
panel.classList.add(this.hiddenClass); | ||
} | ||
} | ||
}; |
55 changes: 55 additions & 0 deletions
55
controlpanel/frontend/static/javascripts/modules/toggle-radio-form.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
moj.Modules.toggleRadioForm = { | ||
panelClass: 'radio-subform', | ||
selector: 'data-show-if-selected', | ||
radioButtonClass: 'govuk-radios__input', | ||
hiddenClass: 'govuk-!-display-none', | ||
|
||
init() { | ||
const panels = document.querySelectorAll(`.${this.panelClass}`); | ||
if (panels) { | ||
this.bindEvents(panels); | ||
} | ||
}, | ||
|
||
bindEvents(panels) { | ||
|
||
const radios = document.querySelectorAll(`.${this.radioButtonClass}`); | ||
|
||
radios.forEach(radio => { | ||
radio.addEventListener('change', () => { | ||
const name = radio.getAttribute('name'); | ||
|
||
document.querySelectorAll(`input[name="${name}"]`).forEach(otherRadio => { | ||
if (otherRadio !== radio) { | ||
// Trigger a custom 'deselect' event on every member of the current radio group except the clicked one... | ||
const event = new Event('deselect'); | ||
otherRadio.dispatchEvent(event); | ||
} | ||
}); | ||
}); | ||
}); | ||
|
||
panels.forEach(panel => { | ||
const attribute = panel.getAttribute(this.selector); | ||
var formItem = document.querySelector(`#${attribute}`); | ||
|
||
this.setVisibility(panel, formItem.checked); | ||
|
||
formItem.addEventListener('change', (event) => { | ||
this.setVisibility(panel, event.target.checked); | ||
}); | ||
|
||
formItem.addEventListener('deselect', (event) => { | ||
this.setVisibility(panel, event.target.checked); | ||
}); | ||
}); | ||
}, | ||
|
||
setVisibility(panel, show) { | ||
if (show) { | ||
panel.classList.remove(this.hiddenClass); | ||
} else { | ||
panel.classList.add(this.hiddenClass); | ||
} | ||
} | ||
}; |
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
Oops, something went wrong.