Skip to content

Commit 835c38e

Browse files
Merge pull request #3740 from ita-social-projects/bugfix/6821-the-location-that-is-outside-of-ukraine-cant-be-entered-manually
Bugfix/6821 the location that is outside of ukraine cant be entered manually
2 parents 82ca116 + c421690 commit 835c38e

12 files changed

Lines changed: 452 additions & 46 deletions

File tree

src/app/greencity/modules/events/components/event-editor/components/create-event-dates/place-online/place-online.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ export class PlaceOnlineComponent implements OnInit, OnDestroy {
4040
private readonly defaultPosition = { coords: { lat: 49.84579567734425, lng: 24.025124653312258 } };
4141

4242
private _regionOptions: google.maps.places.AutocompleteOptions = {
43-
types: ['address'],
44-
componentRestrictions: { country: 'UA' }
43+
types: ['address']
4544
};
4645
private _lastLocation: { coordinates: PlaceOnline; place: string } = {
4746
coordinates: null,

src/app/shared/components/dialog-pop-up/dialog-pop-up.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<div class="main-container">
2+
<img *ngIf="isEditOrPayPopup" [src]="icons.cross" class="cross-img" alt="close-icon" (click)="userReply(undefined)" />
3+
24
<div class="warning-text">
35
<div class="warning-title" *ngIf="popupTitle">{{ popupTitle | translate }}</div>
46
<div class="warning-subtitle" *ngIf="popupSubtitle">{{ popupSubtitle | translate }}</div>

src/app/shared/components/dialog-pop-up/dialog-pop-up.component.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,13 @@
131131
text-align: center;
132132
}
133133
}
134+
135+
.cross-img {
136+
position: absolute;
137+
cursor: pointer;
138+
top: 10px;
139+
right: 10px;
140+
color: var(--ubs-quintynary-light-grey);
141+
width: 10px;
142+
height: 10px;
143+
}

src/app/shared/components/dialog-pop-up/dialog-pop-up.component.spec.ts

Lines changed: 77 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
22
import { MatDialogModule, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
33
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
44
import { TranslateModule } from '@ngx-translate/core';
5-
import { of } from 'rxjs';
5+
import { Observable, of, Subject } from 'rxjs';
66

77
import { DialogPopUpComponent } from './dialog-pop-up.component';
88

@@ -15,14 +15,14 @@ describe('DialogPopUpComponent', () => {
1515
popupConfirm: 'popupSubtitle',
1616
popupCancel: 'popupSubtitle'
1717
};
18-
const dialogRefStub = {
19-
keydownEvents() {
20-
return of();
21-
},
22-
backdropClick() {
23-
return of();
24-
},
25-
close() {}
18+
const dialogRefStub: {
19+
keydownEvents: () => Observable<KeyboardEvent>;
20+
backdropClick: () => Observable<void>;
21+
close: () => void;
22+
} = {
23+
keydownEvents: () => of(),
24+
backdropClick: () => of(),
25+
close: () => {}
2626
};
2727

2828
beforeEach(waitForAsync(() => {
@@ -45,4 +45,72 @@ describe('DialogPopUpComponent', () => {
4545
it('should create', () => {
4646
expect(component).toBeTruthy();
4747
});
48+
49+
it('it should set component isEditOrPayPopup to true if data.isEditOrPayPopup set to true', () => {
50+
component.data.isEditOrPayPopup = true;
51+
component.ngOnInit();
52+
expect(component.isEditOrPayPopup).toBeTrue();
53+
});
54+
55+
it('it should set component isEditOrPayPopup to false if data.isEditOrPayPopup set to false', () => {
56+
component.data.isEditOrPayPopup = false;
57+
component.ngOnInit();
58+
expect(component.isEditOrPayPopup).toBeFalsy();
59+
});
60+
61+
it('setTitles should be called onInit', () => {
62+
const setTitlesSpy = spyOn(component as any, 'setTitles');
63+
component.ngOnInit();
64+
expect(setTitlesSpy).toHaveBeenCalled();
65+
});
66+
67+
it('should call userReply with undefined if isEditOrPayPopup is true on a backdrop click', () => {
68+
const mockBackdrop = new Subject<void>();
69+
dialogRefStub.backdropClick = () => mockBackdrop.asObservable();
70+
spyOn(component, 'userReply');
71+
component.data.isEditOrPayPopup = true;
72+
73+
component.ngOnInit();
74+
mockBackdrop.next();
75+
76+
expect(component.isEditOrPayPopup).toBeTrue();
77+
expect(component.userReply).toHaveBeenCalledWith(undefined);
78+
});
79+
80+
it('should call userReply with false if isEditOrPayPopup isnt true on a backdrop click', () => {
81+
const mockBackdrop = new Subject<void>();
82+
dialogRefStub.backdropClick = () => mockBackdrop.asObservable();
83+
spyOn(component, 'userReply');
84+
component.data.isEditOrPayPopup = false;
85+
86+
component.ngOnInit();
87+
mockBackdrop.next();
88+
89+
expect(component.isEditOrPayPopup).toBeFalsy();
90+
expect(component.userReply).toHaveBeenCalledWith(false);
91+
});
92+
93+
it('should call userReply with undefined if isEditOrPayPopup is true on Escape keydown', () => {
94+
const mockKeydown = new Subject<KeyboardEvent>();
95+
dialogRefStub.keydownEvents = () => mockKeydown.asObservable();
96+
spyOn(component, 'userReply');
97+
component.data.isEditOrPayPopup = true;
98+
99+
component.ngOnInit();
100+
mockKeydown.next(new KeyboardEvent('keydown', { key: 'Escape' }));
101+
102+
expect(component.userReply).toHaveBeenCalledWith(undefined);
103+
});
104+
105+
it('should call userReply with false if isEditOrPayPopup is false on Escape keydown', () => {
106+
const mockKeydown = new Subject<KeyboardEvent>();
107+
dialogRefStub.keydownEvents = () => mockKeydown.asObservable();
108+
spyOn(component, 'userReply');
109+
component.data.isEditOrPayPopup = false;
110+
111+
component.ngOnInit();
112+
mockKeydown.next(new KeyboardEvent('keydown', { key: 'Escape' }));
113+
114+
expect(component.userReply).toHaveBeenCalledWith(false);
115+
});
48116
});

src/app/shared/components/dialog-pop-up/dialog-pop-up.component.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import { PopUpsStyles } from 'src/app/ubs/ubs-admin/components/ubs-admin-employe
1010
styleUrls: ['./dialog-pop-up.component.scss']
1111
})
1212
export class DialogPopUpComponent implements OnInit, OnDestroy {
13+
icons = {
14+
cross: '././assets/img/ubs/cross.svg'
15+
};
16+
1317
private destroy$: Subject<boolean> = new Subject<boolean>();
1418
popupTitle: string;
1519
popupSubtitle: string;
@@ -21,6 +25,7 @@ export class DialogPopUpComponent implements OnInit, OnDestroy {
2125
isItrefund = false;
2226
іsPermissionConfirm = false;
2327
isCancelButtonShow = false;
28+
isEditOrPayPopup?: boolean;
2429

2530
constructor(
2631
private matDialogRef: MatDialogRef<DialogPopUpComponent>,
@@ -34,7 +39,7 @@ export class DialogPopUpComponent implements OnInit, OnDestroy {
3439
.pipe(takeUntil(this.destroy$))
3540
.subscribe((event) => {
3641
if (event.key === 'Escape') {
37-
this.userReply(false);
42+
this.userReply(this.isEditOrPayPopup ? undefined : false);
3843
}
3944
if (event.key === 'Enter') {
4045
this.userReply(true);
@@ -44,7 +49,7 @@ export class DialogPopUpComponent implements OnInit, OnDestroy {
4449
.backdropClick()
4550
.pipe(takeUntil(this.destroy$))
4651
.subscribe(() => {
47-
this.userReply(false);
52+
this.userReply(this.isEditOrPayPopup ? undefined : false);
4853
});
4954
this.isCancelButtonShow = !this.isItrefund || !this.іsPermissionConfirm;
5055
}
@@ -54,14 +59,15 @@ export class DialogPopUpComponent implements OnInit, OnDestroy {
5459
this.popupSubtitle = this.data.popupSubtitle;
5560
this.popupConfirm = this.data.popupConfirm;
5661
this.popupCancel = this.data.popupCancel;
62+
this.isEditOrPayPopup = this.data.isEditOrPayPopup;
5763
this.setBtnStyleGreen = this.data.style === PopUpsStyles.green;
5864
this.setBtnStyleRed = this.data.style === PopUpsStyles.red;
5965
this.setBtnStyleLightGreen = this.data.style === PopUpsStyles.lightGreen;
6066
this.isItrefund = this.data.isItrefund;
6167
this.іsPermissionConfirm = this.data.іsPermissionConfirm;
6268
}
6369

64-
userReply(reply: boolean): void {
70+
userReply(reply: boolean | undefined): void {
6571
this.matDialogRef.close(reply);
6672
}
6773

0 commit comments

Comments
 (0)