Browse Source

fixes #179: ability to search for a given field with key:value syntax

Davide Alberani 7 years ago
parent
commit
a6d60a0e10
2 changed files with 9 additions and 2 deletions
  1. 7 1
      angular_app/js/filters.js
  2. 2 1
      tools/qrcode_reader.py

+ 7 - 1
angular_app/js/filters.js

@@ -39,7 +39,13 @@ eventManApp.filter('splittedFilter', ['$filter',
         return function(inputArray, searchText) {
             var wordArray = searchText ? searchText.toLowerCase().split(/\s+/) : [];
             for (var x=0; x < wordArray.length; x++) {
-                inputArray = $filter('filter')(inputArray, wordArray[x]);
+                var filter_item = wordArray[x];
+                if (filter_item.indexOf(':') != -1) {
+                    var filter_item_split = filter_item.split(':', 2);
+                    filter_item = {};
+                    filter_item[filter_item_split[0]] = filter_item_split[1];
+                }
+                inputArray = $filter('filter')(inputArray, filter_item);
             }
             return inputArray;
         };

+ 2 - 1
tools/qrcode_reader.py

@@ -123,7 +123,8 @@ class Connector():
             pass
         if limit_field:
             code = code[:limit_field]
-        params = {cfg['event']['field']: code, '_errorMessage': 'code: %s' % code, '_searchFor': code}
+        _searchFor = '%s:%s' % (cfg['event']['field'], code)
+        params = {cfg['event']['field']: code, '_errorMessage': 'code: %s' % code, '_searchFor': _searchFor}
         checkin_url = self.checkin_url + '?' + urllib.parse.urlencode(params)
         json = convert(dict(self.cfg['actions']))
         req = self.session.put(checkin_url, json=json, timeout=TIMEOUT)