Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Stubbing out the use of labels for everything.

  • Loading branch information...
commit c5a87d42e4d2d86b60e76b64f43d13736792f017 1 parent 969fabf
Samuel Clay samuelclay authored
3  lib/js/utils/search_parser.js
View
@@ -40,11 +40,14 @@ VS.app.SearchParser = {
value = field;
query = VS.utils.inflector.trim(query.replace(value, ''));
}
+
+ var label = null; // You want the values from search_facet.js:autocompleteValues.
if (category && value) {
var searchFacet = new VS.model.SearchFacet({
category : category,
value : VS.utils.inflector.trim(value),
+ label : label,
app : instance
});
facets.push(searchFacet);
4 lib/js/views/search_box.js
View
@@ -95,10 +95,12 @@ VS.ui.SearchBox = Backbone.View.extend({
category = VS.utils.inflector.trim(category);
initialQuery = VS.utils.inflector.trim(initialQuery || '');
if (!category) return;
-
+ var label = "Yatta";
+
var model = new VS.model.SearchFacet({
category : category,
value : initialQuery || '',
+ label : label,
app : this.app
});
this.app.searchQuery.add(model, {at: position});
12 lib/js/views/search_facet.js
View
@@ -36,7 +36,7 @@ VS.ui.SearchFacet = Backbone.View.extend({
this.setMode('not', 'editing');
this.setMode('not', 'selected');
this.box = this.$('input');
- this.box.val(this.model.get('value'));
+ this.box.val(this.model.get('label'));
this.box.bind('blur', this.deferDisableEdit);
// Handle paste events with `propertychange`
this.box.bind('input propertychange', this.keydown);
@@ -74,7 +74,7 @@ VS.ui.SearchFacet = Backbone.View.extend({
select : _.bind(function(e, ui) {
e.preventDefault();
var originalValue = this.model.get('value');
- this.set(ui.item.value);
+ this.set(ui.item.value, ui.item.label);
if (originalValue != ui.item.value || this.box.val() != ui.item.value) {
this.search(e);
}
@@ -171,9 +171,9 @@ VS.ui.SearchFacet = Backbone.View.extend({
},
// Sets the facet's model's value.
- set : function(value) {
+ set : function(value, label) {
if (!value) return;
- this.model.set({'value': value});
+ this.model.set({'value': value, 'label': label});
},
// Before the searchBox performs a search, we need to close the
@@ -197,7 +197,7 @@ VS.ui.SearchFacet = Backbone.View.extend({
this.setMode('is', 'editing');
this.deselectFacet();
if (this.box.val() == '') {
- this.box.val(this.model.get('value'));
+ this.box.val(this.model.get('label'));
}
}
@@ -234,7 +234,7 @@ VS.ui.SearchFacet = Backbone.View.extend({
// the autocomplete menu.
disableEdit : function() {
var newFacetQuery = VS.utils.inflector.trim(this.box.val());
- if (newFacetQuery != this.model.get('value')) {
+ if (newFacetQuery != this.model.get('value') && newFacetQuery != this.model.get('label')) {
this.set(newFacetQuery);
}
this.flags.canClose = false;
Please sign in to comment.
Something went wrong with that request. Please try again.