Skip to content

Commit b2687b3

Browse files
event actions (#488)
* event actions * events actions * ckeditor * ckeditor * fix * ..
1 parent 6f1fcd4 commit b2687b3

21 files changed

+9873
-32908
lines changed

package-lock.json

+9,563-32,904
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"@ngx-translate/core": "^13.0.0",
3434
"@ngx-translate/http-loader": "^6.0.0",
3535
"alertifyjs": "^1.13.1",
36+
"ckeditor4-angular": "^3.1.0",
3637
"concurrently": "^5.3.0",
3738
"date-fns": "^2.27.0",
3839
"echarts": "^5.2.2",

src/app/_constants/enums.ts

+13
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,19 @@ export enum ActionStatus {
10041004
IN_PROGRESS = 'enum.ActionStatus.IN_PROGRESS',
10051005
}
10061006

1007+
export enum ActionMeasure {
1008+
PROHIBITION_OF_ENTRY_AND_WORK_CASES = 'enum.ActionMeasure.PROHIBITION_OF_ENTRY_AND_WORK_CASES',
1009+
SAMPLE_COLLECTION = 'enum.ActionMeasure.SAMPLE_COLLECTION',
1010+
FORWARDING_TO_NATIONAL_REFERENCE_CENTER = 'enum.ActionMeasure.FORWARDING_TO_NATIONAL_REFERENCE_CENTER',
1011+
CONTACT_FOLLOW_UP = 'enum.ActionMeasure.CONTACT_FOLLOW_UP',
1012+
VERIFICATION_OF_VACCINATION_IMMUNIZATION = 'enum.ActionMeasure.VERIFICATION_OF_VACCINATION_IMMUNIZATION',
1013+
POST_EXPOSURE_PROPHYLAXIS_VACCINATION = 'enum.ActionMeasure.POST_EXPOSURE_PROPHYLAXIS_VACCINATION',
1014+
CLOSURE_OF_FACILITY = 'enum.ActionMeasure.CLOSURE_OF_FACILITY',
1015+
PROHIBITION_OF_ENTRY_AND_WORK_CONTACTS = 'enum.ActionMeasure.PROHIBITION_OF_ENTRY_AND_WORK_CONTACTS',
1016+
POPULATION_INFORMATION = 'enum.ActionMeasure.POPULATION_INFORMATION',
1017+
OTHER = 'enum.ActionMeasure.OTHER',
1018+
}
1019+
10071020
export enum EventCriteriaDateType {
10081021
EVENT_DATE = 'enum.EventCriteriaDateType.EVENT_DATE',
10091022
REPORT_DATE = 'enum.EventCriteriaDateType.REPORT_DATE',

src/app/_constants/form-data.ts

+6
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ export const FORM_DATA_TEXTAREA = {
7777
className: 'size-full',
7878
};
7979

80+
export const FORM_DATA_EDITTEXTAREA = {
81+
...FORM_DATA_BASE,
82+
controlType: 'edittextarea',
83+
className: 'size-full',
84+
};
85+
8086
export const FORM_DATA_NULL = {
8187
...FORM_DATA_BASE,
8288
controlType: 'null',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import {
2+
FORM_DATA_DATETIME,
3+
FORM_DATA_EDITTEXTAREA,
4+
FORM_DATA_INPUT,
5+
FORM_DATA_NULL,
6+
FORM_DATA_RADIO,
7+
FORM_DATA_SELECT,
8+
} from '../../_constants/form-data';
9+
import { ActionMeasure, ActionPriority, ActionStatus } from '../../_constants/enums';
10+
import { EnumToKeyValuePipe } from '../../_pipes/enum-to-key-value/enum-to-key-value.pipe';
11+
12+
const pipe = new EnumToKeyValuePipe();
13+
const actionPriorityOptions = pipe.transform(ActionPriority);
14+
const actionMeasureOptions = pipe.transform(ActionMeasure);
15+
const actionStatusOptions = pipe.transform(ActionStatus);
16+
17+
export const FORM_DATA_EVENT_ACTIONS_ADD_EDIT = [
18+
{
19+
id: 'event',
20+
title: 'captions.Action.event',
21+
fields: [
22+
{
23+
...FORM_DATA_NULL,
24+
key: 'disease',
25+
label: 'strings.promptDisease',
26+
},
27+
],
28+
},
29+
{
30+
id: 'action ',
31+
title: 'captions.Action',
32+
fields: [
33+
{
34+
...FORM_DATA_DATETIME,
35+
key: 'date',
36+
label: 'timeHeading',
37+
},
38+
{
39+
...FORM_DATA_SELECT,
40+
key: 'priority',
41+
label: 'captions.Action.priority',
42+
options: actionPriorityOptions,
43+
newLine: true,
44+
className: 'size-large',
45+
},
46+
{
47+
...FORM_DATA_SELECT,
48+
key: 'measure',
49+
label: 'captions.Action.actionMeasure',
50+
options: actionMeasureOptions,
51+
className: 'size-large',
52+
newLine: true,
53+
},
54+
{
55+
...FORM_DATA_INPUT,
56+
key: 'title',
57+
label: 'captions.Action.title',
58+
className: 'size-large',
59+
newLine: true,
60+
},
61+
{
62+
...FORM_DATA_RADIO,
63+
key: 'actionStatus',
64+
newLine: true,
65+
options: actionStatusOptions,
66+
},
67+
{
68+
...FORM_DATA_EDITTEXTAREA,
69+
key: 'description',
70+
newLine: true,
71+
},
72+
],
73+
},
74+
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<app-dynamic-form
2+
[formId]="formId"
3+
[formElements]="myFormElements"
4+
[resourceService]="eventService"
5+
></app-dynamic-form>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* stylelint-disable */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { HttpClientTestingModule } from '@angular/common/http/testing';
4+
import { EventActionsAddEditModalComponent } from './event-actions-add-edit-modal.component';
5+
6+
describe('EventActionsAddEditModalComponent', () => {
7+
let component: EventActionsAddEditModalComponent;
8+
let fixture: ComponentFixture<EventActionsAddEditModalComponent>;
9+
10+
beforeEach(async () => {
11+
await TestBed.configureTestingModule({
12+
declarations: [EventActionsAddEditModalComponent],
13+
imports: [HttpClientTestingModule],
14+
}).compileComponents();
15+
});
16+
17+
beforeEach(() => {
18+
fixture = TestBed.createComponent(EventActionsAddEditModalComponent);
19+
component = fixture.componentInstance;
20+
fixture.detectChanges();
21+
});
22+
23+
it('should create', () => {
24+
expect(component).toBeTruthy();
25+
});
26+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { Component, Input, OnInit } from '@angular/core';
2+
import { FormBase } from '../../shared/dynamic-form/types/form-element-base';
3+
import * as data from './event-actions-add-edit-modal-form-data';
4+
import { FormElementControlService } from '../../_services/form-element-control.service';
5+
import { ADD_EDIT_FORM_ID } from '../../app.constants';
6+
import { EventService } from '../../_services/api/event.service';
7+
import { ActionDto } from '../../_models/actionDto';
8+
9+
@Component({
10+
selector: 'app-event-actions-add-edit-modal',
11+
templateUrl: './event-actions-add-edit-modal.component.html',
12+
styleUrls: ['./event-actions-add-edit-modal.component.scss'],
13+
})
14+
export class EventActionsAddEditModalComponent implements OnInit {
15+
@Input() selectedResource: ActionDto;
16+
myFormElements: FormBase<any>[] = [];
17+
formId = ADD_EDIT_FORM_ID;
18+
19+
constructor(
20+
public eventService: EventService,
21+
private formElementControlService: FormElementControlService
22+
) {}
23+
24+
ngOnInit(): void {
25+
if (this.selectedResource) {
26+
this.myFormElements = this.formElementControlService.setValuesForDynamicForm(
27+
this.selectedResource,
28+
JSON.parse(JSON.stringify(data.FORM_DATA_EVENT_ACTIONS_ADD_EDIT))
29+
);
30+
} else {
31+
this.myFormElements = JSON.parse(JSON.stringify(data.FORM_DATA_EVENT_ACTIONS_ADD_EDIT));
32+
}
33+
}
34+
}

src/app/events/event-components/event-actions/event-actions.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</mat-select>
1818
</mat-form-field>
1919
</form>
20-
<button mat-flat-button color="primary">Create</button>
20+
<button mat-flat-button color="primary" (click)="openCreateEventActionModal()">Create</button>
2121
</div>
2222

2323
<ul *ngIf="data.length" class="event-actions-list">

src/app/events/event-components/event-actions/event-actions.component.ts

+26-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@ import { Component, OnDestroy, OnInit, QueryList, ViewChildren } from '@angular/
22
import { UntypedFormControl, UntypedFormGroup } from '@angular/forms';
33
import { ActivatedRoute } from '@angular/router';
44
import { Subscription } from 'rxjs';
5+
import { TranslateService } from '@ngx-translate/core';
6+
import { MatDialog } from '@angular/material/dialog';
57
import { CardComponent } from '../../../shared/card/card.component';
68
import { ActionDto } from '../../../_models/actionDto';
79
import { ActionService } from '../../../_services/api/action.service';
810
import { NotificationService } from '../../../_services/notification.service';
11+
import { AddEditBaseModalComponent } from '../../../shared/modals/add-edit-base-modal/add-edit-base-modal.component';
12+
import { ADD_MODAL_MAX_WIDTH } from '../../../_constants/common';
13+
import { EventActionsAddEditModalComponent } from '../../event-actions-add-edit-modal/event-actions-add-edit-modal.component';
914

1015
@Component({
1116
selector: 'app-event-actions',
@@ -28,7 +33,9 @@ export class EventActionsComponent implements OnInit, OnDestroy {
2833
constructor(
2934
private activeRoute: ActivatedRoute,
3035
private actionService: ActionService,
31-
private notificationService: NotificationService
36+
private notificationService: NotificationService,
37+
private dialog: MatDialog,
38+
private translateService: TranslateService
3239
) {}
3340

3441
ngOnInit(): void {
@@ -96,6 +103,24 @@ export class EventActionsComponent implements OnInit, OnDestroy {
96103
this.maxHeight = Math.max(...heights);
97104
}
98105

106+
openCreateEventActionModal(): void {
107+
const dialogRef = this.dialog.open(AddEditBaseModalComponent, {
108+
maxWidth: ADD_MODAL_MAX_WIDTH,
109+
data: {
110+
title: this.translateService.instant('strings.headingCreateNewAction'),
111+
component: EventActionsAddEditModalComponent,
112+
},
113+
});
114+
115+
this.subscriptions.push(
116+
dialogRef.afterClosed().subscribe((result) => {
117+
// eslint-disable-next-line no-empty
118+
if (result) {
119+
}
120+
})
121+
);
122+
}
123+
99124
ngOnDestroy(): void {
100125
this.subscriptions.forEach((subscription) => subscription.unsubscribe());
101126
}

src/app/events/event-components/event-data/event-data.component.html

+15
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,20 @@
1313
[scopeId]="'WXKKDI-W5LSJ2-YWK5SP-U7ZH2MQI'"
1414
[cardCollapse]="true"
1515
></app-edge-panel>
16+
<div class="action-cards">
17+
<h3>{{ 'strings.entityActions' | translate }}</h3>
18+
<div class="action-card pending">
19+
<p>{{ 'enum.ActionStatus.PENDING' | translate }}</p>
20+
<p class="no">2</p>
21+
</div>
22+
<div class="action-card done">
23+
<p>{{ 'enum.ActionStatus.DONE' | translate }}</p>
24+
<p class="no">3</p>
25+
</div>
26+
<div class="action-card progress">
27+
<p>{{ 'enum.ActionStatus.IN_PROGRESS' | translate }}</p>
28+
<p class="no">4</p>
29+
</div>
30+
</div>
1631
</div>
1732
</app-sidebar>
Original file line numberDiff line numberDiff line change
@@ -1 +1,52 @@
1-
/* stylelint-disable */
1+
@use '@angular/material' as mat;
2+
@use '/src/variables.scss' as *;
3+
4+
.action-cards {
5+
> h3 {
6+
font-size: 20px;
7+
font-weight: 500;
8+
color: mat.get-color-from-palette($sormas-accent, 800);
9+
}
10+
11+
.action-card {
12+
padding: 12px 24px;
13+
overflow: hidden;
14+
margin-top: 15px;
15+
border-radius: 5px;
16+
17+
p {
18+
float: left;
19+
text-transform: uppercase;
20+
font-weight: 500;
21+
margin: 0;
22+
23+
&.no {
24+
float: right;
25+
}
26+
}
27+
28+
&.pending, &.progress {
29+
border: 1px solid mat.get-color-from-palette($sormas-accent, 200);
30+
31+
&.pending {
32+
p {
33+
color: mat.get-color-from-palette($sormas-alert, 300);
34+
}
35+
}
36+
37+
&.progress {
38+
p {
39+
color: mat.get-color-from-palette($sormas-primary, 400);
40+
}
41+
}
42+
}
43+
44+
&.done {
45+
background: mat.get-color-from-palette($sormas-accent, 50);
46+
47+
p {
48+
color: mat.get-color-from-palette($sormas-success, 700);
49+
}
50+
}
51+
}
52+
}

src/app/events/event-components/event-data/event-data.component.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { EventService } from '../../../_services/api/event.service';
77
import { EventDto } from '../../../_models/eventDto';
88
import { TaskService } from '../../../_services/api/task.service';
99
import { EVENT_DETAILS_FORM_ID } from '../../../app.constants';
10+
import { ActionService } from '../../../_services/api/action.service';
1011

1112
@Component({
1213
selector: 'app-event-data',
@@ -24,7 +25,8 @@ export class EventDataComponent {
2425
constructor(
2526
private formElementControlService: FormElementControlService,
2627
public eventService: EventService,
27-
public taskService: TaskService
28+
public taskService: TaskService,
29+
public actionService: ActionService
2830
) {}
2931

3032
updateComponent(eventItem: EventDto, resourceService: BaseService<any>): void {

src/app/events/events.module.ts

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { EventGroupAddModalComponent } from './event-group-add-modal/event-group
2323
import { EventGroupLinkEventsModalComponent } from './event-group-link-events-modal/event-group-link-events-modal.component';
2424
import { EventGroupLinkEventsModalFiltersComponent } from './event-group-link-events-modal-filters/event-group-link-events-modal-filters.component';
2525
import { EventParticipantsFiltersComponent } from './event-components/event-participants-filters/event-participants-filters.component';
26+
import { EventActionsAddEditModalComponent } from './event-actions-add-edit-modal/event-actions-add-edit-modal.component';
2627

2728
@NgModule({
2829
declarations: [
@@ -45,6 +46,7 @@ import { EventParticipantsFiltersComponent } from './event-components/event-part
4546
EventGroupAddModalComponent,
4647
EventGroupLinkEventsModalComponent,
4748
EventGroupLinkEventsModalFiltersComponent,
49+
EventActionsAddEditModalComponent,
4850
],
4951
imports: [CommonModule, EventsRoutingModule, MaterialModule, SharedModule, DynamicFormModule],
5052
})

src/app/shared/dynamic-form/components/dynamic-field.directive.ts

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { FormWidgetComponent } from './form-widget/form-widget.component';
1616
import { FormDatetimeComponent } from './form-datetime/form-datetime.component';
1717
import { FormMultiselectComponent } from './form-multiselect/form-multiselect.component';
1818
import { FormSearchboxComponent } from './form-searchbox/form-searchbox.component';
19+
import { FormEdittextareaComponent } from './form-edittextarea/form-edittextarea.component';
1920

2021
const components: FormFields = {
2122
input: FormInputComponent,
@@ -27,6 +28,7 @@ const components: FormFields = {
2728
date: FormDateComponent,
2829
datetime: FormDatetimeComponent,
2930
textarea: FormTextareaComponent,
31+
edittextarea: FormEdittextareaComponent,
3032
null: FormNullComponent,
3133
number: FormNumberComponent,
3234
widget: FormWidgetComponent,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<div [formGroup]="group">
2+
<ckeditor
3+
[data]="config.value"
4+
(change)="onChange()"
5+
[formControlName]="config.key"
6+
></ckeditor>
7+
<div class="errorMessage" color="warn" *ngIf="!isValid">
8+
{{ config.validationMessage || '' | translate }}
9+
</div>
10+
</div>

src/app/shared/dynamic-form/components/form-edittextarea/form-edittextarea.component.scss

Whitespace-only changes.

0 commit comments

Comments
 (0)