Commit 23475d19 authored by Rob Phillips's avatar Rob Phillips Committed by Rob Phillips
Browse files

Issue #3282453 by chucksimply, robphillips: Fix support for quote encapsulated values and matches.

parent d0925836
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -136,12 +136,13 @@
     */
    search(event) {
      this.value = event.detail.value;

      if (this.cache[event.detail.value]) {
        // Populate from static cache.
        this.populate([...this.cache[event.detail.value]], event.detail.value);
      } else {
        this.setState(true);
        fetch(`${this.url}?q=${encodeURIComponent(event.detail.value)}`, {
        fetch(`${this.url}?q="${encodeURIComponent(event.detail.value)}"`, {
          headers: { "Content-Type": "application/json; charset=utf-8" },
        })
          .then((response) => response.json())
@@ -176,12 +177,12 @@
      // Gather current selection IDs and labels.
      const ids = [];
      const labels = values.map((value) => {
        const matches = value.match(/\s\(\d+\)$/);
        const matches = value.match(/\s\(\d+\)"?$/);
        if (matches) {
          ids.push(matches[0].replace(/\D/g, "").trim());
        }
        return value
          .replace(/\s\(\d+\)$/, "")
          .replace(/\s\(\d+\)"?$/, "")
          .toLowerCase()
          .trim();
      });
@@ -190,11 +191,11 @@
      items = items.filter((item) => {
        labels.push(
          item.value
            .replace(/\s\(\d+\)$/, "")
            .replace(/\s\(\d+\)"?$/, "")
            .toLowerCase()
            .trim()
        );
        const matches = item.value.match(/\s\(\d+\)$/);
        const matches = item.value.match(/\s\(\d+\)"?$/);
        if (matches) {
          return ids.indexOf(matches[0].replace(/\W/g, "").trim()) === -1;
        }
+5 −5
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@
        this.populate([...this.cache[event.detail.value]], event.detail.value);
      } else {
        this.setState(true);
        fetch(`${this.url}?q=${encodeURIComponent(event.detail.value)}`, {
        fetch(`${this.url}?q="${encodeURIComponent(event.detail.value)}"`, {
          headers: {
            "Content-Type": "application/json; charset=utf-8"
          }
@@ -122,17 +122,17 @@

      const ids = [];
      const labels = values.map(value => {
        const matches = value.match(/\s\(\d+\)$/);
        const matches = value.match(/\s\(\d+\)"?$/);

        if (matches) {
          ids.push(matches[0].replace(/\D/g, "").trim());
        }

        return value.replace(/\s\(\d+\)$/, "").toLowerCase().trim();
        return value.replace(/\s\(\d+\)"?$/, "").toLowerCase().trim();
      });
      items = items.filter(item => {
        labels.push(item.value.replace(/\s\(\d+\)$/, "").toLowerCase().trim());
        const matches = item.value.match(/\s\(\d+\)$/);
        labels.push(item.value.replace(/\s\(\d+\)"?$/, "").toLowerCase().trim());
        const matches = item.value.match(/\s\(\d+\)"?$/);

        if (matches) {
          return ids.indexOf(matches[0].replace(/\W/g, "").trim()) === -1;