Sha256: 4df7f955629c1ab3fbdc86b6da1457b81c27ad1966a651b64a25442f162bf68c

Contents?: true

Size: 886 Bytes

Versions: 13

Compression:

Stored size: 886 Bytes

Contents

/* eslint-disable require-jsdoc */

class OptionAttachedInputsComponent {
  constructor(options = {}) {
    this.wrapperField = options.wrapperField;
    this.controllerFieldSelector = options.controllerFieldSelector;
    this.dependentInputSelector = options.dependentInputSelector;
    this.controllerSelector = this.wrapperField.find(this.controllerFieldSelector);
    this._bindEvent();
    this._run();
  }

  _run() {
    this.controllerSelector.each((idx, el) => {
      const $field = $(el);
      const enabled = $field.is(":checked");

      $field.parents("div.js-collection-input").find(this.dependentInputSelector).prop("disabled", !enabled);
    });
  }

  _bindEvent() {
    this.controllerSelector.on("change", () => {
      this._run();
    });
  }
}

export default function createOptionAttachedInputs(options) {
  return new OptionAttachedInputsComponent(options);
}

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-forms-0.29.1 app/packs/src/decidim/forms/option_attached_inputs.component.js
decidim-forms-0.28.4 app/packs/src/decidim/forms/option_attached_inputs.component.js
decidim-forms-0.29.0 app/packs/src/decidim/forms/option_attached_inputs.component.js
decidim-forms-0.28.3 app/packs/src/decidim/forms/option_attached_inputs.component.js
decidim-forms-0.29.0.rc4 app/packs/src/decidim/forms/option_attached_inputs.component.js
decidim-forms-0.29.0.rc3 app/packs/src/decidim/forms/option_attached_inputs.component.js
decidim-forms-0.29.0.rc2 app/packs/src/decidim/forms/option_attached_inputs.component.js
decidim-forms-0.29.0.rc1 app/packs/src/decidim/forms/option_attached_inputs.component.js
decidim-forms-0.28.2 app/packs/src/decidim/forms/option_attached_inputs.component.js
decidim-forms-0.28.1 app/packs/src/decidim/forms/option_attached_inputs.component.js
decidim-forms-0.28.0 app/packs/src/decidim/forms/option_attached_inputs.component.js
decidim-forms-0.28.0.rc5 app/packs/src/decidim/forms/option_attached_inputs.component.js
decidim-forms-0.28.0.rc4 app/packs/src/decidim/forms/option_attached_inputs.component.js