Sha256: ccf19247a433cf205e6d8ee7c4a55616a753b68042eca72b8ae43fe56a6f5de9
Contents?: true
Size: 1.13 KB
Versions: 12
Compression:
Stored size: 1.13 KB
Contents
import { Controller } from '@hotwired/stimulus' import { castBoolean } from '../helpers/cast_boolean' export default class extends Controller { static targets = ['controllerDiv', 'resourceIds', 'form', 'selectedAllQuery'] connect() { this.resourceIdsTarget.value = this.resourceIds // This value is picked up from the DOM so we check true/false as strings if (this.selectionOptions.itemSelectAllSelectedAllValue === 'true') { this.selectedAllQueryTarget.value = this.selectionOptions.itemSelectAllSelectedAllQueryValue } 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(this.selectionOptions.selectedResources) } catch (error) { return [] } } get selectionOptions() { return document.querySelector(`[data-selected-resources-name="${this.resourceName}"]`).dataset } }
Version data entries
12 entries across 12 versions & 1 rubygems