From 350657be9db0b51c06ccba2dd3e3a4b1702bcfb1 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 29 Mar 2021 15:22:56 +0300 Subject: Fixed loading of avaiable languages and technologies in profile settings page --- .../profile-settings/profile-settings.component.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/app/components/profile-settings/profile-settings.component.ts b/src/app/components/profile-settings/profile-settings.component.ts index 007ce28..4bee52e 100644 --- a/src/app/components/profile-settings/profile-settings.component.ts +++ b/src/app/components/profile-settings/profile-settings.component.ts @@ -108,24 +108,34 @@ export class ProfileSettingsComponent implements OnInit { this._languageService.getFullLanguagesFromIncomplete(this.user.languages).then( (result) => { this.chosenLanguages = result as Language[]; + this.loadAvailableLanguages(); } ); this._technologyService.getFullTechnologiesFromIncomplete(this.user.technologies).then( (result) => { this.chosenTechnologies = result as Technology[]; + this.loadAvailableTechnologies(); } ); + } - // Load avaiable languages and technologies + private loadAvailableLanguages(): void { this._languageService.getAllLanguagesWithSessionStorageRequest().subscribe({ next: (result: object) => { - this.availableLanguages = result as Language[]; + const allAvailable = result as Language[]; + // Remove the chosen languages from all of the avaiable ones + this.availableLanguages = allAvailable.filter(a => !this.user.languages.some(l => l.name === a.name)); } }); + } + + private loadAvailableTechnologies(): void { this._technologyService.getAllTechnologiesWithSessionStorageRequest().subscribe({ next: (result: object) => { - this.availableTechnologies = result as Technology[]; + const allAvailable = result as Technology[]; + // Remove the chosen technologies from all of the avaiable ones + this.availableTechnologies = allAvailable.filter(a => !this.user.technologies.some(t => t.name === a.name)); } }); } -- cgit v1.2.3