Sha256: 7e89a26971388ad6e1667f96b6e7c9a3f56af826abf3481016a15b35b3d12be5
Contents?: true
Size: 1.24 KB
Versions: 24
Compression:
Stored size: 1.24 KB
Contents
import { Controller } from '@hotwired/stimulus' import { castBoolean } from '../helpers/cast_boolean' export default class extends Controller { static targets = ['controllerDiv', 'resourceIds', 'submit', 'selectedAllQuery'] connect() { if (this.resourceIdsTarget.value === '') { 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.submitTarget.click() } 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() { try { return document.querySelector(`[data-selected-resources-name="${this.resourceName}"]`).dataset } catch (error) { return [] } } }
Version data entries
24 entries across 24 versions & 1 rubygems