Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
feat(search): can search with prefix wildcard
Browse files Browse the repository at this point in the history
 - adds prefix + wildcard option in facet-free-search

Closes #631
  • Loading branch information
alex-wilmer committed Mar 16, 2016
1 parent 0ddcae4 commit 350fcce
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
17 changes: 11 additions & 6 deletions app/scripts/components/facets/facets.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ module ngApp.components.facets.services {
}

return this.Restangular.all(entity + "/ids").get("", options).then((data) => {
return data.data.hits.length ? data.data.hits : [{'warning': 'No Results Found'}];
var model = {};
model[field.split(".").pop()] = query + "*";
return [model].concat(data.data.hits);
});
}

Expand Down Expand Up @@ -144,19 +146,21 @@ module ngApp.components.facets.services {

// TODO - not like this
var found = false;
var cs = filters["content"];
var cs = filters.content;

for (var i = 0; i < cs.length; i++) {
var c = cs[i]["content"];
if (c["field"] === facet && cs[i]["op"] === op) {
var c = cs[i].content;
if (c.field === facet && cs[i].op === op) {
found = true;
if (c["value"].indexOf(term) === -1) {
c["value"].push(term);
if (c.value.indexOf(term) === -1) {
c.value.push(term);
} else {
return;
}
break;
}
}

if (!found) {
cs.push({
op: op,
Expand All @@ -166,6 +170,7 @@ module ngApp.components.facets.services {
}
});
}

this.LocationService.setFilters(filters);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<span class="uuid">{{ match.model.case_id }}</span>
</div>
<div class="data-row sub-item">
{{ match.model.submitter_id }}
{{ match.model.submitter_id || 'Prefix search' }}
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<span class="uuid">{{ match.model.file_id }}</span>
</div>
<div class="data-row sub-item">
{{ match.model.file_name }}
{{ match.model.file_name || 'Prefix search' }}
</div>
</div>
</div>
Expand Down

0 comments on commit 350fcce

Please sign in to comment.