Fix linter errors on account-edit

This commit is contained in:
Tom Bloor 2017-08-24 16:20:55 +01:00
parent 346ea2c6fd
commit c46e91e795

View file

@ -8,7 +8,7 @@ import 'rxjs/add/operator/map';
templateUrl: 'account-edit.component.html', templateUrl: 'account-edit.component.html',
providers: [ApiService] providers: [ApiService]
}) })
export class AccountEditComponent { export class AccountEditComponent implements OnInit {
settingForm: FormGroup; settingForm: FormGroup;
settingOrganisationForm: FormGroup; settingOrganisationForm: FormGroup;
settingCustomerForm: FormGroup; settingCustomerForm: FormGroup;
@ -17,27 +17,27 @@ export class AccountEditComponent {
constructor( constructor(
private http: Http, private http: Http,
private formBuilder: FormBuilder, private formBuilder: FormBuilder,
private api: ApiService, private api: ApiService,
) { ) {
this.settingForm = this.formBuilder.group({ this.settingForm = this.formBuilder.group({
email : ['', [Validators.required]], email : ['', [Validators.required]],
postcode : ['', [Validators.required]], postcode : ['', [Validators.required]],
password : ['', [Validators.required]], password : ['', [Validators.required]],
new_password : [''], new_password : [''],
profile_picture : [''], profile_picture : [''],
}); });
this.settingOrganisationForm = this.formBuilder.group({ this.settingOrganisationForm = this.formBuilder.group({
name : ['', [Validators.required]], name : ['', [Validators.required]],
street_name : ['', [Validators.required]], street_name : ['', [Validators.required]],
town : ['', [Validators.required]], town : ['', [Validators.required]],
}); });
this.settingCustomerForm = this.formBuilder.group({ this.settingCustomerForm = this.formBuilder.group({
full_name : ['', [Validators.required]], full_name : ['', [Validators.required]],
display_name : ['', [Validators.required]], display_name : ['', [Validators.required]],
}); });
} }
ngOnInit(): void { ngOnInit(): void {
this.api.accountFullLoad().subscribe( this.api.accountFullLoad().subscribe(
result => { result => {
@ -65,27 +65,27 @@ export class AccountEditComponent {
} }
); );
} }
onSubmitOrganisation() { onSubmitOrganisation() {
console.log(this.settingForm.valid); console.log(this.settingForm.valid);
if (!this.settingForm.valid && !this.settingOrganisationForm.valid) { if (!this.settingForm.valid && !this.settingOrganisationForm.valid) {
console.log("Not Valid!"); console.log('Not Valid!');
return; return;
}
let settingForm = this.settingForm.value;
let settingOrganisationForm = this.settingOrganisationForm.value;
// image upload code
let fi = this.fileInput.nativeElement;
let data = new FormData();
if (fi.files && fi.files[0]) {
let fileToUpload = fi.files[0];
data.append("file", fileToUpload);
} }
let submitData = { const settingForm = this.settingForm.value;
const settingOrganisationForm = this.settingOrganisationForm.value;
// image upload code
const fi = this.fileInput.nativeElement;
const data = new FormData();
if (fi.files && fi.files[0]) {
const fileToUpload = fi.files[0];
data.append('file', fileToUpload);
}
const submitData = {
email: settingForm.email, email: settingForm.email,
postcode: settingForm.postcode, postcode: settingForm.postcode,
password: settingForm.password, password: settingForm.password,
@ -93,12 +93,12 @@ export class AccountEditComponent {
name: settingOrganisationForm.name, name: settingOrganisationForm.name,
street_name: settingOrganisationForm.street_name, street_name: settingOrganisationForm.street_name,
town: settingOrganisationForm.town, town: settingOrganisationForm.town,
} };
data.append('form', JSON.stringify(submitData)); data.append('form', JSON.stringify(submitData));
console.log(data); console.log(data);
this.api this.api
.accountEditUpdate(data) .accountEditUpdate(data)
.subscribe( .subscribe(
result => { result => {
@ -109,38 +109,38 @@ export class AccountEditComponent {
} }
); );
} }
onSubmitCustomer() { onSubmitCustomer() {
console.log(this.settingForm.valid); console.log(this.settingForm.valid);
if (!this.settingForm.valid && !this.settingCustomerForm.valid) { if (!this.settingForm.valid && !this.settingCustomerForm.valid) {
console.log("Not Valid!"); console.log('Not Valid!');
return; return;
}
let settingForm = this.settingForm.value;
let settingCustomerForm = this.settingCustomerForm.value;
// image upload code
let fi = this.fileInput.nativeElement;
let data = new FormData();
if (fi.files && fi.files[0]) {
let fileToUpload = fi.files[0];
data.append("file", fileToUpload);
} }
let submitData = { const settingForm = this.settingForm.value;
const settingCustomerForm = this.settingCustomerForm.value;
// image upload code
const fi = this.fileInput.nativeElement;
const data = new FormData();
if (fi.files && fi.files[0]) {
const fileToUpload = fi.files[0];
data.append('file', fileToUpload);
}
const submitData = {
email: settingForm.email, email: settingForm.email,
postcode: settingForm.postcode, postcode: settingForm.postcode,
password: settingForm.password, password: settingForm.password,
new_password: settingForm.new_password, new_password: settingForm.new_password,
full_name: settingCustomerForm.full_name, full_name: settingCustomerForm.full_name,
display_name: settingCustomerForm.display_name, display_name: settingCustomerForm.display_name,
} };
data.append('form', JSON.stringify(submitData)); data.append('form', JSON.stringify(submitData));
this.api this.api
.accountEditUpdate(data) .accountEditUpdate(data)
.subscribe( .subscribe(
result => { result => {