Sha256: 68e052ba4cc0c291fe105805ec1204546736d84c2e31b9d8f4d9d00a63a4d988

Contents?: true

Size: 1.26 KB

Versions: 5

Compression:

Stored size: 1.26 KB

Contents

// Checks if the form contains fields with special CSS classes added in
// Decidim::Admin::SettingsHelper and acts accordingly.
$(() => {
  // Prevents checkbox with ".participatory_texts_disabled" class from being clicked.
  const $participatoryTexts = $(".participatory_texts_disabled");

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

  // Target fields:
  // - amendments_wizard_help_text
  // - all fields with ".amendments_step_settings" class
  // (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 $amendmentWizardHelpText = $("[id*='amendments_wizard_help_text']").parent();
    const $amendmentStepSettings = $(".amendments_step_settings").parent();

    if ($amendmentsEnabled.is(":not(:checked)")) {
      $amendmentWizardHelpText.hide();
      $amendmentStepSettings.hide().siblings(".help-text").hide();
    }

    $amendmentsEnabled.click(() => {
      $amendmentWizardHelpText.toggle();
      $amendmentStepSettings.toggle().siblings(".help-text").toggle();
    });
  }
});

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-admin-0.21.0 app/assets/javascripts/decidim/admin/form.js.es6
decidim-admin-0.20.1 app/assets/javascripts/decidim/admin/form.js.es6
decidim-admin-0.20.0 app/assets/javascripts/decidim/admin/form.js.es6
decidim-admin-0.19.1 app/assets/javascripts/decidim/admin/form.js.es6
decidim-admin-0.19.0 app/assets/javascripts/decidim/admin/form.js.es6