Sha256: 8c9fea0456436538258e8a7fb2a5701789f9f1b25bfe0e0e3beb38a17187bdff

Contents?: true

Size: 795 Bytes

Versions: 7

Compression:

Stored size: 795 Bytes

Contents

/**
 * Changes "Back to list" links to the one saved in sessionStorage API
 * To apply this to a link, at least one element must have the class "js-back-to-list".
 * For this to work it needs the filteredParams in SessionStorage, that is saved on FormFilterComponent.
 * @param {NodeList} links - Hyperlinks elements that point to the filters page that will use the fitererd params
 * @returns {void}
 */
export default function backToListLink(links) {

  if (!links) {
    return;
  }

  if (!window.sessionStorage) {
    return;
  }

  const filteredParams = JSON.parse(sessionStorage.getItem("filteredParams")) || {};
  links.forEach((link) => {
    const href = link.getAttribute("href");
    if (filteredParams[href]) {
      link.setAttribute("href", filteredParams[href]);
    }
  });

}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-core-0.28.4 app/packs/src/decidim/back_to_list.js
decidim-core-0.28.3 app/packs/src/decidim/back_to_list.js
decidim-core-0.28.2 app/packs/src/decidim/back_to_list.js
decidim-core-0.28.1 app/packs/src/decidim/back_to_list.js
decidim-core-0.28.0 app/packs/src/decidim/back_to_list.js
decidim-core-0.28.0.rc5 app/packs/src/decidim/back_to_list.js
decidim-core-0.28.0.rc4 app/packs/src/decidim/back_to_list.js