Sha256: 31c4082cc9df68a97de862893177b5464e8fc9b1d4cd46fe127b13d2246ad8ef

Contents?: true

Size: 824 Bytes

Versions: 13

Compression:

Stored size: 824 Bytes

Contents

// Choose a Block User Message template, get it by AJAX and add the Template in the justification textarea
document.addEventListener("DOMContentLoaded", () => {
  const blockTemplateChooser = document.getElementById("block_template_chooser");
  if (blockTemplateChooser) {
    blockTemplateChooser.addEventListener("change", () => {
      const dropdown =  document.getElementById("block_template_chooser");
      const url = dropdown.getAttribute("data-url");
      const templateId = dropdown.value;

      if (templateId === "") {
        return;
      }
      fetch(`${new URL(url).pathname}?${new URLSearchParams({ id: templateId })}`).
        then((response) => response.json()).
        then((data) => {
          document.getElementById("block_user_justification").value = data.template;
        })
    });
  }
});

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-templates-0.29.1 app/packs/src/decidim/templates/admin/block_user_template_chooser.js
decidim-templates-0.28.4 app/packs/src/decidim/templates/admin/block_user_template_chooser.js
decidim-templates-0.29.0 app/packs/src/decidim/templates/admin/block_user_template_chooser.js
decidim-templates-0.28.3 app/packs/src/decidim/templates/admin/block_user_template_chooser.js
decidim-templates-0.29.0.rc4 app/packs/src/decidim/templates/admin/block_user_template_chooser.js
decidim-templates-0.29.0.rc3 app/packs/src/decidim/templates/admin/block_user_template_chooser.js
decidim-templates-0.29.0.rc2 app/packs/src/decidim/templates/admin/block_user_template_chooser.js
decidim-templates-0.29.0.rc1 app/packs/src/decidim/templates/admin/block_user_template_chooser.js
decidim-templates-0.28.2 app/packs/src/decidim/templates/admin/block_user_template_chooser.js
decidim-templates-0.28.1 app/packs/src/decidim/templates/admin/block_user_template_chooser.js
decidim-templates-0.28.0 app/packs/src/decidim/templates/admin/block_user_template_chooser.js
decidim-templates-0.28.0.rc5 app/packs/src/decidim/templates/admin/block_user_template_chooser.js
decidim-templates-0.28.0.rc4 app/packs/src/decidim/templates/admin/block_user_template_chooser.js