[FIX] prevent crash when searching strings (addon web)

with the switch to moment.js, the way dates are parsed has changed,
and the autocompletion should be adapted to ignore invalid dates.
This commit is contained in:
Géry Debongnie
2014-11-12 15:17:20 +01:00
parent 6baca1b494
commit 3b700779bc
+3 -2
View File
@@ -1272,8 +1272,9 @@ instance.web.search.DateField = instance.web.search.Field.extend(/** @lends inst
return instance.web.date_to_str(facetValue.get('value'));
},
complete: function (needle) {
var d = moment(needle).toDate();
if (!d) { return $.when(null); }
var m = moment(needle);
if (!m.isValid()) { return $.when(null); }
var d = m.toDate();
var date_string = instance.web.format_value(d, this.attrs);
var label = _.str.sprintf(_.str.escapeHTML(
_t("Search %(field)s at: %(value)s")), {