Sha256: fc16ef8d96b6ec52b190e78f9aba74e8708194c47fbb75e998577d3e18c3f5c0

Contents?: true

Size: 807 Bytes

Versions: 20

Compression:

Stored size: 807 Bytes

Contents

import { Controller } from '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

20 entries across 20 versions & 1 rubygems

Version Path
avo-1.22.2 app/javascript/js/controllers/action_controller.js
avo-1.22.1 app/javascript/js/controllers/action_controller.js
avo-1.22.1.pre.2 app/javascript/js/controllers/action_controller.js
avo-1.22.1.pre.1 app/javascript/js/controllers/action_controller.js
avo-1.22.0 app/javascript/js/controllers/action_controller.js
avo-1.22.0.pre.1 app/javascript/js/controllers/action_controller.js
avo-1.21.1.pre.1 app/javascript/js/controllers/action_controller.js
avo-1.21.0 app/javascript/js/controllers/action_controller.js
avo-1.20.2.pre.2 app/javascript/js/controllers/action_controller.js
avo-1.20.2.pre.1 app/javascript/js/controllers/action_controller.js
avo-1.21.0.pre.1 app/javascript/js/controllers/action_controller.js
avo-1.20.1 app/javascript/js/controllers/action_controller.js
avo-1.19.1.pre.11 app/javascript/js/controllers/action_controller.js
avo-1.19.1.pre.10 app/javascript/js/controllers/action_controller.js
avo-1.19.1.pre.9 app/javascript/js/controllers/action_controller.js
avo-1.19.1.pre.8 app/javascript/js/controllers/action_controller.js
avo-1.19.1.pre.7 app/javascript/js/controllers/action_controller.js
avo-1.19.1.pre.6 app/javascript/js/controllers/action_controller.js
avo-1.19.1.pre.5 app/javascript/js/controllers/action_controller.js
avo-1.19.1.pre.4 app/javascript/js/controllers/action_controller.js