From bcba82bbbcc55a511de1e126e0741ea6cf9fb505 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 29 Mar 2021 15:40:26 +0300 Subject: Added logic for transferring languages and technologies from available to chosen and back in profile settings --- .../profile-settings/profile-settings.component.ts | 27 +++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'src/app/components/profile-settings/profile-settings.component.ts') diff --git a/src/app/components/profile-settings/profile-settings.component.ts b/src/app/components/profile-settings/profile-settings.component.ts index 4bee52e..4724f02 100644 --- a/src/app/components/profile-settings/profile-settings.component.ts +++ b/src/app/components/profile-settings/profile-settings.component.ts @@ -274,13 +274,34 @@ export class ProfileSettingsComponent implements OnInit { } langClick(name: string): void { - console.log('Language: ' + name); + if (this.chosenLanguages.some(c => c.name === name)) { + const index = this.chosenLanguages.findIndex(t => t.name === name); + + this.availableLanguages.push(this.chosenLanguages[index]); + this.chosenLanguages.splice(index, 1); + } + else { + const index = this.availableLanguages.findIndex(t => t.name === name); + + this.chosenLanguages.push(this.availableLanguages[index]); + this.availableLanguages.splice(index, 1); + } } techClick(name: string): void { - console.log('Technology: ' + name); - } + if (this.chosenTechnologies.some(c => c.name === name)) { + const index = this.chosenTechnologies.findIndex(t => t.name === name); + this.availableTechnologies.push(this.chosenTechnologies[index]); + this.chosenTechnologies.splice(index, 1); + } + else { + const index = this.availableTechnologies.findIndex(t => t.name === name); + + this.chosenTechnologies.push(this.availableTechnologies[index]); + this.availableTechnologies.splice(index, 1); + } + } goToProfile(): void { this._router.navigate([this._router.url.substring(0, this._router.url.length - 9)]); -- cgit v1.2.3