Skip to content

Commit

Permalink
fix: remove preferred language management in user profile (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
suschneider authored and Carola Bratsch committed Mar 9, 2020
1 parent 878c054 commit 12d3e03
Show file tree
Hide file tree
Showing 19 changed files with 5 additions and 326 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { fillFormField } from '../../framework';

import { Registration } from './registration.page';

export type ProfileEditDetailsTypes = Partial<
Pick<Registration, 'title' | 'firstName' | 'lastName' | 'phoneHome' | 'preferredLanguage'>
>;
export type ProfileEditDetailsTypes = Partial<Pick<Registration, 'title' | 'firstName' | 'lastName' | 'phoneHome'>>;

export class ProfileEditDetailsPage {
readonly tag = 'ish-account-profile-user';
Expand Down
4 changes: 0 additions & 4 deletions e2e/cypress/integration/pages/account/profile.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ export class ProfilePage {
return cy.get(this.tag).find('[data-testing-id="phone-field"]');
}

get preferredLanguage() {
return cy.get(this.tag).find('[data-testing-id="preferred-language-field"]');
}

get companyName() {
return cy.get(this.tag).find('[data-testing-id="company-field"]');
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ <h1>{{ 'account.update_profile.heading' | translate }}</h1>

<ish-input [form]="form" controlName="phoneHome" label="account.update_profile.phone.label"></ish-input>

<ish-select-language
[form]="form"
controlName="preferredLanguage"
[languages]="languages"
></ish-select-language>

<div class="row">
<div class="offset-md-4 col-md-8">
<button type="submit" class="btn btn-primary" [disabled]="buttonDisabled">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { anything, spy, verify } from 'ts-mockito';
import { User } from 'ish-core/models/user/user.model';
import { ErrorMessageComponent } from 'ish-shared/components/common/error-message/error-message.component';
import { InputComponent } from 'ish-shared/forms/components/input/input.component';
import { SelectLanguageComponent } from 'ish-shared/forms/components/select-language/select-language.component';
import { SelectTitleComponent } from 'ish-shared/forms/components/select-title/select-title.component';

import { AccountProfileUserComponent } from './account-profile-user.component';
Expand All @@ -24,7 +23,6 @@ describe('Account Profile User Component', () => {
AccountProfileUserComponent,
MockComponent(ErrorMessageComponent),
MockComponent(InputComponent),
MockComponent(SelectLanguageComponent),
MockComponent(SelectTitleComponent),
],
}).compileComponents();
Expand Down Expand Up @@ -52,11 +50,6 @@ describe('Account Profile User Component', () => {
expect(element.querySelectorAll('ish-select-title')).toHaveLength(1);
});

it('should display select box for language', () => {
fixture.detectChanges();
expect(element.querySelectorAll('ish-select-language')).toHaveLength(1);
});

it('should emit updateUserProfile event if form is valid', () => {
const eventEmitter$ = spy(component.updateUserProfile);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export class AccountProfileUserComponent implements OnInit, OnChanges {
firstName: new FormControl('', [Validators.required, SpecialValidators.noSpecialChars]),
lastName: new FormControl('', [Validators.required, SpecialValidators.noSpecialChars]),
phoneHome: new FormControl(''),
preferredLanguage: new FormControl(this.countryCode, Validators.required),
});

// initialize form values in case currentUser is available
Expand All @@ -69,11 +68,6 @@ export class AccountProfileUserComponent implements OnInit, OnChanges {
this.form.get('firstName').setValue(this.currentUser.firstName);
this.form.get('lastName').setValue(this.currentUser.lastName);
this.form.get('phoneHome').setValue(this.currentUser.phoneHome);
if (this.currentUser.preferredLanguage) {
this.form
.get('preferredLanguage')
.setValue(this.currentUser.preferredLanguage ? this.currentUser.preferredLanguage : this.countryCode);
}
}
}

Expand All @@ -91,9 +85,8 @@ export class AccountProfileUserComponent implements OnInit, OnChanges {
const firstName = this.form.get('firstName').value;
const lastName = this.form.get('lastName').value;
const phoneHome = this.form.get('phoneHome').value;
const preferredLanguage = this.form.get('preferredLanguage').value;

this.updateUserProfile.emit({ ...this.currentUser, title, firstName, lastName, phoneHome, preferredLanguage });
this.updateUserProfile.emit({ ...this.currentUser, title, firstName, lastName, phoneHome });
}

get buttonDisabled() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ <h3>{{ 'account.profile.detail.heading' | translate }}</h3>
<dd class="col-md-8" data-testing-id="birthday-field">{{
user.birthday ? (user.birthday | ishDate) : ('account.profile.birthday.not_available' | translate)
}}</dd>
<dt class="col-md-4">{{ 'account.profile.language.label' | translate }}</dt>
<dd class="col-md-8" data-testing-id="preferred-language-field">{{ preferredLanguageName }}</dd>
</dl>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { ChangeDetectionStrategy, Component, Inject, Input } from '@angular/core';
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';

import { AVAILABLE_LOCALES } from 'ish-core/configurations/injection-keys';
import { Customer } from 'ish-core/models/customer/customer.model';
import { Locale } from 'ish-core/models/locale/locale.model';
import { User } from 'ish-core/models/user/user.model';

@Component({
Expand All @@ -13,18 +11,4 @@ import { User } from 'ish-core/models/user/user.model';
export class AccountProfileComponent {
@Input() user: User;
@Input() customer: Customer;

constructor(@Inject(AVAILABLE_LOCALES) public locales: Locale[]) {}

get preferredLanguageName(): string {
if (
!this.user ||
!this.user.preferredLanguage ||
!this.locales ||
!this.locales.some(locale => locale.lang === this.user.preferredLanguage)
) {
return '';
}
return this.locales.find(locale => locale.lang === this.user.preferredLanguage).displayLong;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ <h2>

<ish-address-form-container [parentForm]="form"></ish-address-form-container>

<!--- TODO: language and birthday selection
<ish-registration-personal-form
[parentForm]="form"
[languages]="languages"></ish-registration-personal-form>
<!--- TODO: birthday selection
<ish-input-birthday [form]="parentForm" controlName="birthday"></ish-input-birthday>
-->

<ish-registration-company-form
Expand Down
2 changes: 0 additions & 2 deletions src/app/pages/registration/registration-page.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { RegistrationCompanyFormComponent } from './registration-company-form/re
import { RegistrationCredentialsFormComponent } from './registration-credentials-form/registration-credentials-form.component';
import { RegistrationFormComponent } from './registration-form/registration-form.component';
import { RegistrationPageComponent } from './registration-page.component';
import { RegistrationPersonalFormComponent } from './registration-personal-form/registration-personal-form.component';

const registrationPageRoutes: Routes = [{ path: '', component: RegistrationPageComponent }];

Expand All @@ -18,7 +17,6 @@ const registrationPageRoutes: Routes = [{ path: '', component: RegistrationPageC
RegistrationCredentialsFormComponent,
RegistrationFormComponent,
RegistrationPageComponent,
RegistrationPersonalFormComponent,
],
})
export class RegistrationPageModule {}

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 12d3e03

Please sign in to comment.