-
Notifications
You must be signed in to change notification settings - Fork 5
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
added guard, fixed some errors with styling, and added some features #142
Changes from 2 commits
2a8ba3e
54b5e5e
41b5b0e
2e0d1ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { CanDeactivate } from '@angular/router'; | ||
import { Injectable } from '@angular/core'; | ||
import { ProviderConfigComponent } from './provider-config.component'; | ||
|
||
@Injectable({providedIn: 'root'}) | ||
export class CanDeactivateGuard implements CanDeactivate<ProviderConfigComponent> { | ||
canDeactivate(component: ProviderConfigComponent): boolean { | ||
if (component.orgFormGroup.dirty || component.addressFormGroup.dirty || component.photoFormGroup.dirty) { | ||
return confirm('У вас є не збережені дані, покинути сторінку?'); | ||
} | ||
return true; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,7 +82,7 @@ | |
</div> | ||
<div class="web-page"> | ||
<label for="webPageForm">Веб сайт</label> | ||
<input type="text" id="webPageForm" formControlName="webPage"> | ||
<input type="text" id="webPageForm" formControlName="webPage" placeholder="380XXXXXXX"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there any reason using ids instead of classes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. phone number placeholder for web page field? |
||
</div> | ||
<div class="facebook"> | ||
<label for="facebook">Facebook</label> | ||
|
@@ -97,16 +97,13 @@ | |
<input type="text" id="ownerName" formControlName="ownerName"> | ||
</div> | ||
<div class="buttons1"> | ||
<div class="buttons1_reset"> | ||
<button>СКАСУВАТИ</button> | ||
</div> | ||
<div class="buttons1_next"> | ||
<button | ||
mat-button matStepperNext [disabled]="orgFormGroup.valid" | ||
[ngClass]="{'disabled-button':!orgFormGroup.valid}" | ||
>ДАЛІ | ||
</button> | ||
</div> | ||
<button class="buttons1_reset" type="button" (click)="formReset()">СКАСУВАТИ</button> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use meaningful class names and follow conwention |
||
<button class="buttons1_next" | ||
type="button" | ||
matStepperNext [disabled]="orgFormGroup.valid" | ||
[ngClass]="{'disabled-button':!orgFormGroup.valid}" | ||
>ДАЛІ | ||
</button> | ||
</div> | ||
</div> | ||
</form> | ||
|
@@ -167,9 +164,9 @@ | |
</div> | ||
</ng-container> | ||
<div class="buttons2"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we dont need 3 sets of buttons, move them outside individual step and use for whole stepper |
||
<button class="buttons2_back" mat-button matStepperPrevious>НАЗАД</button> | ||
<button class="reset">СКАСУВАТИ</button> | ||
<button class="buttons2_next" mat-button matStepperNext | ||
<button class="buttons2_back" matStepperPrevious>НАЗАД</button> | ||
<button type="button" class="buttons2_reset" (click)="formReset()">СКАСУВАТИ</button> | ||
<button class="buttons2_next" matStepperNext | ||
[ngClass]="{'disabled-button':!addressFormGroup.valid}" | ||
[disabled]="addressFormGroup.valid" | ||
>ДАЛІ | ||
|
@@ -204,12 +201,14 @@ | |
<label for="text-desc">Опис<span class="important">*</span></label> | ||
<p> | ||
<span | ||
[ngClass]="{'highlight-text': !photoFormGroup.controls['text'].valid && photoFormGroup.controls['text'].touched }" | ||
class="default">{{photoFormGroup.controls['text'].value.length}}</span>/500</p> | ||
[ngClass]="{'highlight-text': !(photoFormGroup.controls['text']).valid && (photoFormGroup.controls['text']).touched }" | ||
class="default">{{(textValue) ? textValue.split('').length : '0'}}</span>/500</p> | ||
</div> | ||
<div class="description_form"> | ||
<textarea name="" id="text-desc" cols="30" rows="10" | ||
placeholder="Додайте опис вашого закладу" formControlName="text"></textarea> | ||
placeholder="Додайте опис вашого закладу" | ||
[(ngModel)]="textValue" | ||
formControlName="text"></textarea> | ||
</div> | ||
</div> | ||
<div class="photo-checkbox"> | ||
|
@@ -219,16 +218,16 @@ | |
</mat-checkbox> | ||
</div> | ||
</div> | ||
<div class="buttons3"> | ||
<button matStepperPrevious class="buttons3_back">НАЗАД</button> | ||
<button class="buttons3_reset" (click)="formReset()">СКАСУВАТИ</button> | ||
<button matStepperPrevious class="buttons3_reg" | ||
[ngClass]="{'disabled-button':!photoFormGroup.valid}" | ||
[disabled]="photoFormGroup.valid" | ||
>ЗАРЕЄСТРУВАТИ | ||
</button> | ||
</div> | ||
</form> | ||
<div class="buttons3"> | ||
<button mat-button matStepperPrevious class="buttons3_back">НАЗАД</button> | ||
<button mat-button class="reset">СКАСУВАТИ</button> | ||
<button mat-button matStepperPrevious class="buttons3_reg" | ||
[ngClass]="{'disabled-button':!photoFormGroup.valid}" | ||
[disabled]="photoFormGroup.valid" | ||
>ЗАРЕЄСТРУВАТИ | ||
</button> | ||
</div> | ||
</mat-step> | ||
</mat-horizontal-stepper> | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ export class ProviderConfigComponent implements OnInit { | |
organizationTypeList = ['ФОП', 'Громадська організація', 'ТОВ', 'ПП', 'Заклад освіти', 'Інше']; | ||
valueOwnership = false; | ||
valueOrgType = false; | ||
textValue = ''; | ||
|
||
constructor() { | ||
} | ||
|
@@ -29,7 +30,7 @@ export class ProviderConfigComponent implements OnInit { | |
ceoName: new FormControl(null, [Validators.required]), | ||
ceoBirthday: new FormControl(null, Validators.required), | ||
personalId: new FormControl(null, [Validators.required, Validators.maxLength(10), Validators.maxLength(8), Validators.pattern('^[0-9]*$')]), | ||
phone: new FormControl(380, [Validators.required, Validators.maxLength(10), Validators.minLength(10)]), | ||
phone: new FormControl(null, [Validators.required, Validators.maxLength(10), Validators.minLength(10)]), | ||
email: new FormControl(null, [Validators.required, Validators.email]), | ||
webPage: new FormControl(null), | ||
facebook: new FormControl(null), | ||
|
@@ -101,5 +102,18 @@ export class ProviderConfigComponent implements OnInit { | |
break; | ||
} | ||
} | ||
|
||
formReset(): void { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add annotation |
||
if (this.orgFormGroup.dirty || this.addressFormGroup.dirty || this.photoFormGroup.dirty) { | ||
const value = confirm('Скасувати реєстрацію нового закладу?'); | ||
if (value === true) { | ||
this.orgFormGroup.reset(); | ||
this.addressFormGroup.reset(); | ||
this.photoFormGroup.reset(); | ||
this.selectedLogos = []; | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
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.
is this a requirement?