Skip to content

Commit 06cb72a

Browse files
Fixes for eventGroups (#278)
Co-authored-by: Sandor Ban <[email protected]>
1 parent 1c5f6b0 commit 06cb72a

File tree

7 files changed

+47
-8
lines changed

7 files changed

+47
-8
lines changed

src/app/events/event-components/event-group-filters/event-group-filters-form-data.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ export const FORM_DATA_EVENT_GROUP_FILTERS = [
1515
fields: [
1616
{
1717
...FORM_DATA_SEARCHBOX,
18-
key: 'nameEpidLike',
19-
placeholder: 'strings.promptSearch',
18+
key: 'freeText',
19+
placeholder: 'strings.promptEventsSearchFieldEventGroups',
2020
className: 'fullwidth',
2121
},
2222
],
@@ -41,8 +41,8 @@ export const FORM_DATA_EVENT_GROUP_FILTERS = [
4141
fields: [
4242
{
4343
...FORM_DATA_SEARCHBOX,
44-
key: 'eventLike',
45-
placeholder: 'strings.promptEventsSearchFieldEventGroups',
44+
key: 'freeTextEvent',
45+
placeholder: 'eventGroupEventSearch',
4646
className: 'fullwidth',
4747
},
4848
],

src/app/events/event-components/event-groups-list/event-groups-list.component.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22
<h1 class="page-header-title">
33
{{ 'captions.View.groups' | translate }}
44
</h1>
5+
<div class="page-header-actions">
6+
<button mat-flat-button color="primary" (click)="openAddEventModal()">
7+
{{ 'captions.eventNewEvent' | translate }}
8+
</button>
9+
</div>
510
</div>
611
<app-table
712
[resourceService]="eventGroupService"
813
[tableColumns]="defaultColumns"
914
[isSortable]="true"
1015
[isHeaderSticky]="true"
1116
[fullHeight]="true"
12-
[appearance]="tableAppearanceOptions.MINIMAL"
1317
[viewOptions]="actionsViewOption"
1418
>
1519
</app-table>

src/app/events/event-components/event-groups-list/event-groups-list.component.spec.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
22
import { TranslateModule } from '@ngx-translate/core';
33
import { HttpClientTestingModule } from '@angular/common/http/testing';
44
import { RouterTestingModule } from '@angular/router/testing';
5+
import { MatDialogModule } from '@angular/material/dialog';
56
import { EventGroupsListComponent } from './event-groups-list.component';
67

78
describe('EventGroupsListComponent', () => {
@@ -11,7 +12,12 @@ describe('EventGroupsListComponent', () => {
1112
beforeEach(async () => {
1213
await TestBed.configureTestingModule({
1314
declarations: [EventGroupsListComponent],
14-
imports: [TranslateModule.forRoot(), HttpClientTestingModule, RouterTestingModule],
15+
imports: [
16+
TranslateModule.forRoot(),
17+
HttpClientTestingModule,
18+
RouterTestingModule,
19+
MatDialogModule,
20+
],
1521
}).compileComponents();
1622
});
1723

src/app/events/event-components/event-groups-list/event-groups-list.component.ts

+28-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import { Component, OnDestroy } from '@angular/core';
2-
import { Router } from '@angular/router';
2+
import { MatDialog } from '@angular/material/dialog';
3+
import { TranslateService } from '@ngx-translate/core';
34
import { Subscription } from 'rxjs';
5+
import { AddEditBaseModalComponent } from '../../../shared/modals/add-edit-base-modal/add-edit-base-modal.component';
6+
import { ADD_MODAL_MAX_WIDTH } from '../../../_constants/common';
47
import { TableAppearanceOptions } from '../../../_constants/enums';
58
import { NavItem, TableColumn } from '../../../_models/common';
69
import { EventGroupService } from '../../../_services/api/event-group.service';
10+
import { EventAddComponent } from '../../event-add/event-add.component';
711
import { viewOptionsDefs } from './event-groups-list-action-data';
812
import { defaultColumnDefs } from './event-groups-list-table-data';
913

@@ -18,7 +22,29 @@ export class EventGroupsListComponent implements OnDestroy {
1822
tableAppearanceOptions = TableAppearanceOptions;
1923

2024
private subscription: Subscription[] = [];
21-
constructor(public eventGroupService: EventGroupService, private router: Router) {}
25+
constructor(
26+
public eventGroupService: EventGroupService,
27+
private dialog: MatDialog,
28+
private translateService: TranslateService
29+
) {}
30+
31+
openAddEventModal(): void {
32+
const dialogRef = this.dialog.open(AddEditBaseModalComponent, {
33+
maxWidth: ADD_MODAL_MAX_WIDTH,
34+
data: {
35+
title: this.translateService.instant('strings.headingCreateNewEvent'),
36+
component: EventAddComponent,
37+
},
38+
});
39+
40+
this.subscription.push(
41+
dialogRef.afterClosed().subscribe((result) => {
42+
if (result) {
43+
// callback
44+
}
45+
})
46+
);
47+
}
2248

2349
ngOnDestroy(): void {
2450
this.subscription.forEach((subscription) => subscription.unsubscribe());

src/app/shared/filters/filters-form/filters-form.component.ts

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export class FiltersFormComponent implements OnInit, OnDestroy {
7777
}
7878

7979
ngOnDestroy(): void {
80+
this.formActionsService.setDiscard(this.formId);
8081
this.subscriptions.forEach((subscription) => subscription.unsubscribe());
8182
}
8283
}

src/assets/i18n/custom-translations.json

+1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
"eventGroup.responsibleCommunity": "Responsible community",
115115
"headingConfirmUnlink": "Confirm unlink",
116116
"confirmationUnlinkEventFromGroup": "Are you sure you want to unlink this event from this group?",
117+
"eventGroupEventSearch": "Search by Event, title, description",
117118
"aboutSormasGithub": "SORMAS Github",
118119
"aboutContactSupport": "Contact support",
119120
"aboutGiveFeedback": "Give feedback",

src/assets/i18n/en.json

+1
Original file line numberDiff line numberDiff line change
@@ -5863,6 +5863,7 @@
58635863
"eventGroup.responsibleCommunity": "Responsible community",
58645864
"headingConfirmUnlink": "Confirm unlink",
58655865
"confirmationUnlinkEventFromGroup": "Are you sure you want to unlink this event from this group?",
5866+
"eventGroupEventSearch": "Search by Event, title, description",
58665867
"aboutSormasGithub": "SORMAS Github",
58675868
"aboutContactSupport": "Contact support",
58685869
"aboutGiveFeedback": "Give feedback",

0 commit comments

Comments
 (0)