Sha256: f44ff7897beffedad0ced2d0bc05ae8ca975a3f60bd0272ae475bb827cd0690e

Contents?: true

Size: 1.57 KB

Versions: 8

Compression:

Stored size: 1.57 KB

Contents

// = require ./budget_rule_toggler.component
// = require ./scope_picker_enabler.component

((exports) => {
  const { BudgetRuleTogglerComponent } = exports.DecidimAdmin;

  const budgetRuleToggler = new BudgetRuleTogglerComponent({
    ruleCheckboxes: $("input[id^='component_settings_vote_rule_']")
  });

  budgetRuleToggler.run();
})(window);

// Checks if the form contains fields with special CSS classes added in
// Decidim::Admin::SettingsHelper and acts accordingly.
$(() => {
  // Prevents readonly containers from being modified.
  const $readonlyContainer = $(".readonly_container input");

  $readonlyContainer.click((event) => {
    event.preventDefault();
    return false;
  });

  // Target fields:
  // - amendments_wizard_help_text
  // - amendments_visibility
  // - amendment_creation_enabled
  // - amendment_reaction_enabled
  // - amendment_promotion_enabled

  // (1) Hides target fields if amendments_enabled component setting is NOT checked.
  // (2) Toggles visibilty of target fields when amendments_enabled component setting is clicked.
  const $amendmentsEnabled = $("input#component_settings_amendments_enabled");

  if ($amendmentsEnabled.length > 0) {
    const $amendmentStepSettings = $(".amendments_wizard_help_text_container, .amendments_visibility_container, .amendment_creation_enabled_container, .amendment_reaction_enabled_container, .amendment_promotion_enabled_container");

    if ($amendmentsEnabled.is(":not(:checked)")) {
      $amendmentStepSettings.hide();
    }

    $amendmentsEnabled.click(() => {
      $amendmentStepSettings.toggle();
    });
  }
});

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
decidim-admin-0.23.6 app/assets/javascripts/decidim/admin/form.js.es6
decidim-admin-0.23.5 app/assets/javascripts/decidim/admin/form.js.es6
decidim-admin-0.23.4 app/assets/javascripts/decidim/admin/form.js.es6
decidim-admin-0.23.3 app/assets/javascripts/decidim/admin/form.js.es6
decidim-admin-0.23.2 app/assets/javascripts/decidim/admin/form.js.es6
decidim-admin-0.23.1 app/assets/javascripts/decidim/admin/form.js.es6
decidim-admin-0.23.1.rc1 app/assets/javascripts/decidim/admin/form.js.es6
decidim-admin-0.23.0 app/assets/javascripts/decidim/admin/form.js.es6