Browse Source
* Add standard task for linting JavaScript * Lint JavaScript * Pin govuk-frontend to v4.0.1pull/670/head
Paul Robert Lloyd
3 years ago
committed by
GitHub
15 changed files with 1060 additions and 148 deletions
@ -1,22 +1,23 @@ |
|||||||
// This file is automatically compiled by Webpack, along with any other files
|
// This file is automatically compiled by Webpack, along with any other files
|
||||||
// present in this directory. You're encouraged to place your actual application logic in
|
// present in this directory. You're encouraged to place your actual application
|
||||||
// a relevant structure within app/javascript and only use these pack files to reference
|
// logic in a relevant structure within app/javascript and only use these pack
|
||||||
// that code so it'll be compiled.
|
// files to reference that code so it'll be compiled.
|
||||||
|
|
||||||
// Polyfills for IE
|
// Polyfills for IE
|
||||||
import "@webcomponents/webcomponentsjs" |
import '@webcomponents/webcomponentsjs' |
||||||
import "core-js/stable" |
import 'core-js/stable' |
||||||
import "regenerator-runtime/runtime" |
import 'regenerator-runtime/runtime' |
||||||
import "@stimulus/polyfills" |
import '@stimulus/polyfills' |
||||||
import "custom-event-polyfill" |
import 'custom-event-polyfill' |
||||||
import "intersection-observer" |
import 'intersection-observer' |
||||||
|
|
||||||
//
|
//
|
||||||
|
import GOVUKFrontend from 'govuk-frontend' |
||||||
|
import GOVUKPrototypeComponents from 'govuk-prototype-components' |
||||||
|
import './styles/application.scss' |
||||||
|
import './controllers' |
||||||
|
|
||||||
require.context("govuk-frontend/govuk/assets") |
require.context('govuk-frontend/govuk/assets') |
||||||
import GOVUKFrontend from "govuk-frontend" |
|
||||||
import GOVUKPrototypeComponents from "govuk-prototype-components" |
|
||||||
import "./styles/application.scss" |
|
||||||
import "./controllers" |
|
||||||
|
|
||||||
GOVUKFrontend.initAll() |
GOVUKFrontend.initAll() |
||||||
GOVUKPrototypeComponents.initAll() |
GOVUKPrototypeComponents.initAll() |
||||||
|
@ -1,10 +1,10 @@ |
|||||||
import { Application } from "@hotwired/stimulus" |
import { Application } from '@hotwired/stimulus' |
||||||
|
|
||||||
const application = Application.start() |
const application = Application.start() |
||||||
|
|
||||||
// Configure Stimulus development experience
|
// Configure Stimulus development experience
|
||||||
application.warnings = true |
application.warnings = true |
||||||
application.debug = false |
application.debug = false |
||||||
window.Stimulus = application |
window.Stimulus = application |
||||||
|
|
||||||
export { application } |
export { application } |
||||||
|
@ -1,13 +1,13 @@ |
|||||||
import { Controller } from "@hotwired/stimulus" |
import { Controller } from '@hotwired/stimulus' |
||||||
|
|
||||||
export default class extends Controller { |
export default class extends Controller { |
||||||
initialize() { |
initialize () { |
||||||
this.clearIfHidden() |
this.clearIfHidden() |
||||||
} |
} |
||||||
|
|
||||||
clearIfHidden() { |
clearIfHidden () { |
||||||
if(this.element.style["display"] == "none") { |
if (this.element.style.display === 'none') { |
||||||
this.element.value = "" |
this.element.value = '' |
||||||
} |
} |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -1,36 +1,36 @@ |
|||||||
import { Controller } from "@hotwired/stimulus" |
import { Controller } from '@hotwired/stimulus' |
||||||
|
|
||||||
export default class extends Controller { |
export default class extends Controller { |
||||||
initialize() { |
initialize () { |
||||||
this.displayConditional() |
this.displayConditional() |
||||||
} |
} |
||||||
|
|
||||||
displayConditional() { |
displayConditional () { |
||||||
if(this.element.checked) { |
if (this.element.checked) { |
||||||
let selectedValue = this.element.value |
const selectedValue = this.element.value |
||||||
let conditional_for = JSON.parse(this.element.dataset.info) |
const conditionalFor = JSON.parse(this.element.dataset.info) |
||||||
Object.entries(conditional_for).map(([targetQuestion, conditions]) => { |
|
||||||
if(conditions.map(String).includes(String(selectedValue))) { |
Object.entries(conditionalFor).forEach(([targetQuestion, conditions]) => { |
||||||
|
if (!conditions.map(String).includes(String(selectedValue))) { |
||||||
|
const textNumericInput = document.getElementById(`case-log-${targetQuestion.replaceAll('_', '-')}-field`) |
||||||
|
if (textNumericInput == null) { |
||||||
|
const dateInputs = [1, 2, 3].map((idx) => { |
||||||
|
return document.getElementById(`case_log_${targetQuestion}_${idx}i`) |
||||||
|
}) |
||||||
|
this.clearDateInputs(dateInputs) |
||||||
} else { |
} else { |
||||||
const textNumericInput = document.getElementById(`case-log-${targetQuestion.replaceAll("_","-")}-field`) |
this.clearTextNumericInput(textNumericInput) |
||||||
if (textNumericInput == null) { |
|
||||||
const dateInputs = [1,2,3].map((idx) => { |
|
||||||
return document.getElementById(`case_log_${targetQuestion}_${idx}i`) |
|
||||||
}) |
|
||||||
this.clearDateInputs(dateInputs) |
|
||||||
} else { |
|
||||||
this.clearTextNumericInput(textNumericInput) |
|
||||||
} |
} |
||||||
} |
} |
||||||
}) |
}) |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
clearTextNumericInput(input) { |
clearTextNumericInput (input) { |
||||||
input.value = "" |
input.value = '' |
||||||
} |
} |
||||||
|
|
||||||
clearDateInputs(inputs) { |
clearDateInputs (inputs) { |
||||||
inputs.forEach((input) => { input.value = "" }) |
inputs.forEach((input) => { input.value = '' }) |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -1,22 +1,22 @@ |
|||||||
// Load all the controllers within this directory and all subdirectories.
|
// Load all the controllers within this directory and all subdirectories.
|
||||||
// Controller files must be named *_controller.js.
|
// Controller files must be named *_controller.js.
|
||||||
|
|
||||||
import { application } from "./application" |
import { application } from './application' |
||||||
|
|
||||||
import AccessibleAutocompleteController from "./accessible_autocomplete_controller.js" |
import AccessibleAutocompleteController from './accessible_autocomplete_controller.js' |
||||||
application.register("accessible-autocomplete", AccessibleAutocompleteController) |
|
||||||
|
|
||||||
import ConditionalFilterController from "./conditional_filter_controller.js" |
import ConditionalFilterController from './conditional_filter_controller.js' |
||||||
application.register("conditional-filter", ConditionalFilterController) |
|
||||||
|
|
||||||
import ConditionalQuestionController from "./conditional_question_controller.js" |
import ConditionalQuestionController from './conditional_question_controller.js' |
||||||
application.register("conditional-question", ConditionalQuestionController) |
|
||||||
|
|
||||||
import GovukfrontendController from "./govukfrontend_controller.js" |
import GovukfrontendController from './govukfrontend_controller.js' |
||||||
application.register("govukfrontend", GovukfrontendController) |
|
||||||
|
|
||||||
import NumericQuestionController from "./numeric_question_controller.js" |
import NumericQuestionController from './numeric_question_controller.js' |
||||||
application.register("numeric-question", NumericQuestionController) |
|
||||||
|
|
||||||
import FilterLayoutController from "./filter_layout_controller.js" |
import FilterLayoutController from './filter_layout_controller.js' |
||||||
application.register("filter-layout", FilterLayoutController) |
application.register('accessible-autocomplete', AccessibleAutocompleteController) |
||||||
|
application.register('conditional-filter', ConditionalFilterController) |
||||||
|
application.register('conditional-question', ConditionalQuestionController) |
||||||
|
application.register('govukfrontend', GovukfrontendController) |
||||||
|
application.register('numeric-question', NumericQuestionController) |
||||||
|
application.register('filter-layout', FilterLayoutController) |
||||||
|
Loading…
Reference in new issue