-
Notifications
You must be signed in to change notification settings - Fork 44
Joining offers form (fixes 982) #1066
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
OtisRed
wants to merge
11
commits into
CodeForPoznan:master
Choose a base branch
from
OtisRed:joining_offers
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+120
−2
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9d8bb88
982 changes after recovery
OtisRed cf67d9c
impoved form
OtisRed d9ace6e
minor changes
OtisRed e23b903
added reponse to errors and placeholder in a form
OtisRed f9c01c5
honey pot added
OtisRed 9e1a06b
styling of the button
OtisRed 551a6a7
code aesthetic fixes
OtisRed b08b326
placeholder fixes
OtisRed 30f68e6
merging upstream
OtisRed 19315fd
adjusting code to review comments
OtisRed 951d28a
hiding the bot trap
OtisRed File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
frontend/src/app/offers/offer-join-form/offer-join-form.component.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| <div class="container"> | ||
| <form [formGroup]="joinForm" (ngSubmit)="onSubmit()"> | ||
| <div class="form-group row"> | ||
| <label class="col-sm-4 col-md-3 col-lg-2 col-form-label" for="fullname">Imię i nazwisko:</label> | ||
| <div class="col-sm-8 col-md-9 col-lg-10"> | ||
| <input class="form-control" formControlName="applicantName" id="fullname"/> | ||
| </div> | ||
| </div> | ||
| <div class="form-group row"> | ||
| <label class="col-sm-4 col-md-3 col-lg-2 col-form-label" for="email">Email:</label> | ||
| <div class="col-sm-8 col-md-9 col-lg-10"> | ||
| <input class="form-control" formControlName="applicantEmail" id="email"/> | ||
| </div> | ||
| </div> | ||
| <div class="form-group row"> | ||
| <label class="col-sm-4 col-md-3 col-lg-2 col-form-label" for="phone">Telefon:</label> | ||
| <div class="col-sm-8 col-md-9 col-lg-10"> | ||
| <input class="form-control" formControlName="phoneNo" id="phone" [imask]="{mask: '+48 000-000-000'}"/> | ||
| </div> | ||
| </div> | ||
| <div> | ||
| <label for="message">Możliwe uwagi:</label> | ||
| <textarea type="text" class="form-control" rows="3" id="message" placeholder="{{ communicate }}" formControlName="message"></textarea> | ||
| <volontulo-form-error [fc]="joinForm.controls.message" [minLength]="10" [maxLength]="2000"></volontulo-form-error> | ||
| </div> | ||
| <div class="form-group row d-none"> | ||
| <label class="col-sm-4 col-md-3 col-lg-2 col-form-label">Bot trap</label> | ||
| <div class="col-sm-8 col-md-9 col-lg-10"> | ||
| <input type="text" class="form-control" formControlName="honeyValue" /> | ||
| </div> | ||
| </div> | ||
| <div class="d-flex justify-content-center p-3"> | ||
| <button type="submit" name="submit" class="btn btn-primary" [disabled]="joinForm.invalid && submitEnabled"> | ||
| Zgłaszam się do pomocy | ||
| </button> | ||
| </div> | ||
| </form> | ||
| </div> | ||
|
|
68 changes: 68 additions & 0 deletions
68
frontend/src/app/offers/offer-join-form/offer-join-form.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| 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 error; | ||
| public communicate = 'Dodatkowe informacje dla organizatora (pole nieobowiązkowe)'; | ||
| 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: [''], | ||
| }); | ||
| public offerId: number; | ||
| public submitEnabled = true; | ||
|
|
||
| constructor( | ||
| private activatedRoute: ActivatedRoute, | ||
| private authService: AuthService, | ||
| private fb: FormBuilder, | ||
| private httpClient: HttpClient, | ||
| private location: Location, | ||
| private offersService: OffersService, | ||
| private userService: UserService, | ||
| ) { | ||
| } | ||
|
|
||
| ngOnInit() { | ||
| this.authService.user$ | ||
| .subscribe( | ||
| (user: User) => { | ||
| this.joinForm.controls.applicantEmail.setValue(user.email); | ||
| this.joinForm.controls.applicantName.setValue(this.userService.getFullName(user)); | ||
| this.joinForm.controls.phoneNo.setValue(user.phoneNo); | ||
| } | ||
| ); | ||
|
|
||
| this.activatedRoute.params | ||
| .switchMap(params => this.offerId = params.offerId) | ||
| .subscribe() | ||
| } | ||
|
|
||
| onSubmit() { | ||
| if (this.joinForm.valid && !this.joinForm.value.honeyValue) { | ||
| this.submitEnabled = false; | ||
|
|
||
| this.offersService.joinOffer(this.offerId, this.joinForm.value.message).subscribe( | ||
| response => { | ||
| if (response.status === 201) { | ||
| this.location.back()}}, | ||
| err => this.error = err.error.nonFieldErrors | ||
| ) | ||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose that the type of this variable is HttpRequestError or smth like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so. I haven't put it there. IDE did it itself when I used this expresson
err => this.error = err.error.nonFieldErrors