Bugfix: Now correctly joining several words before querying the backend. It will only query the backend if its either one or two words.

This commit is contained in:
Nils Norman Haukås 2016-01-20 22:36:33 +01:00
parent d26a1572a6
commit 58a5ed2b45
2 changed files with 24 additions and 7 deletions

View file

@ -58,12 +58,29 @@ module tagIt {
}
onWordSelected = (newWord: string) => {
this.selectedWord = newWord;
this.backendService.callServer(newWord)
.then((synsets: Object) => {
this.$log.debug(synsets);
this.senses = this.backendService.processSynsets(<ISynset>synsets);
});
function countWords(wordWithUnderscores: string) {
return wordWithUnderscores.split("_").length;
}
if (countWords(newWord) > 2) {
this.selectedWord = "Wops! Plugin can't handle more than two words.";
this.senses = [];
}
else if (newWord.length === 0) {
this.clearMenuVariables();
}
else {
this.selectedWord = newWord;
this.backendService.callServer(newWord)
.then((synsets: Object) => {
this.$log.debug(synsets);
this.senses = this.backendService.processSynsets(<ISynset>synsets);
});
}
//call for a digest because clicklistener that triggers this
//function is unknown to Angular.
this.$scope.$apply();
}
onWordDeSelected = () => {

View file

@ -51,7 +51,7 @@ module tagIt {
}
}, false);
function joinLongWords(possiblyLongWord: string) {
return possiblyLongWord.replace(" ", "_");
return possiblyLongWord.trim().split(" ").join("_");
}
function wasRemoveTagButtonClicked(evt: any) {
return evt.target.className === 'js-tagit-remove-tag';