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:
parent
d26a1572a6
commit
58a5ed2b45
2 changed files with 24 additions and 7 deletions
|
@ -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 = () => {
|
||||
|
|
|
@ -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';
|
||||
|
|
Loading…
Reference in a new issue