generated from hmcts/expressjs-template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workaround for ministryofjustice/moj-frontend#343 and ignore js files…
… copied to make MoJ frontend library work
- Loading branch information
Taoufik Mohdit
authored and
Taoufik Mohdit
committed
Apr 11, 2022
1 parent
f150b00
commit f418fe0
Showing
5 changed files
with
37 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* This is a workaround for https://github.com/ministryofjustice/moj-frontend/issues/343 | ||
* For the workaround to work, add buttons using MoJ add-another library have to have their HTML ids added to | ||
* addButtonsIds list. | ||
* The logic below may have to be adjusted if the duplicated/added item has different error classes. | ||
* Once the issue above addressed, MoJ library can be upgraded and this workaround can be discarded. | ||
*/ | ||
const addButtonIds = [ | ||
'add-another-court-order', | ||
]; | ||
|
||
addButtonIds.forEach(addButtonId => document.getElementById(addButtonId).addEventListener('click', () => { | ||
[...document.getElementsByClassName('govuk-error-summary')] | ||
.forEach(errorSummary => errorSummary.classList.add('hide')); | ||
[...document.getElementsByClassName('govuk-error-message')] | ||
.forEach(errorMessage => errorMessage.classList.add('hide')); | ||
[...document.getElementsByClassName('govuk-input--error')] | ||
.forEach(inputError => inputError.classList.remove('govuk-input--error')); | ||
[...document.getElementsByClassName('govuk-form-group--error')] | ||
.forEach(errorMessage => { | ||
errorMessage.classList.add('govuk-form-group'); | ||
errorMessage.classList.remove('govuk-form-group--error'); | ||
}); | ||
})); |
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,7 +1,12 @@ | ||
@import '~govuk-frontend'; | ||
|
||
.moj-add-another { | ||
// sass-lint:disable class-name-format | ||
&__remove-button { | ||
display: none; | ||
} | ||
} | ||
|
||
.hide { | ||
display: none; | ||
} |
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,8 +1,9 @@ | ||
import './assets/scss/main.scss'; | ||
import './assets/js/postcode-lookup.js'; | ||
import './assets/js/append-row.js'; | ||
import { initAll } from 'govuk-frontend'; | ||
import './assets/js/jquery'; | ||
import './assets/js/mojAll'; | ||
import './assets/js/remove-error-content'; | ||
import { initAll } from 'govuk-frontend'; | ||
|
||
initAll(); |
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