Sha256: 1cc16e091b88c0763003d577a4f0b31a785dd49e677f5eb9a2af9353d1ed8f4b

Contents?: true

Size: 1.83 KB

Versions: 3

Compression:

Stored size: 1.83 KB

Contents

import ApplicationController from "signum/controllers/application_controller"

export default class extends ApplicationController {

  static targets = ["alertBellIcon", "bellIcon", "submenu", "item", "crossIcon"]

  connect() {
    this.bounditemActivity = this.itemActivity.bind(this)
    window.addEventListener("nd-item-activity", this.bounditemActivity)

    setTimeout(() => {
      this.manageBellIcon()
    }, 300)

  }

  disconnect() {
    window.removeEventListener("nd-item-activity", this.bounditemActivity)
  }

  show(event) {
    if (this.submenuTarget.children.length > 0) {
      this.submenuTarget.classList.remove("hidden")
      this.crossIconTarget.classList.remove("hidden")
    } else {
      this.submenuTarget.classList.add("hidden")
    }
  }

  hide(event) {
    this.submenuTarget.classList.add("hidden")
    this.crossIconTarget.classList.add("hidden")
    if (this.submenuTarget.children.length < 0) {
      this.alertBellIconTarget.classList.add("hidden")
    }
  }

  closeNotifications(event) {
      fetch("/signal/close_all", {
        method: "GET",
        headers: {
          "Content-Type": "application/json",
        },
      })
        .then((res) => {})
        .catch((err) => {
          console.log(err)
        })
      this.crossIconTarget.style.display = 'none';
      this.bellIconTarget.style.display = 'inline-block'
      this.alertBellIconTarget.style.display = 'none';
  }

  itemActivity(event) {
    this.manageBellIcon()

    if (this.submenuTarget.children.length == 0) {
      this.hide(event)
    }
  }

  manageBellIcon() {
    if (this.submenuTarget.children.length > 0) {
      this.alertBellIconTarget.classList.remove("hidden")
      this.bellIconTarget.classList.add("hidden")
    } else {
      this.alertBellIconTarget.classList.add("hidden")
      this.bellIconTarget.classList.remove("hidden")
    }
  }
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
signum-0.7.2 app/components/signum/notification_drawer/component_controller.js
signum-0.7.1 app/components/signum/notification_drawer/component_controller.js
signum-0.7.0 app/components/signum/notification_drawer/component_controller.js