Sha256: ee53d39e94256c8e87e6d25cca6c81162d1a85ec118d6c1291fbbf188f9c3f8e

Contents?: true

Size: 645 Bytes

Versions: 14

Compression:

Stored size: 645 Bytes

Contents

import {Controller} from '@hotwired/stimulus'

import {useDebounce} from 'stimulus-use'

// can't use controllerFactory because it  seems to conflict with `useDebounce`
export default class AutoSubmittableController extends Controller<HTMLFormElement> {
  static debounces = ['save']
  static targets = ['form']
  declare readonly formTarget: HTMLFormElement
  declare readonly formTargets: HTMLFormElement[]

  declare readonly hasFormTarget: boolean

  connect(): void {
    useDebounce(this)
  }

  save(): void {
    if (this.hasFormTarget) {
      this.formTarget.requestSubmit()
    } else {
      this.element.requestSubmit()
    }
  }
}

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
ariadne_view_components-0.0.80.3 app/frontend/controllers/autosubmittable_controller.ts
ariadne_view_components-0.0.79.2 app/frontend/controllers/autosubmittable_controller.ts
ariadne_view_components-0.0.79.1 app/frontend/controllers/autosubmittable_controller.ts
ariadne_view_components-0.0.79 app/frontend/controllers/autosubmittable_controller.ts
ariadne_view_components-0.0.78 app/frontend/controllers/autosubmittable_controller.ts
ariadne_view_components-0.0.77 app/frontend/controllers/autosubmittable_controller.ts
ariadne_view_components-0.0.76.1 app/frontend/controllers/autosubmittable_controller.ts
ariadne_view_components-0.0.76 app/frontend/controllers/autosubmittable_controller.ts
ariadne_view_components-0.0.75 app/frontend/controllers/autosubmittable_controller.ts
ariadne_view_components-0.0.74.1 app/frontend/controllers/autosubmittable_controller.ts
ariadne_view_components-0.0.74 app/frontend/controllers/autosubmittable_controller.ts
ariadne_view_components-0.0.73 app/frontend/controllers/autosubmittable_controller.ts
ariadne_view_components-0.0.72 app/frontend/controllers/autosubmittable_controller.ts
ariadne_view_components-0.0.71 app/frontend/controllers/autosubmittable_controller.ts