Sha256: f203cea8fa8726de431a92b5db02e271a449d8d5d2b41427dd9247d5d9405628

Contents?: true

Size: 798 Bytes

Versions: 2

Compression:

Stored size: 798 Bytes

Contents

import { Controller } from "@hotwired/stimulus"
import { useClickOutside } from 'stimulus-use'

// simple controller to hide/show the filter modal
export default class extends Controller {
  static targets = ["frame"]

  static values = {
    src: String,
    isOpen: {type: Boolean, default: false}
  }

  connect() {
    console.log("Connecting modal controller")
    useClickOutside(this)
  }

  disconnect() {
  }

  open(event) {
    console.log("Opening modal!!!", this.srcValue)
    event.preventDefault()
    this.frameTarget.src = this.srcValue;
    this.isOpenValue = true
  }

  close(event) {
    if (this.isOpenValue) {
      event?.preventDefault()
      this.frameTarget.innerHTML = "";
      this.isOpenValue = false
    }
  }

  clickOutside(event) {
    this.close(event)
  }


}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
refine-rails-2.11.8 app/javascript/controllers/refine/modal-controller.js
refine-rails-2.11.6 app/javascript/controllers/refine/modal-controller.js