Sha256: b53728c7c9ba49e68eecf4e3e2b54f9557e2b68297b536a02da75c78074b5dc6

Contents?: true

Size: 1.11 KB

Versions: 19

Compression:

Stored size: 1.11 KB

Contents

import { Controller } from '@hotwired/stimulus'
import Rollbar from 'rollbar'

export default class extends Controller {
  connect () {
    this.element.querySelectorAll('.form-select, .form-control').forEach((slct) => {
      slct.addEventListener('change', (e) => {
        if (e.target.value) {
          slct.classList.remove('is-invalid')
        }
      })
    })
    const errorTitle = this.element.querySelector('.error-title')
    if (errorTitle) {
      const invalidField = document.querySelector('.is-invalid')
      const baseAlert = document.querySelector('.alert-danger')
      if (!invalidField && !baseAlert) {
        const errorTitle = this.element.querySelector('.error-title')
        // FIXME: testear con capybara
        errorTitle.innerText = 'Lo lamentamos mucho pero ocurrió algo inesperado. Por favor, intentá nuevamente o ponete en contacto con nosotros.'
        // FIXME: link a contacto
        const form = this.element.querySelector('form')
        const errorMsg = `${form.id} - ${form.action} - ${form.dataset.errors}`
        console.error(errorMsg)
        Rollbar.error(errorMsg)
      }
    }
  }
}

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
pg_rails-7.0.8.pre.alpha.56 pg_layout/app/javascript/controllers/pg_form_controller.js
pg_rails-7.0.8.pre.alpha.55 pg_layout/app/javascript/controllers/pg_form_controller.js
pg_rails-7.0.8.pre.alpha.54 pg_layout/app/javascript/controllers/pg_form_controller.js
pg_rails-7.0.8.pre.alpha.53 pg_layout/app/javascript/controllers/pg_form_controller.js
pg_rails-7.0.8.pre.alpha.52 pg_layout/app/javascript/controllers/pg_form_controller.js
pg_rails-7.0.8.pre.alpha.51 pg_layout/app/javascript/controllers/pg_form_controller.js
pg_rails-7.0.8.pre.alpha.50 pg_layout/app/javascript/controllers/pg_form_controller.js
pg_rails-7.0.8.pre.alpha.49 pg_layout/app/javascript/controllers/pg_form_controller.js
pg_rails-7.0.8.pre.alpha.48 pg_layout/app/javascript/controllers/pg_form_controller.js
pg_rails-7.0.8.pre.alpha.47 pg_layout/app/javascript/controllers/pg_form_controller.js
pg_rails-7.0.8.pre.alpha.46 pg_layout/app/javascript/controllers/pg_form_controller.js
pg_rails-7.0.8.pre.alpha.45 pg_layout/app/javascript/controllers/pg_form_controller.js
pg_rails-7.0.8.pre.alpha.44 pg_layout/app/javascript/controllers/pg_form_controller.js
pg_rails-7.0.8.pre.alpha.43 pg_layout/app/javascript/controllers/pg_form_controller.js
pg_rails-7.0.8.pre.alpha.42 pg_layout/app/javascript/controllers/pg_form_controller.js
pg_rails-7.0.8.pre.alpha.41 pg_layout/app/javascript/controllers/pg_form_controller.js
pg_rails-7.0.8.pre.alpha.40 pg_layout/app/javascript/controllers/pg_form_controller.js
pg_rails-7.0.8.pre.alpha.39 pg_layout/app/javascript/controllers/pg_form_controller.js
pg_rails-7.0.8.pre.alpha.38 pg_layout/app/javascript/controllers/pg_form_controller.js