Skip to content

Commit

Permalink
Merge pull request #3446 from ita-social-projects/bugfix/#7743-filters
Browse files Browse the repository at this point in the history
[Bugfix] #7743 Events filters
  • Loading branch information
hnativlyubomyr authored Nov 11, 2024
2 parents 566a1ef + 00a3844 commit 5b6e8bd
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,33 +116,36 @@
<mat-tab label="{{ 'homepage.events.my-space.tag-title' | translate }}">
<hr />
<div *ngIf="!loading; else spinner">
<div class="in-progress">
<div class="in-progress header" id="my-events" *ngIf="!isFavoriteBtnClicked">
<div class="buttons-wrapper">
<a [routerLink]="['/events/create-event']">
<div id="create-button-event" class="secondary-global-button s-btn">
<span>{{ 'profile.dashboard.add-event' | translate }}</span>
<div class="header">
<div class="in-progress">
<p>
<app-set-count [remainingCount]="totalEvents" [tabName]="'news'">
{{ (isFavoriteBtnClicked ? 'profile.dashboard.saved-events' : 'profile.dashboard.my-events') | translate }} <br />
</app-set-count>
</p>
<div class="in-progress" id="my-events">
<div class="buttons-wrapper">
<a [routerLink]="['/events/create-event']">
<div id="create-button-event" class="secondary-global-button s-btn">
<span>{{ 'profile.dashboard.add-event' | translate }}</span>
</div>
</a>
<div class="favourites" (click)="toggleFavorites()" (keydown.enter)="toggleFavorites()">
<span [ngClass]="isFavoriteBtnClicked ? 'flag-active' : 'flag'"></span>
</div>
</a>
<div class="favourites" (click)="goToFavorites()">
<span class="flag-active"></span>
</div>
</div>
</div>
<div *ngIf="isFavoriteBtnClicked" class="in-progress header">
<div class="button-arrow" (click)="escapeFromFavorites()">
<img [src]="images.arrowLeft" aria-hidden="true" alt="arrow" class="button-arrow-img" />
<div class="edit-events">{{ 'create-event.back' | translate }}</div>
</div>
</div>
<div class="events-filter filters">
<div class="events-types">
<mat-checkbox [(ngModel)]="isOnlineChecked" (ngModelChange)="onCheckboxChange()" color="primary" class="checkbox">
{{ 'homepage.events.my-space.event-type-online' | translate }}
</mat-checkbox>
<mat-checkbox [(ngModel)]="isOfflineChecked" (ngModelChange)="onCheckboxChange()" color="primary" class="checkbox"
>{{ 'homepage.events.my-space.event-type-offline' | translate }}
</mat-checkbox>
<div class="in-progress justify-end">
<div class="events-filter">
<div class="events-types">
<mat-checkbox [(ngModel)]="isOnlineChecked" (ngModelChange)="onCheckboxChange()" color="primary" class="checkbox">
{{ 'homepage.events.my-space.event-type-online' | translate }}
</mat-checkbox>
<mat-checkbox [(ngModel)]="isOfflineChecked" (ngModelChange)="onCheckboxChange()" color="primary" class="checkbox"
>{{ 'homepage.events.my-space.event-type-offline' | translate }}
</mat-checkbox>
</div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,16 +223,18 @@ describe('ProfileDashboardComponent', () => {
});

it('should toggle isFavoriteBtnClicked property on escapeFromFavorites method', () => {
component.isFavoriteBtnClicked = false;
expect(component.isFavoriteBtnClicked).toBeFalse();
component.escapeFromFavorites();
component.toggleFavorites();
expect(component.isFavoriteBtnClicked).toBeTrue();
component.escapeFromFavorites();
component.toggleFavorites();
expect(component.isFavoriteBtnClicked).toBeFalse();
});

it('should set isFavoriteBtnClicked to true and call getUserEvents when goToFavorites is called', () => {
spyOn(component, 'getUserEvents');
component.goToFavorites();
component.isFavoriteBtnClicked = false;
component.toggleFavorites();
expect(component.isFavoriteBtnClicked).toBeTrue();
expect(component.getUserEvents).toHaveBeenCalled();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,20 +140,13 @@ export class ProfileDashboardComponent implements OnInit, OnDestroy {
this.hasNextPageOfEvents = true;
}

escapeFromFavorites(): void {
toggleFavorites(): void {
this.isFavoriteBtnClicked = !this.isFavoriteBtnClicked;

this.cleanState();
this.getUserEvents();
}

goToFavorites(): void {
this.isFavoriteBtnClicked = true;

this.cleanState();
this.getUserEvents();
}

initGetUserEvents(): void {
this.eventService
.getEvents(this.getHttpParams(0))
Expand Down Expand Up @@ -193,6 +186,7 @@ export class ProfileDashboardComponent implements OnInit, OnDestroy {
next: (res: EventResponseDto) => {
this.eventsList.push(...res.page);
this.eventsPage++;
this.totalEvents = res.totalElements;
this.hasNextPageOfEvents = res.hasNext;
this.isActiveEventsScroll = res.hasNext;
},
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,7 @@
"my-habits": "My habits",
"my-news": "My news",
"my-events": "My events",
"saved-events": "Saved events",
"my-articles": "My articles",
"habits-inprogress": "In progress",
"add-new-habit": "Add New Habit",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/ua.json
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,7 @@
"my-habits": "Мої звички",
"my-news": "Мої новини",
"my-events": "Мої події",
"saved-events": "Збережені події",
"my-tips-and-tricks": "Мої статті",
"habits-inprogress": "У процесі",
"add-new-habit": "Додати Нову Звичку",
Expand Down

0 comments on commit 5b6e8bd

Please sign in to comment.