Fixed issue 18283: Accents are now ignored in 'Quick launch' and in 'Create New' suggestion combobox
authorDavid Baz Fayos <david.baz@openbravo.com>
Tue, 16 Aug 2011 13:26:06 +0200
changeset 13528 eb7bc1a49352
parent 13527 b8c828c166bc
child 13529 72043a243438
Fixed issue 18283: Accents are now ignored in 'Quick launch' and in 'Create New' suggestion combobox
modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
--- a/modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js	Tue Aug 16 13:20:46 2011 +0200
+++ b/modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js	Tue Aug 16 13:26:06 2011 +0200
@@ -340,4 +340,32 @@
 //isc.Class._fireOnPause = isc.Class.fireOnPause;
 //isc.Class.fireOnPause = function(id, callback, delay, target, instanceID) {
 //  isc.Class._fireOnPause(id, callback, delay, target, instanceID);
-//};
\ No newline at end of file
+//};
+
+
+// Allow searchs (with full dataset in memory/the datasource) not distinguish
+// between accent or non-accent words
+isc.DataSource.addProperties({
+  _fieldMatchesFilter: isc.DataSource.getPrototype().fieldMatchesFilter,
+  fieldMatchesFilter: function(fieldValue, filterValue, requestProperties) {
+    if (fieldValue && typeof fieldValue === "string") {
+      fieldValue = fieldValue.replace(/á|à|ä|â/g, 'a').replace(/Á|À|Ä|Â/g, 'A');
+      fieldValue = fieldValue.replace(/é|è|ë|ê/g, 'e').replace(/É|È|Ë|Ê/g, 'E');
+      fieldValue = fieldValue.replace(/í|ì|ï|î/g, 'i').replace(/Í|Ì|Ï|Î/g, 'I');
+      fieldValue = fieldValue.replace(/ó|ò|ö|ô/g, 'o').replace(/Ó|Ò|Ö|Ô/g, 'O');
+      fieldValue = fieldValue.replace(/ú|ù|ü|û/g, 'u').replace(/Ú|Ù|Ü|Û/g, 'U');
+      fieldValue = fieldValue.replace(/ç/g, 'c').replace(/Ç/g, 'C');
+      fieldValue = fieldValue.replace(/ñ/g, 'n').replace(/Ñ/g, 'N');
+    }
+    if (filterValue && typeof filterValue === "string") {
+      filterValue = filterValue.replace(/á|à|ä|â/g, 'a').replace(/Á|À|Ä|Â/g, 'A');
+      filterValue = filterValue.replace(/é|è|ë|ê/g, 'e').replace(/É|È|Ë|Ê/g, 'E');
+      filterValue = filterValue.replace(/í|ì|ï|î/g, 'i').replace(/Í|Ì|Ï|Î/g, 'I');
+      filterValue = filterValue.replace(/ó|ò|ö|ô/g, 'o').replace(/Ó|Ò|Ö|Ô/g, 'O');
+      filterValue = filterValue.replace(/ú|ù|ü|û/g, 'u').replace(/Ú|Ù|Ü|Û/g, 'U');
+      filterValue = filterValue.replace(/ç/g, 'c').replace(/Ç/g, 'C');
+      filterValue = filterValue.replace(/ñ/g, 'n').replace(/Ñ/g, 'N');
+    }
+    return this._fieldMatchesFilter(fieldValue, filterValue, requestProperties);
+  }
+});
\ No newline at end of file