ehr-alerts-ui 0.0.14 → 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.cjs.js +3 -3
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
- package/src/library/actions/AlertActions.ts +25 -11
- package/src/library/actions/TableActions.ts +4 -4
- package/src/library/components/AlertModal/AlertModal.tsx +73 -53
- package/src/library/components/AlertsTable/AlertsTable.tsx +16 -8
- package/src/library/reducers/alertReducer.ts +2 -2
- package/src/library/reducers/tableReducer.ts +5 -1
- package/ehr-alerts-ui.iml +0 -9
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"main": "lib/index.cjs.js",
|
|
4
4
|
"module": "lib/index.js",
|
|
5
5
|
"types": "lib/components/index.d.ts",
|
|
6
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.18",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@types/node": "^12.0.0",
|
|
9
9
|
"@types/react": "^17.0.0",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"start": "react-scripts start",
|
|
65
65
|
"build": "rm -rf lib && rollup -c rollup.config.js",
|
|
66
66
|
"prepack": "npm run build",
|
|
67
|
-
"build_standalone": "rm -rf build && sed -i \"s~0.0.
|
|
67
|
+
"build_standalone": "rm -rf build && sed -i \"s~0.0.18~0.0.10~\" ./package.json && react-scripts build"
|
|
68
68
|
},
|
|
69
69
|
"eslintConfig": {
|
|
70
70
|
"extends": [
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {Action} from "redux";
|
|
2
|
-
import {Alert} from "../reducers/tableReducer";
|
|
2
|
+
import {Alert, Audience} from "../reducers/tableReducer";
|
|
3
3
|
import {ThunkAction} from "redux-thunk";
|
|
4
4
|
import {AlertsUiState} from "../reducers";
|
|
5
5
|
import Axios from "axios";
|
|
6
6
|
import {clearTable, loadAlerts, TableActions} from "./TableActions";
|
|
7
7
|
import {AlertModalError} from "../reducers/alertReducer";
|
|
8
|
+
import appendZero from "../helpers/appendZero";
|
|
8
9
|
|
|
9
10
|
export enum AlertActionsType {
|
|
10
11
|
CREATE_ALERT = 'CREATE_ALERT',
|
|
@@ -88,18 +89,24 @@ export function updateAlert(): ThunkAction<void, AlertsUiState, unknown, AlertAc
|
|
|
88
89
|
const begin = applyHour(alert.beginHour, applyMinutes(alert.beginMinute, alert.begin));
|
|
89
90
|
const end = applyHour(alert.endHour, applyMinutes(alert.endMinute, alert.end));
|
|
90
91
|
|
|
92
|
+
// Lazy convert to local time
|
|
93
|
+
const beginDate = toLocalString(begin);
|
|
94
|
+
console.log(beginDate);
|
|
95
|
+
const endDate = toLocalString(end);
|
|
96
|
+
|
|
97
|
+
|
|
91
98
|
Axios({
|
|
92
99
|
method: "put",
|
|
93
100
|
url: (window as any).APP_URL_APP + `/api/yld-teated/v1/api/message/${alert.id}`,
|
|
94
101
|
data: JSON.stringify({
|
|
95
102
|
id: 0,
|
|
96
|
-
code:
|
|
103
|
+
code: "",
|
|
97
104
|
title: alert.title,
|
|
98
105
|
body: alert.content,
|
|
99
|
-
open:
|
|
106
|
+
open: alert.audience === Audience.NOT_AUTHENTICATED,
|
|
100
107
|
level: alert.level,
|
|
101
|
-
begin:
|
|
102
|
-
end:
|
|
108
|
+
begin: beginDate,
|
|
109
|
+
end: endDate,
|
|
103
110
|
}),
|
|
104
111
|
headers: {
|
|
105
112
|
'Content-Type': 'Application/JSON',
|
|
@@ -120,21 +127,21 @@ export function postAlert(): ThunkAction<void, AlertsUiState, unknown, AlertActi
|
|
|
120
127
|
return;
|
|
121
128
|
}
|
|
122
129
|
|
|
123
|
-
const begin = applyHour(alert.beginHour, applyMinutes(alert.beginMinute, alert.begin));
|
|
124
|
-
const end = applyHour(alert.endHour, applyMinutes(alert.endMinute, alert.end));
|
|
130
|
+
const begin = toLocalString(applyHour(alert.beginHour, applyMinutes(alert.beginMinute, alert.begin)));
|
|
131
|
+
const end = toLocalString(applyHour(alert.endHour, applyMinutes(alert.endMinute, alert.end)));
|
|
125
132
|
|
|
126
133
|
Axios({
|
|
127
134
|
method: "post",
|
|
128
135
|
url: (window as any).APP_URL_APP + '/api/yld-teated/v1/api/message',
|
|
129
136
|
data: JSON.stringify({
|
|
130
137
|
id: 0,
|
|
131
|
-
code:
|
|
138
|
+
code: "",
|
|
132
139
|
title: alert.title,
|
|
133
140
|
body: alert.content,
|
|
134
|
-
open:
|
|
141
|
+
open: alert.audience === Audience.NOT_AUTHENTICATED,
|
|
135
142
|
level: alert.level,
|
|
136
|
-
begin: begin
|
|
137
|
-
end: end
|
|
143
|
+
begin: begin,
|
|
144
|
+
end: end
|
|
138
145
|
}),
|
|
139
146
|
headers: {
|
|
140
147
|
'Content-Type': 'Application/JSON',
|
|
@@ -170,4 +177,11 @@ function applyMinutes(value: number | undefined, oldDate: Date | string | undefi
|
|
|
170
177
|
newDate.setMinutes(minutes);
|
|
171
178
|
|
|
172
179
|
return newDate;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function toLocalString(date: Date): string {
|
|
183
|
+
return `${date.getUTCFullYear()}-` +
|
|
184
|
+
`${appendZero((date.getUTCMonth() + 1).toString())}-` +
|
|
185
|
+
`${appendZero((date.getDate()).toString())}` +
|
|
186
|
+
`T${date.toLocaleTimeString()}`;
|
|
173
187
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Alert,
|
|
1
|
+
import {Alert, Audience} from "../reducers/tableReducer";
|
|
2
2
|
import {ThunkAction} from "redux-thunk";
|
|
3
3
|
import Axios from 'axios';
|
|
4
4
|
import {AlertsUiState} from "../reducers";
|
|
@@ -81,15 +81,15 @@ export function loadAlerts(): ThunkAction<void, AlertsUiState, unknown, TableAct
|
|
|
81
81
|
|
|
82
82
|
// Populate table
|
|
83
83
|
for (const alert of alerts) {
|
|
84
|
-
const begin = new Date(alert.begin
|
|
85
|
-
const end = new Date(alert.end
|
|
84
|
+
const begin = new Date(alert.begin);
|
|
85
|
+
const end = new Date(alert.end);
|
|
86
86
|
|
|
87
87
|
dispatch(addAlert({
|
|
88
88
|
id: alert.id,
|
|
89
89
|
title: alert.title,
|
|
90
90
|
content: alert.body,
|
|
91
91
|
level: alert.level,
|
|
92
|
-
audience: alert.
|
|
92
|
+
audience: (alert.open) ? Audience.NOT_AUTHENTICATED : Audience.AUTHENTICATED,
|
|
93
93
|
begin: printDate(begin, true),
|
|
94
94
|
beginHour: begin.getHours(),
|
|
95
95
|
beginMinute: begin.getMinutes(),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import {Button, DatePicker, FieldWrapper, Input, Section, Select, TextArea, AlertIcon} from 'ehr-components';
|
|
3
|
-
import {Alert, MessageLevel} from "../../reducers/tableReducer";
|
|
3
|
+
import {Alert, Audience, MessageLevel} from "../../reducers/tableReducer";
|
|
4
4
|
import appendZero from "../../helpers/appendZero";
|
|
5
5
|
import {AlertModalError} from "../../reducers/alertReducer";
|
|
6
6
|
|
|
@@ -24,17 +24,22 @@ enum ContentLanguage {
|
|
|
24
24
|
RU,
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
const audiences = [
|
|
28
|
+
{code: Audience.AUTHENTICATED, texts: 'Autenditud kasutaja'},
|
|
29
|
+
{code: Audience.NOT_AUTHENTICATED, texts: 'Autentimata kasutaja'},
|
|
30
|
+
]
|
|
31
|
+
|
|
27
32
|
const messageLevels = [
|
|
28
33
|
{code: MessageLevel.TEADE, texts: 'Teade (roheline)'},
|
|
29
|
-
{code: MessageLevel.HOIATUS, texts: 'Hoiatus'},
|
|
30
|
-
{code: MessageLevel.VEATEADE, texts: 'Veateade'},
|
|
34
|
+
{code: MessageLevel.HOIATUS, texts: 'Hoiatus (kollane)'},
|
|
35
|
+
{code: MessageLevel.VEATEADE, texts: 'Veateade (punane)'},
|
|
31
36
|
]
|
|
32
37
|
|
|
33
38
|
const AlertModal: React.FC<AlertModalState & AlertModalDispatch> = ({alert, clearAlert, editAlert, postAlert,
|
|
34
39
|
updateAlert, addAlertModalError, errors,
|
|
35
40
|
clearAlertModalErrors}) => {
|
|
36
41
|
|
|
37
|
-
function onAudienceChange(code:
|
|
42
|
+
function onAudienceChange(code: Audience) {
|
|
38
43
|
if (!alert) {
|
|
39
44
|
return;
|
|
40
45
|
}
|
|
@@ -311,16 +316,16 @@ const AlertModal: React.FC<AlertModalState & AlertModalDispatch> = ({alert, clea
|
|
|
311
316
|
<div className='alerts-ui--alert-creation-modal--content'>
|
|
312
317
|
|
|
313
318
|
<FieldWrapper label='Teate publik'
|
|
314
|
-
info={{content: 'Teate
|
|
319
|
+
info={{content: 'Autentimata kasutaja on iga kasutaja, kes avab e-ehituse veebilehe. Autenditud kasutaja on kasutaja, kes logib end e-ehituse veebi sisse. Teate loomisel tuleb arvestada, kas teade on vajalik neile, kes on juba lehel sisse loginud või kõikidele, kes lehele satuvad.'}}
|
|
315
320
|
className={checkSelfError('publik')}
|
|
316
321
|
component={
|
|
317
|
-
<Select name='audience' value={alert.audience} onChange={onAudienceChange} options={
|
|
322
|
+
<Select name='audience' value={alert.audience} onChange={onAudienceChange} options={audiences} />
|
|
318
323
|
}
|
|
319
324
|
required
|
|
320
325
|
/>
|
|
321
326
|
|
|
322
327
|
<FieldWrapper label='Teate tase'
|
|
323
|
-
info={{content: '
|
|
328
|
+
info={{content: 'Teade (roheline) on neutraalse või positiivse sisuga. Näiteks info uue teenuse või muutuse kohta keskkonnas. Hoiatus (kollane) on hoiatav info millegi kohta, mis võib häirida kasutaja tööd lehel, kuid ei takista. Näiteks suhtlus mõne teise registriga võib olla häiritud. Veateade (punane) on teade selle kohta, et midagi ei tööta ja see takistab tööd lehel. Näiteks teenus on mingi aeg maas, allkirjastamine ei tööta, sisse logida ei saa.'}}
|
|
324
329
|
className={checkSelfError('tease')}
|
|
325
330
|
component={
|
|
326
331
|
<Select name='level' value={alert.level} onChange={onLevelChange} options={messageLevels} />
|
|
@@ -329,7 +334,7 @@ const AlertModal: React.FC<AlertModalState & AlertModalDispatch> = ({alert, clea
|
|
|
329
334
|
/>
|
|
330
335
|
|
|
331
336
|
<FieldWrapper label='Teate kuvamise algus'
|
|
332
|
-
info={{content: '
|
|
337
|
+
info={{content: 'Teade kuvatakse kasutajale siin märgitud kellaajast alates'}}
|
|
333
338
|
component={
|
|
334
339
|
<div className='alerts-ui--alert-creation-modal--content--date'>
|
|
335
340
|
<InternalDatePicker date={alert.begin} onChange={onDateStartChange} title='start_date'
|
|
@@ -354,7 +359,7 @@ const AlertModal: React.FC<AlertModalState & AlertModalDispatch> = ({alert, clea
|
|
|
354
359
|
/>
|
|
355
360
|
|
|
356
361
|
<FieldWrapper label='Teate kuvamise lõpp'
|
|
357
|
-
info={{content: 'Teate
|
|
362
|
+
info={{content: 'Teate kuvamine kasutajale lõpeb siin märgitud kellaajast'}}
|
|
358
363
|
component={
|
|
359
364
|
<div className='alerts-ui--alert-creation-modal--content--date'>
|
|
360
365
|
<InternalDatePicker date={alert.end} onChange={onDateEndChange} title='end_date'
|
|
@@ -379,71 +384,86 @@ const AlertModal: React.FC<AlertModalState & AlertModalDispatch> = ({alert, clea
|
|
|
379
384
|
required
|
|
380
385
|
/>
|
|
381
386
|
|
|
382
|
-
|
|
387
|
+
{/*<Section form={true} title='EE' >*/}
|
|
383
388
|
|
|
384
389
|
<FieldWrapper label='Teate pealkiri'
|
|
385
|
-
info={{content: 'Teate pealkiri label'}}
|
|
386
390
|
className={checkSelfError('title')}
|
|
387
391
|
component={
|
|
388
392
|
<Input name='Title EE' value={alert.title}
|
|
389
393
|
onChange={(c: string) => onTitleChange(ContentLanguage.EE, c)}
|
|
394
|
+
maxLength="100"
|
|
390
395
|
/>
|
|
391
396
|
}
|
|
392
397
|
required
|
|
393
398
|
/>
|
|
394
399
|
|
|
395
400
|
<FieldWrapper label='Teate sisu'
|
|
396
|
-
info={{content: 'Teate sisu label'}}
|
|
397
401
|
className={checkSelfError('content')}
|
|
398
402
|
component={
|
|
399
403
|
<TextArea name='Content EE' value={alert.content}
|
|
400
404
|
onChange={(c: string) => onContentChange(ContentLanguage.EE, c)}
|
|
405
|
+
isLimitingLength={true}
|
|
406
|
+
maxLength={500}
|
|
401
407
|
/>
|
|
402
408
|
}
|
|
403
409
|
required
|
|
404
410
|
/>
|
|
405
411
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
412
|
+
{/*</Section>*/}
|
|
413
|
+
|
|
414
|
+
{/*<Section form={true} title='EN' collapsed >*/}
|
|
415
|
+
|
|
416
|
+
{/* <FieldWrapper label='Message title'*/}
|
|
417
|
+
{/* info={{content: 'Message title label'}}*/}
|
|
418
|
+
{/* component={*/}
|
|
419
|
+
{/* <Input name='Title EN'*/}
|
|
420
|
+
{/* onChange={(c: string) => onTitleChange(ContentLanguage.EN, c)}*/}
|
|
421
|
+
{/* maxLength="100"*/}
|
|
422
|
+
{/* />*/}
|
|
423
|
+
{/* }*/}
|
|
424
|
+
{/* required*/}
|
|
425
|
+
{/* />*/}
|
|
426
|
+
|
|
427
|
+
{/* <FieldWrapper label='Message title'*/}
|
|
428
|
+
{/* info={{content: 'Message title label'}}*/}
|
|
429
|
+
{/* component={*/}
|
|
430
|
+
{/* <TextArea name='Content EN'*/}
|
|
431
|
+
{/* onChange={(c: string) => onContentChange(ContentLanguage.EN, c)}*/}
|
|
432
|
+
{/* isLimitingLength={true}*/}
|
|
433
|
+
{/* maxLength={500}*/}
|
|
434
|
+
{/* />*/}
|
|
435
|
+
{/* }*/}
|
|
436
|
+
{/* required*/}
|
|
437
|
+
{/* />*/}
|
|
438
|
+
|
|
439
|
+
{/*</Section>*/}
|
|
440
|
+
|
|
441
|
+
{/*<Section form={true} title='RU' collapsed >*/}
|
|
442
|
+
|
|
443
|
+
{/* <FieldWrapper label='Teate pealkiri'*/}
|
|
444
|
+
{/* info={{content: 'Teate pealkiri label'}}*/}
|
|
445
|
+
{/* component={*/}
|
|
446
|
+
{/* <Input name='Title RU'*/}
|
|
447
|
+
{/* onChange={(c: string) => onTitleChange(ContentLanguage.RU, c)}*/}
|
|
448
|
+
{/* maxLength="100"*/}
|
|
449
|
+
{/* />*/}
|
|
450
|
+
{/* }*/}
|
|
451
|
+
{/* required*/}
|
|
452
|
+
{/* />*/}
|
|
453
|
+
|
|
454
|
+
{/* <FieldWrapper label='Teate sisu'*/}
|
|
455
|
+
{/* info={{content: 'Teate sisu label'}}*/}
|
|
456
|
+
{/* component={*/}
|
|
457
|
+
{/* <TextArea name='Content RU'*/}
|
|
458
|
+
{/* onChange={(c: string) => onContentChange(ContentLanguage.RU, c)}*/}
|
|
459
|
+
{/* isLimitingLength={true}*/}
|
|
460
|
+
{/* maxLength={500}*/}
|
|
461
|
+
{/* />*/}
|
|
462
|
+
{/* }*/}
|
|
463
|
+
{/* required*/}
|
|
464
|
+
{/* />*/}
|
|
465
|
+
|
|
466
|
+
{/*</Section>*/}
|
|
447
467
|
</div>
|
|
448
468
|
|
|
449
469
|
<div className='alerts-ui--alert-creation-modal--footer mt-2'>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, {useEffect, useState} from "react";
|
|
2
|
-
import {Button, CollapseTable, CollapseTableRow, ControlledPopover} from 'ehr-components';
|
|
2
|
+
import {Button, CollapseTable, CollapseTableRow, ControlledPopover, Tooltip} from 'ehr-components';
|
|
3
3
|
import SortableRow from "./SortableRow";
|
|
4
4
|
import {Alert} from "../../reducers/tableReducer";
|
|
5
5
|
import {ReactComponent as CopyIcon} from "../../assets/icons/copy.svg";
|
|
@@ -150,12 +150,16 @@ const AlertsTable: React.FC<AlertsTableState & AlertsTableDispatch> = ({alerts,
|
|
|
150
150
|
alert.level,
|
|
151
151
|
`${alert.begin} - ${alert.end}`,
|
|
152
152
|
alert.content,
|
|
153
|
-
<
|
|
154
|
-
<
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
153
|
+
<Tooltip content='Kopeerin'>
|
|
154
|
+
<button className='alerts-ui--icon-button' onClick={() => duplicateAlert(alert)}>
|
|
155
|
+
<CopyIcon fill={styles.colorGreyDark} />
|
|
156
|
+
</button>
|
|
157
|
+
</Tooltip>,
|
|
158
|
+
<Tooltip content='Muudan'>
|
|
159
|
+
<button className='alerts-ui--icon-button' onClick={() => editAlert(alert)}>
|
|
160
|
+
<EditIcon fill={styles.colorGreyDark} />
|
|
161
|
+
</button>
|
|
162
|
+
</Tooltip>,
|
|
159
163
|
<ControlledPopover
|
|
160
164
|
className={'popover-confirm'}
|
|
161
165
|
content={deleteContent(alert.id)}
|
|
@@ -164,7 +168,11 @@ const AlertsTable: React.FC<AlertsTableState & AlertsTableDispatch> = ({alerts,
|
|
|
164
168
|
theme={'danger'}
|
|
165
169
|
toggle={() => onToggleDeletePopup(alert)}
|
|
166
170
|
>
|
|
167
|
-
<
|
|
171
|
+
<div>
|
|
172
|
+
<Tooltip content='Kustutan'>
|
|
173
|
+
<button className='alerts-ui--icon-button'><DeleteIcon fill={styles.colorGreyDark} /></button>
|
|
174
|
+
</Tooltip>
|
|
175
|
+
</div>
|
|
168
176
|
</ControlledPopover>,
|
|
169
177
|
];
|
|
170
178
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {AlertActions, AlertActionsType} from "../actions/AlertActions";
|
|
2
|
-
import {Alert, MessageLevel} from "./tableReducer";
|
|
2
|
+
import {Alert, Audience, MessageLevel} from "./tableReducer";
|
|
3
3
|
|
|
4
4
|
export interface AlertModalError {
|
|
5
5
|
title: string,
|
|
@@ -33,7 +33,7 @@ export function alertReducer(state = initialState, action: AlertActions): AlertS
|
|
|
33
33
|
endMinute: undefined,
|
|
34
34
|
level: MessageLevel.TEADE,
|
|
35
35
|
title: '',
|
|
36
|
-
audience:
|
|
36
|
+
audience: Audience.AUTHENTICATED,
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import {TableActions, TableActionsType} from "../actions/TableActions";
|
|
2
2
|
|
|
3
|
+
export enum Audience {
|
|
4
|
+
AUTHENTICATED = "Autenditud kasutaja",
|
|
5
|
+
NOT_AUTHENTICATED = "Autentimata kasutaja",
|
|
6
|
+
}
|
|
3
7
|
|
|
4
8
|
export enum MessageLevel {
|
|
5
9
|
"TEADE" = "TEADE",
|
|
@@ -10,7 +14,7 @@ export enum MessageLevel {
|
|
|
10
14
|
export interface Alert {
|
|
11
15
|
id: number,
|
|
12
16
|
title: string,
|
|
13
|
-
audience:
|
|
17
|
+
audience: Audience,
|
|
14
18
|
level: MessageLevel,
|
|
15
19
|
begin: string | undefined,
|
|
16
20
|
beginHour: number | undefined,
|
package/ehr-alerts-ui.iml
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="WEB_MODULE" version="4">
|
|
3
|
-
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
|
-
<exclude-output />
|
|
5
|
-
<content url="file://$MODULE_DIR$" />
|
|
6
|
-
<orderEntry type="inheritedJdk" />
|
|
7
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
8
|
-
</component>
|
|
9
|
-
</module>
|