Sha256: 7d8146e74e65e48ebbbb57eef17adb755e9c26b16de7e31dabe5b2b63c10cb18

Contents?: true

Size: 586 Bytes

Versions: 47

Compression:

Stored size: 586 Bytes

Contents

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

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

    update() {
      if (this.validate()) {
        const searchParams = new URLSearchParams(window.location.search);
        searchParams.set(this.name, this.value);
        const path = location.href.replace(location.search, "");
        this.navigateTo(`${path}?${searchParams.toString()}`);
      }
    },

    validate() {
      return this.$root.reportValidity ? this.$root.reportValidity() : true;
    },
  };
}

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
lookbook-1.3.3 app/assets/lookbook/js/components/params_input.js
lookbook-1.3.1 app/assets/lookbook/js/components/params_input.js
lookbook-1.3.0 app/assets/lookbook/js/components/params_input.js
lookbook-1.2.1 app/assets/lookbook/js/components/params_input.js
lookbook-1.2.0 app/assets/lookbook/js/components/params_input.js
lookbook-1.1.1 app/assets/lookbook/js/components/params_input.js
lookbook-1.1.0 app/assets/lookbook/js/components/params_input.js