Sha256: 8705bab05cf2b2b64eecf5507e444c4bd16db0ffa44a5726de2298ea30a1808f

Contents?: true

Size: 838 Bytes

Versions: 22

Compression:

Stored size: 838 Bytes

Contents

import Cookies from "js-cookie";
import {
  parseSearchParamValue,
  buildSearchParamValue,
} from "~/assets/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

22 entries across 22 versions & 1 rubygems

Version Path
lookbook-2.3.4 app/components/lookbook/display_options/field/component.js
lookbook-2.3.3 app/components/lookbook/display_options/field/component.js
lookbook-2.3.2 app/components/lookbook/display_options/field/component.js
lookbook-2.3.0 app/components/lookbook/display_options/field/component.js
lookbook-2.2.2 app/components/lookbook/display_options/field/component.js
lookbook-2.2.1 app/components/lookbook/display_options/field/component.js
lookbook-2.2.0 app/components/lookbook/display_options/field/component.js
lookbook-2.1.1 app/components/lookbook/display_options/field/component.js
lookbook-2.1.0 app/components/lookbook/display_options/field/component.js
lookbook-2.0.5 app/components/lookbook/display_options/field/component.js
lookbook-2.0.4 app/components/lookbook/display_options/field/component.js
lookbook-2.0.3 app/components/lookbook/display_options/field/component.js
lookbook-2.0.2 app/components/lookbook/display_options/field/component.js
lookbook-2.0.1 app/components/lookbook/display_options/field/component.js
lookbook-2.0.0 app/components/lookbook/display_options/field/component.js
lookbook-2.0.0.rc.3 app/components/lookbook/display_options/field/component.js
lookbook-2.0.0.rc.2 app/components/lookbook/display_options/field/component.js
lookbook-2.0.0.rc.1 app/components/lookbook/display_options/field/component.js
lookbook-2.0.0.beta.9 app/components/lookbook/display_options/field/component.js
lookbook-2.0.0.beta.8 app/components/lookbook/display_options/field/component.js