Sha256: e6c14d8c48af6b412a1a40eb8e8ada827320e163e0039d6e64bbd1109885d2dd

Contents?: true

Size: 851 Bytes

Versions: 24

Compression:

Stored size: 851 Bytes

Contents

import Cookies from "js-cookie";
import {
  parseSearchParamValue,
  buildSearchParamValue,
} from "~/app/assets/lookbook/js/helpers/string";

export default function displayOptionsFieldComponent({ name, value }) {
  return {
    name,
    value,

    init() {
      this.$watch("value", () => this.update());
    },

    update() {
      Cookies.set(`lookbook-display-${name}`, this.value);

      const searchParams = new URLSearchParams(window.location.search);
      const display = searchParams.get("_display");

      const displayParams = display ? parseSearchParamValue(display) : {};
      displayParams[this.name] = this.value;
      searchParams.set("_display", buildSearchParamValue(displayParams));

      const path = location.href.replace(location.search, "");
      this.navigateTo(`${path}?${searchParams.toString()}`);
    },
  };
}

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
lookbook-1.5.5 app/components/lookbook/display_options/field/component.js
lookbook-1.5.4 app/components/lookbook/display_options/field/component.js
lookbook-2.0.0.beta.5 app/components/lookbook/display_options/field/component.js
lookbook-2.0.0.beta.4 app/components/lookbook/display_options/field/component.js
lookbook-2.0.0.beta.3 app/components/lookbook/display_options/field/component.js
lookbook-2.0.0.beta.2 app/components/lookbook/display_options/field/component.js
lookbook-1.5.3 app/components/lookbook/display_options/field/component.js
lookbook-2.0.0.beta.1 app/components/lookbook/display_options/field/component.js
lookbook-1.5.2 app/components/lookbook/display_options/field/component.js
lookbook-2.0.0.beta.0 app/components/lookbook/display_options/field/component.js
lookbook-1.5.1 app/components/lookbook/display_options/field/component.js
lookbook-1.5.0 app/components/lookbook/display_options/field/component.js
lookbook-1.4.5 app/components/lookbook/display_options/field/component.js
lookbook-1.4.4 app/components/lookbook/display_options/field/component.js
lookbook-1.4.3 app/components/lookbook/display_options/field/component.js
lookbook-1.4.2 app/components/lookbook/display_options/field/component.js
lookbook-1.4.1 app/components/lookbook/display_options/field/component.js
lookbook-1.4.0 app/components/lookbook/display_options/field/component.js
lookbook-1.3.4 app/components/lookbook/display_options/field/component.js
lookbook-1.3.3 app/components/lookbook/display_options/field/component.js