From 9d8bb886c410c9c589d741af66f260e5157c52f7 Mon Sep 17 00:00:00 2001 From: OtisRed Date: Wed, 12 Sep 2018 22:18:18 +0200 Subject: [PATCH 01/10] 982 changes after recovery --- frontend/src/app/app.module.ts | 9 ++- .../src/app/homepage-offer/offers.service.ts | 4 ++ .../offer-detail/offer-detail.component.html | 2 +- .../offer-join-form.component.html | 35 ++++++++++ .../offer-join-form.component.ts | 67 +++++++++++++++++++ 5 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 frontend/src/app/offers/offer-join-form/offer-join-form.component.html create mode 100644 frontend/src/app/offers/offer-join-form/offer-join-form.component.ts diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index fd3391b6..f8feeed2 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -55,6 +55,7 @@ import { FormErrorComponent } from './form-error/form-error.component'; import { ContactService } from './contact.service'; import { UserProfileComponent } from './user-profile/user-profile.component'; import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { OfferJoinFormComponent } from './offers/offer-join-form/offer-join-form.component'; Raven.config(environment.sentryDSN).install(); @@ -166,6 +167,11 @@ const appRoutes: Routes = [ component: UserProfileComponent, canActivate: [LoggedInGuard], }, + { + path: 'offers/:offerSlug/:offerId/join', + component: OfferJoinFormComponent, + canActivate: [LoggedInGuard], + }, { path: '**', component: RedirectComponent @@ -212,7 +218,8 @@ registerLocaleData(localePl); ContactComponent, FormErrorComponent, OrganizationsListComponent, - UserProfileComponent + UserProfileComponent, + OfferJoinFormComponent, ], imports: [ BrowserModule.withServerTransition({ appId: 'volontulo' }), diff --git a/frontend/src/app/homepage-offer/offers.service.ts b/frontend/src/app/homepage-offer/offers.service.ts index 5a506a6d..37b9bc04 100644 --- a/frontend/src/app/homepage-offer/offers.service.ts +++ b/frontend/src/app/homepage-offer/offers.service.ts @@ -35,4 +35,8 @@ export class OffersService { return this.http.put(`${environment.apiRoot}/offers/${id}/`, offer); } + joinOffer(id: number, message: string) { + return this.http.post(`${environment.apiRoot}/offers/${id}/join/`, {message}, {observe: 'response'}); + } + } diff --git a/frontend/src/app/offers/offer-detail/offer-detail.component.html b/frontend/src/app/offers/offer-detail/offer-detail.component.html index 51e2d40c..348d424b 100644 --- a/frontend/src/app/offers/offer-detail/offer-detail.component.html +++ b/frontend/src/app/offers/offer-detail/offer-detail.component.html @@ -68,7 +68,7 @@

Pomagasz już w tej inicjatywie

Możesz pomóc?

Twoja pomoc jest ważna. Potrzebujemy Ciebie!

- Zgłoś się na ten wolontariat
diff --git a/frontend/src/app/offers/offer-join-form/offer-join-form.component.html b/frontend/src/app/offers/offer-join-form/offer-join-form.component.html new file mode 100644 index 00000000..2a55af53 --- /dev/null +++ b/frontend/src/app/offers/offer-join-form/offer-join-form.component.html @@ -0,0 +1,35 @@ +
+
+
+ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + +
+
+
+
+ +
+
+
+
+ diff --git a/frontend/src/app/offers/offer-join-form/offer-join-form.component.ts b/frontend/src/app/offers/offer-join-form/offer-join-form.component.ts new file mode 100644 index 00000000..d10e3849 --- /dev/null +++ b/frontend/src/app/offers/offer-join-form/offer-join-form.component.ts @@ -0,0 +1,67 @@ +import {Component, OnInit} from '@angular/core'; +import {FormBuilder, FormGroup, Validators} from '@angular/forms'; +import {HttpClient} from '@angular/common/http'; +import {Location} from '@angular/common' + +import {ActivatedRoute} from '@angular/router'; +import {AuthService} from '../../auth.service'; +import {OffersService} from 'app/homepage-offer/offers.service'; +import {User} from '../../user'; +import {UserService} from '../../user.service'; + +@Component({ + selector: 'volontulo-offer-join-form', + templateUrl: './offer-join-form.component.html' +}) + +export class OfferJoinFormComponent implements OnInit { + public joinForm: FormGroup = this.fb.group({ + applicant_email: [''], + applicant_name: [''], + message: ['', [Validators.minLength(10), Validators.maxLength(2000)]], + phone_no: [''], + }); + + public submitEnabled = false; + public success: null | boolean = null; + public offerId: number; + public error; + + constructor( + private activatedRoute: ActivatedRoute, + private fb: FormBuilder, + private authService: AuthService, + private userService: UserService, + private httpClient: HttpClient, + private offersService: OffersService, + private location: Location , + ) { + } + + ngOnInit() { + this.authService.user$ + .subscribe( + (user: User) => { + this.joinForm.controls.applicant_email.setValue(user.email); + this.joinForm.controls.applicant_name.setValue(this.userService.getFullName(user)); + this.joinForm.controls.phone_no.setValue(user.phoneNo); + } + ); + + this.activatedRoute.params + .switchMap(params => this.offerId = params.offerId) + .subscribe() + } + + onSubmit() { + if (this.joinForm.valid) { + this.submitEnabled = true; + + this.offersService.joinOffer(this.offerId, this.joinForm.value.message).subscribe( + response => { + if (response.status === 201) { + this.location.back()}} + ) + } + } +} From cf67d9c65f697a0cff3e5b829e7beca8b08bde42 Mon Sep 17 00:00:00 2001 From: OtisRed Date: Wed, 19 Sep 2018 21:48:10 +0200 Subject: [PATCH 02/10] impoved form --- .../offer-join-form.component.html | 42 +++++++++---------- .../offer-join-form.component.ts | 13 +++--- 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/frontend/src/app/offers/offer-join-form/offer-join-form.component.html b/frontend/src/app/offers/offer-join-form/offer-join-form.component.html index 2a55af53..cc9c36ab 100644 --- a/frontend/src/app/offers/offer-join-form/offer-join-form.component.html +++ b/frontend/src/app/offers/offer-join-form/offer-join-form.component.html @@ -1,35 +1,33 @@
- -
- + +
+
- -
- -
-
-
- -
- -
-
-
- -
- +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
-
-
-
-
diff --git a/frontend/src/app/offers/offer-join-form/offer-join-form.component.ts b/frontend/src/app/offers/offer-join-form/offer-join-form.component.ts index d10e3849..0598cbb1 100644 --- a/frontend/src/app/offers/offer-join-form/offer-join-form.component.ts +++ b/frontend/src/app/offers/offer-join-form/offer-join-form.component.ts @@ -16,14 +16,13 @@ import {UserService} from '../../user.service'; export class OfferJoinFormComponent implements OnInit { public joinForm: FormGroup = this.fb.group({ - applicant_email: [''], - applicant_name: [''], + applicantEmail: [{value: '', disabled: true}], + applicantName: [{value: '', disabled: true}], message: ['', [Validators.minLength(10), Validators.maxLength(2000)]], - phone_no: [''], + phoneNo: [{value: '', disabled: true}], }); public submitEnabled = false; - public success: null | boolean = null; public offerId: number; public error; @@ -42,9 +41,9 @@ export class OfferJoinFormComponent implements OnInit { this.authService.user$ .subscribe( (user: User) => { - this.joinForm.controls.applicant_email.setValue(user.email); - this.joinForm.controls.applicant_name.setValue(this.userService.getFullName(user)); - this.joinForm.controls.phone_no.setValue(user.phoneNo); + this.joinForm.controls.applicantEmail.setValue(user.email); + this.joinForm.controls.applicantName.setValue(this.userService.getFullName(user)); + this.joinForm.controls.phoneNo.setValue(user.phoneNo); } ); From d9ace6e7342493c5e5a86458c870faed774e85f7 Mon Sep 17 00:00:00 2001 From: OtisRed Date: Wed, 19 Sep 2018 22:03:34 +0200 Subject: [PATCH 03/10] minor changes --- .../app/offers/offer-join-form/offer-join-form.component.html | 2 +- .../src/app/offers/offer-join-form/offer-join-form.component.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/offers/offer-join-form/offer-join-form.component.html b/frontend/src/app/offers/offer-join-form/offer-join-form.component.html index cc9c36ab..9f785898 100644 --- a/frontend/src/app/offers/offer-join-form/offer-join-form.component.html +++ b/frontend/src/app/offers/offer-join-form/offer-join-form.component.html @@ -24,7 +24,7 @@
-
diff --git a/frontend/src/app/offers/offer-join-form/offer-join-form.component.ts b/frontend/src/app/offers/offer-join-form/offer-join-form.component.ts index 0598cbb1..5a3afb21 100644 --- a/frontend/src/app/offers/offer-join-form/offer-join-form.component.ts +++ b/frontend/src/app/offers/offer-join-form/offer-join-form.component.ts @@ -18,7 +18,7 @@ export class OfferJoinFormComponent implements OnInit { public joinForm: FormGroup = this.fb.group({ applicantEmail: [{value: '', disabled: true}], applicantName: [{value: '', disabled: true}], - message: ['', [Validators.minLength(10), Validators.maxLength(2000)]], + message: ['Miejsce na pytania i informacje do organizatora', [Validators.minLength(10), Validators.maxLength(2000)]], phoneNo: [{value: '', disabled: true}], }); From e23b903e82763694ab13971f639b466157abbb76 Mon Sep 17 00:00:00 2001 From: OtisRed Date: Wed, 26 Sep 2018 21:07:28 +0200 Subject: [PATCH 04/10] added reponse to errors and placeholder in a form --- frontend/package-lock.json | 2 +- .../offers/offer-join-form/offer-join-form.component.html | 2 +- .../offers/offer-join-form/offer-join-form.component.ts | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 8e06c608..8f99ab0b 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -5035,7 +5035,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", "dev": true, "requires": { "brace-expansion": "1.1.8" diff --git a/frontend/src/app/offers/offer-join-form/offer-join-form.component.html b/frontend/src/app/offers/offer-join-form/offer-join-form.component.html index 9f785898..228aca11 100644 --- a/frontend/src/app/offers/offer-join-form/offer-join-form.component.html +++ b/frontend/src/app/offers/offer-join-form/offer-join-form.component.html @@ -20,7 +20,7 @@
- +
diff --git a/frontend/src/app/offers/offer-join-form/offer-join-form.component.ts b/frontend/src/app/offers/offer-join-form/offer-join-form.component.ts index 5a3afb21..7f39b714 100644 --- a/frontend/src/app/offers/offer-join-form/offer-join-form.component.ts +++ b/frontend/src/app/offers/offer-join-form/offer-join-form.component.ts @@ -18,7 +18,7 @@ export class OfferJoinFormComponent implements OnInit { public joinForm: FormGroup = this.fb.group({ applicantEmail: [{value: '', disabled: true}], applicantName: [{value: '', disabled: true}], - message: ['Miejsce na pytania i informacje do organizatora', [Validators.minLength(10), Validators.maxLength(2000)]], + message: ['', [Validators.minLength(10), Validators.maxLength(2000)]], phoneNo: [{value: '', disabled: true}], }); @@ -33,7 +33,7 @@ export class OfferJoinFormComponent implements OnInit { private userService: UserService, private httpClient: HttpClient, private offersService: OffersService, - private location: Location , + private location: Location, ) { } @@ -59,7 +59,8 @@ export class OfferJoinFormComponent implements OnInit { this.offersService.joinOffer(this.offerId, this.joinForm.value.message).subscribe( response => { if (response.status === 201) { - this.location.back()}} + this.location.back()}}, + err => this.error = err.error.nonFieldErrors ) } } From f9c01c502f912af434e77a437b1a77457aef376b Mon Sep 17 00:00:00 2001 From: OtisRed Date: Wed, 26 Sep 2018 21:31:04 +0200 Subject: [PATCH 05/10] honey pot added --- .../offers/offer-join-form/offer-join-form.component.html | 6 ++++++ .../app/offers/offer-join-form/offer-join-form.component.ts | 2 ++ 2 files changed, 8 insertions(+) diff --git a/frontend/src/app/offers/offer-join-form/offer-join-form.component.html b/frontend/src/app/offers/offer-join-form/offer-join-form.component.html index 228aca11..73dff5d6 100644 --- a/frontend/src/app/offers/offer-join-form/offer-join-form.component.html +++ b/frontend/src/app/offers/offer-join-form/offer-join-form.component.html @@ -23,6 +23,12 @@
+
+ +
+ +
+
From 551a6a79635819eefbdea2d68aac958368c8cf3e Mon Sep 17 00:00:00 2001 From: OtisRed Date: Thu, 27 Sep 2018 15:57:10 +0200 Subject: [PATCH 07/10] code aesthetic fixes --- .../offer-join-form/offer-join-form.component.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/frontend/src/app/offers/offer-join-form/offer-join-form.component.ts b/frontend/src/app/offers/offer-join-form/offer-join-form.component.ts index 5668725e..98cc1406 100644 --- a/frontend/src/app/offers/offer-join-form/offer-join-form.component.ts +++ b/frontend/src/app/offers/offer-join-form/offer-join-form.component.ts @@ -15,26 +15,25 @@ import {UserService} from '../../user.service'; }) export class OfferJoinFormComponent implements OnInit { + public error; public joinForm: FormGroup = this.fb.group({ applicantEmail: [{value: '', disabled: true}], applicantName: [{value: '', disabled: true}], message: ['', [Validators.minLength(10), Validators.maxLength(2000)]], phoneNo: [{value: '', disabled: true}], - honeyValue: '', + honeyValue: [''], }); - - public submitEnabled = false; public offerId: number; - public error; + public submitEnabled = false; constructor( private activatedRoute: ActivatedRoute, - private fb: FormBuilder, private authService: AuthService, - private userService: UserService, + private fb: FormBuilder, private httpClient: HttpClient, - private offersService: OffersService, private location: Location, + private offersService: OffersService, + private userService: UserService, ) { } @@ -56,7 +55,7 @@ export class OfferJoinFormComponent implements OnInit { onSubmit() { if (this.joinForm.valid) { this.submitEnabled = true; - delete this.joinForm.value.honey_value; + delete this.joinForm.value.honeyValue; this.offersService.joinOffer(this.offerId, this.joinForm.value.message).subscribe( response => { From b08b326051e1aa09894af86c9cfb4e0675ac5619 Mon Sep 17 00:00:00 2001 From: OtisRed Date: Thu, 27 Sep 2018 16:11:46 +0200 Subject: [PATCH 08/10] placeholder fixes --- .../app/offers/offer-join-form/offer-join-form.component.html | 2 +- .../src/app/offers/offer-join-form/offer-join-form.component.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/offers/offer-join-form/offer-join-form.component.html b/frontend/src/app/offers/offer-join-form/offer-join-form.component.html index 8c0c97c3..9b6dd3b3 100644 --- a/frontend/src/app/offers/offer-join-form/offer-join-form.component.html +++ b/frontend/src/app/offers/offer-join-form/offer-join-form.component.html @@ -20,7 +20,7 @@
- +
diff --git a/frontend/src/app/offers/offer-join-form/offer-join-form.component.ts b/frontend/src/app/offers/offer-join-form/offer-join-form.component.ts index 98cc1406..f68bc3bd 100644 --- a/frontend/src/app/offers/offer-join-form/offer-join-form.component.ts +++ b/frontend/src/app/offers/offer-join-form/offer-join-form.component.ts @@ -25,6 +25,7 @@ export class OfferJoinFormComponent implements OnInit { }); public offerId: number; public submitEnabled = false; + public communicate = 'Dodatkowe informacje dla organizatora (pole nieobowiązkowe)'; constructor( private activatedRoute: ActivatedRoute, From 19315fdb58bfe8fa26599967afed4a72165cc9bb Mon Sep 17 00:00:00 2001 From: OtisRed Date: Wed, 10 Oct 2018 19:51:23 +0200 Subject: [PATCH 09/10] adjusting code to review comments --- .../offer-join-form.component.html | 8 +++--- .../offer-join-form.component.ts | 27 +++++++++---------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/frontend/src/app/offers/offer-join-form/offer-join-form.component.html b/frontend/src/app/offers/offer-join-form/offer-join-form.component.html index 9b6dd3b3..e1c5610a 100644 --- a/frontend/src/app/offers/offer-join-form/offer-join-form.component.html +++ b/frontend/src/app/offers/offer-join-form/offer-join-form.component.html @@ -15,7 +15,7 @@
- +
@@ -23,14 +23,14 @@
-
+
-
-
diff --git a/frontend/src/app/offers/offer-join-form/offer-join-form.component.ts b/frontend/src/app/offers/offer-join-form/offer-join-form.component.ts index f68bc3bd..e9b7b7a6 100644 --- a/frontend/src/app/offers/offer-join-form/offer-join-form.component.ts +++ b/frontend/src/app/offers/offer-join-form/offer-join-form.component.ts @@ -1,13 +1,13 @@ -import {Component, OnInit} from '@angular/core'; -import {FormBuilder, FormGroup, Validators} from '@angular/forms'; -import {HttpClient} from '@angular/common/http'; -import {Location} from '@angular/common' +import { Component, OnInit } from '@angular/core'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { HttpClient } from '@angular/common/http'; +import { Location } from '@angular/common' -import {ActivatedRoute} from '@angular/router'; -import {AuthService} from '../../auth.service'; -import {OffersService} from 'app/homepage-offer/offers.service'; -import {User} from '../../user'; -import {UserService} from '../../user.service'; +import { ActivatedRoute } from '@angular/router'; +import { AuthService } from '../../auth.service'; +import { OffersService } from 'app/homepage-offer/offers.service'; +import { User } from '../../user'; +import { UserService } from '../../user.service'; @Component({ selector: 'volontulo-offer-join-form', @@ -16,6 +16,7 @@ import {UserService} from '../../user.service'; export class OfferJoinFormComponent implements OnInit { public error; + public communicate = 'Dodatkowe informacje dla organizatora (pole nieobowiązkowe)'; public joinForm: FormGroup = this.fb.group({ applicantEmail: [{value: '', disabled: true}], applicantName: [{value: '', disabled: true}], @@ -24,8 +25,7 @@ export class OfferJoinFormComponent implements OnInit { honeyValue: [''], }); public offerId: number; - public submitEnabled = false; - public communicate = 'Dodatkowe informacje dla organizatora (pole nieobowiązkowe)'; + public submitEnabled = true; constructor( private activatedRoute: ActivatedRoute, @@ -54,9 +54,8 @@ export class OfferJoinFormComponent implements OnInit { } onSubmit() { - if (this.joinForm.valid) { - this.submitEnabled = true; - delete this.joinForm.value.honeyValue; + if (this.joinForm.valid && !this.joinForm.value.honeyValue) { + this.submitEnabled = false; this.offersService.joinOffer(this.offerId, this.joinForm.value.message).subscribe( response => { From 951d28a7e52e38f528450cf9d448906b25a93402 Mon Sep 17 00:00:00 2001 From: OtisRed Date: Wed, 10 Oct 2018 19:58:31 +0200 Subject: [PATCH 10/10] hiding the bot trap --- .../app/offers/offer-join-form/offer-join-form.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/app/offers/offer-join-form/offer-join-form.component.html b/frontend/src/app/offers/offer-join-form/offer-join-form.component.html index e1c5610a..6434bb14 100644 --- a/frontend/src/app/offers/offer-join-form/offer-join-form.component.html +++ b/frontend/src/app/offers/offer-join-form/offer-join-form.component.html @@ -23,7 +23,7 @@
-
+