From a1fe0f2d8cbba3f9be34d6f0aedb1c73b826eb7d Mon Sep 17 00:00:00 2001 From: Giulio Cesare Solaroli Date: Wed, 22 Jul 2015 08:42:38 +0200 Subject: [PATCH] Improved tag handling --- frontend/delta/js/Clipperz/PM/DataModel/Record.js | 4 ++-- .../tests/tests/Clipperz/PM/DataModel/Record.test.js | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/delta/js/Clipperz/PM/DataModel/Record.js b/frontend/delta/js/Clipperz/PM/DataModel/Record.js index ea81b6f..f3bd761 100644 --- a/frontend/delta/js/Clipperz/PM/DataModel/Record.js +++ b/frontend/delta/js/Clipperz/PM/DataModel/Record.js @@ -1257,8 +1257,8 @@ Clipperz.PM.DataModel.Record.regExpForSearch = function (aSearch) { }; - -Clipperz.PM.DataModel.Record.tagRegExp = new RegExp('\\' + Clipperz.PM.DataModel.Record.tagChar + '(' + Clipperz.PM.DataModel.Record.specialTagChar + '?\\w+)', 'g'); +// Slightly more readable: http://rubular.com/r/4O8xGEsLgw +Clipperz.PM.DataModel.Record.tagRegExp = new RegExp('\\' + Clipperz.PM.DataModel.Record.tagChar + '(' + Clipperz.PM.DataModel.Record.specialTagChar + '?[^'+Clipperz.PM.DataModel.Record.tagChar+']+?)\\s*(?='+Clipperz.PM.DataModel.Record.tagChar+'|$)', 'g'); Clipperz.PM.DataModel.Record.trimSpacesRegExp = new RegExp('^\\s+|\\s+$', 'g'); Clipperz.PM.DataModel.Record.extractLabelFromFullLabel = function (aValue) { diff --git a/frontend/delta/tests/tests/Clipperz/PM/DataModel/Record.test.js b/frontend/delta/tests/tests/Clipperz/PM/DataModel/Record.test.js index a9e0f54..18f03de 100644 --- a/frontend/delta/tests/tests/Clipperz/PM/DataModel/Record.test.js +++ b/frontend/delta/tests/tests/Clipperz/PM/DataModel/Record.test.js @@ -1550,10 +1550,14 @@ deferredResult.addCallback(function (aValue) { console.log("FIELDS", aValue); re deferredResult.addMethod(user, 'getRecord', recordID); //deferredResult.addCallback(function (aValue) { console.log("VALUE", aValue); return aValue; }); deferredResult.addMethodcaller('addTag', "TagX"); + deferredResult.addMethod(user, 'getRecord', recordID); + deferredResult.addMethodcaller('addTag', "A tag with spaces"); + deferredResult.addMethod(user, 'getRecord', recordID); + deferredResult.addMethodcaller('addTag', "ετικέτα"); deferredResult.addMethod(user, 'getRecord', recordID); deferredResult.addMethodcaller('tags'); - deferredResult.addCallback(SimpleTest.eq, ['Tag1', 'Tag2', 'TagX']); + deferredResult.addCallback(SimpleTest.eq, ['Tag1', 'Tag2', 'TagX', 'A tag with spaces', 'ετικέτα']); deferredResult.addMethod(user, 'getRecord', recordID); deferredResult.addMethodcaller('setLabel', "Card 1 - edited"); @@ -1565,7 +1569,7 @@ deferredResult.addCallback(function (aValue) { console.log("FIELDS", aValue); re deferredResult.addMethod(user_2, 'login'); deferredResult.addMethod(user_2, 'getRecord', recordID); deferredResult.addMethodcaller('tags'); - deferredResult.addCallback(SimpleTest.eq, ['Tag1', 'Tag2', 'TagX']); + deferredResult.addCallback(SimpleTest.eq, ['Tag1', 'Tag2', 'TagX', 'A tag with spaces', 'ετικέτα']); deferredResult.callback();