Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implement text column filter. Closes #758.

  • Loading branch information...
commit 144589515e1294430c571575e4f54485e1a7dee2 1 parent 3c276c3
@onyxfish onyxfish authored
View
1  CHANGELOG
@@ -1,6 +1,7 @@
1.0.0
-----
+* Implement "Text" column filter. (#758)
* Make modal dialogs focus first form field on open. (#674)
* Fix display of notifications in navbar. (#749)
* Datasets are no longer locked for editing during exports. (#659)
View
4 client/static/js/views/dataset_search.js
@@ -295,7 +295,9 @@ PANDA.views.DatasetSearch = Backbone.View.extend({
q += " AND ";
}
- if (v["operator"] == "is") {
+ if (v["operator"] == "is_like") {
+ q += c["indexed_name"] + ':(' + v["value"] + ')';
+ } else if (v["operator"] == "is") {
q += c["indexed_name"] + ':"' + v["value"] + '"';
} else if (v["operator"] == "is_greater") {
q += c["indexed_name"] + ":[" + v["value"] + " TO *]";
View
24 client/static/js/views/dataset_search_filters.js
@@ -1,5 +1,13 @@
PANDA.views.DatasetSearchFilters = Backbone.View.extend({
operations: {
+ "unicode": {
+ "is_like": {
+ "name": "is like",
+ "widget_template": "inline_widget_single_input",
+ "parser": "parse_inline_widget_single_input",
+ "validator": "validate_unicode"
+ }
+ },
"int": {
"is": {
"name": "is",
@@ -186,7 +194,7 @@ PANDA.views.DatasetSearchFilters = Backbone.View.extend({
/*
* Determine if a column is filterable.
*/
- return c["indexed"] && c["type"] && c["type"] != "unicode";
+ return c["indexed"] && c["type"];
},
column_has_query: function(c) {
@@ -242,7 +250,13 @@ PANDA.views.DatasetSearchFilters = Backbone.View.extend({
if (this.column_has_query(c)) {
return this.search.query[c["name"]];
} else {
- return { "operator": "is", "value": "", "range_value": "" };
+ var op = "is";
+
+ if (c["type"] == "unicode") {
+ op = "is_like";
+ }
+
+ return { "operator": op, "value": "", "range_value": "" };
}
},
@@ -380,6 +394,12 @@ PANDA.views.DatasetSearchFilters = Backbone.View.extend({
/* Value validators - prepare values from widgets for Solr query */
+ validate_unicode: function(c, values) {
+ if (!values["value"]) {
+ throw new Error("No value provided.");
+ }
+ },
+
is_int: function(v) {
return parseFloat(v) == parseInt(v) && !_.isNaN(v);
},
View
2  client/static/templates/dataset_view.jst
@@ -137,13 +137,13 @@
<td><input type="checkbox" name="typed-<%= i %>" <% if (c['indexed']) { %>checked="checked"<% } %>></td>
<td><select name="type-<%= i %>">
<option value=""<% if (c['type'] == null) { %>selected="selected"<% } %>>Pick a type...</option>
+ <option value="unicode"<% if (c['type'] == "unicode") { %>selected="selected"<% } %>>Text</option>
<option value="int"<% if (c['type'] == "int") { %>selected="selected"<% } %>>Whole Number</option>
<option value="float"<% if (c['type'] == "float") { %>selected="selected"<% } %>>Decimal Number</option>
<option value="date"<% if (c['type'] == "date") { %>selected="selected"<% } %>>Date</option>
<option value="time"<% if (c['type'] == "time") { %>selected="selected"<% } %>>Time</option>
<option value="datetime"<% if (c['type'] == "datetime") { %>selected="selected"<% } %>>Date and Time</option>
<option value="bool"<% if (c['type'] == "bool") { %>selected="selected"<% } %>>True or False</option>
- <!--<option value="unicode"<% if (c['type'] == "unicode") { %>selected="selected"<% } %>>Text</option>-->
</select></td>
</tr>
<% }); %>
View
2  setup_panda/data_schema.xml
@@ -53,7 +53,7 @@
<field name="last_modified" type="date" indexed="true" stored="false" required="false" />
<!-- Dynamic typed fields that correspond to Python types -->
- <dynamicField name="column_unicode_*" type="string" indexed="true" stored="false" />
+ <dynamicField name="column_unicode_*" type="text_general" indexed="true" stored="false" />
<dynamicField name="column_int_*" type="long" indexed="true" stored="false" />
<dynamicField name="column_bool_*" type="boolean" indexed="true" stored="false" />
<dynamicField name="column_float_*" type="float" indexed="true" stored="false" />
Please sign in to comment.
Something went wrong with that request. Please try again.