Sha256: 3ad8d73806a4906dbf318df92a399c54cac856be7f7d5bd84c63c7a0b428f048

Contents?: true

Size: 817 Bytes

Versions: 79

Compression:

Stored size: 817 Bytes

Contents

import { Controller } from '@hotwired/stimulus'
import { castBoolean } from '../helpers/cast_boolean'

export default class extends Controller {
  static targets = ['controllerDiv', 'resourceIds', 'form']

  connect() {
    this.resourceIdsTarget.value = this.resourceIds

    if (this.noConfirmation) {
      this.formTarget.submit()
    } else {
      this.controllerDivTarget.classList.remove('hidden')
    }
  }

  get noConfirmation() {
    return castBoolean(this.controllerDivTarget.dataset.noConfirmation)
  }

  get resourceName() {
    return this.controllerDivTarget.dataset.resourceName
  }

  get resourceIds() {
    try {
      return JSON.parse(document.querySelector(`[data-selected-resources-name="${this.resourceName}"]`).dataset.selectedResources)
    } catch (error) {
      return []
    }
  }
}

Version data entries

79 entries across 79 versions & 1 rubygems

Version Path
avo-2.3.1.pre.2 app/javascript/js/controllers/action_controller.js
avo-2.3.1.pre.1 app/javascript/js/controllers/action_controller.js
avo-2.3.0 app/javascript/js/controllers/action_controller.js
avo-2.2.2 app/javascript/js/controllers/action_controller.js
avo-2.2.1 app/javascript/js/controllers/action_controller.js
avo-2.2.0 app/javascript/js/controllers/action_controller.js
avo-2.1.2.pre2 app/javascript/js/controllers/action_controller.js
avo-2.1.2.pre1 app/javascript/js/controllers/action_controller.js
avo-1.25.1 app/javascript/js/controllers/action_controller.js
avo-2.1.1 app/javascript/js/controllers/action_controller.js
avo-2.1.0 app/javascript/js/controllers/action_controller.js
avo-2.0.0 app/javascript/js/controllers/action_controller.js
avo-1.25.0 app/javascript/js/controllers/action_controller.js
avo-1.24.2 app/javascript/js/controllers/action_controller.js
avo-1.24.1 app/javascript/js/controllers/action_controller.js
avo-1.24.0 app/javascript/js/controllers/action_controller.js
avo-1.23.0 app/javascript/js/controllers/action_controller.js
avo-1.22.4 app/javascript/js/controllers/action_controller.js
avo-1.22.3 app/javascript/js/controllers/action_controller.js