found and squashed angular invocation bug.

This commit is contained in:
Nils Norman Haukås 2017-04-15 20:38:15 +02:00
parent 75a32605a7
commit 6ed5a84934
3 changed files with 20 additions and 17 deletions

View file

@ -16,14 +16,14 @@ export class MenuCtrl {
senses: Object[];
constructor(
private $scope: IVMScope,
private $scope: IVMScope,
private $log: angular.ILogService,
private BackendService: BackendService,
private WebPageService: WebPageService,
private TagStorageService: TagStorageService,
private SettingsService: SettingsService,
private FileService: FileService) {
$scope.vm = this;
this.$scope.$on('wordWasSelected', (event, selectedWord) => {
@ -93,6 +93,7 @@ export class MenuCtrl {
}
onWordSelectedEvent = (newWord: string) => {
this.$log.debug('On word selected event()')
if (countWords(newWord) > 2) {
this.selectedWord = "Wops! Plugin can't handle more than two words."
this.senses = []
@ -100,7 +101,7 @@ export class MenuCtrl {
else if (newWord.length === 0) {
this.clearMenuVariables();
}
else {
else if (this.selectedWord != newWord) {
this.selectedWord = newWord;
this.senses = []
this.BackendService.callServer(newWord)
@ -126,21 +127,21 @@ export class MenuCtrl {
}
isLoadingSenses() {
// if senses var has initialized, we check length to see if they've been loaded.
// if senses var has initialized, we check length to see if they've been loaded.
return this.senses && this.senses.length == 0 && this.selectedWord
}
/**
* In order to hide the menu before angular has loaded I
* explicitly set display: none; on the div.
*
* Thus to override that after user has logged in
* we use the ng-style attribute in combination with
* In order to hide the menu before angular has loaded I
* explicitly set display: none; on the div.
*
* Thus to override that after user has logged in
* we use the ng-style attribute in combination with
* this function below.
*/
isUserLoggedIn() {
if (!this.SettingsService.isUserLoggedIn()) return null;
else return {display: 'block'};
else return {display: 'block'};
}
doLogin() {

View file

@ -4,7 +4,7 @@ import {SettingsService} from '../services/index';
import {ISenseTag} from '../index.interfaces';
/**
* Service that is responsible for talking to the
* Service that is responsible for talking to the
* backend server.
*/
export class BackendService {
@ -30,7 +30,9 @@ export class BackendService {
//alright let's make this query!
this.previousCall = word;
return this.SettingsService.loadSettings()
.then(loadedSettings => this.$http.get(`${loadedSettings.tagitSenseQueryUrl}/${word}`))
.then(loadedSettings => {
return this.$http.get(`${loadedSettings.tagitSenseQueryUrl}/${word}`)
})
}
sendTaggedDataToServer(senseTag: ISenseTag) {
@ -38,9 +40,9 @@ export class BackendService {
return this.SettingsService.loadSettings()
.then(loadedSettings => {
//let's add in the user's email to the tag.
senseTag.userEmail = loadedSettings.emailToTagWith
senseTag.userEmail = loadedSettings.emailToTagWith
this.$http.post(loadedSettings.tagitSenseDestinationUrl, senseTag)
})
}
}
}

View file

@ -9,7 +9,7 @@ export class TagStorageService {
$localStorage: { tagStorage: ISenseTag[] };
constructor(
private $http: ng.IHttpService,
private $http: ng.IHttpService,
private $log: ng.ILogService,
$localStorage: any) {
this.$localStorage = $localStorage;
@ -52,7 +52,7 @@ export class TagStorageService {
loadTagsForCurrentPage(): ISenseTag[] {
this.$log.debug('loadTagsForCurrentPage');
return this.$localStorage.tagStorage
return angular.copy(this.$localStorage.tagStorage)
.filter((tag: ISenseTag) =>
tag.urlOfPageThatWasTagged === window.location.href
);
@ -66,4 +66,4 @@ export class TagStorageService {
return this.$localStorage.tagStorage
}
}
}