@uxland/primary-shell 6.0.3 → 6.0.5
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/dist/index.js +12 -8
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +2 -2
- package/dist/index.umd.cjs.map +1 -1
- package/dist/internal-plugins/activity-history/activity-history-item/filter/up-filters/handle-add-up-options-from-item.d.ts +9 -0
- package/dist/internal-plugins/activity-history/activity-history-item/filter/up-filters/handle-add-up-options-from-item.test.d.ts +1 -0
- package/package.json +1 -1
- package/src/features/clinical-monitoring/component/styles.css +4 -3
- package/src/internal-plugins/activity-history/activity-history-item/filter/up-filters/handle-add-up-options-from-item.test.ts +237 -0
- package/src/internal-plugins/activity-history/activity-history-item/filter/up-filters/handle-add-up-options-from-item.ts +12 -3
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { Store } from '@reduxjs/toolkit';
|
|
2
2
|
import { IActivityHistoryItem } from '../../domain/model';
|
|
3
3
|
|
|
4
|
+
export declare const getUpFilter: (items: IActivityHistoryItem[]) => {
|
|
5
|
+
id: string;
|
|
6
|
+
title: string;
|
|
7
|
+
values: {
|
|
8
|
+
label: any;
|
|
9
|
+
value: any;
|
|
10
|
+
}[];
|
|
11
|
+
enabledValues: never[];
|
|
12
|
+
} | undefined;
|
|
4
13
|
export declare const handleAddUpFilter: (items: IActivityHistoryItem[], store: Store) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
#widgets-sidebar-region {
|
|
15
15
|
width: 25%;
|
|
16
16
|
border-left: 1px solid rgb(189, 189, 189);
|
|
17
|
+
overflow: auto;
|
|
17
18
|
}
|
|
18
19
|
.content {
|
|
19
20
|
flex: 1;
|
|
@@ -23,14 +24,13 @@
|
|
|
23
24
|
display: grid;
|
|
24
25
|
grid-template-columns: repeat(3, 1fr);
|
|
25
26
|
gap: 24px;
|
|
26
|
-
padding: 24px
|
|
27
|
+
padding: 24px 24px 0 24px;
|
|
27
28
|
}
|
|
28
29
|
#content-widgets-region {
|
|
29
30
|
flex: 1;
|
|
30
31
|
min-height: 1px;
|
|
31
32
|
height: 100%;
|
|
32
|
-
padding
|
|
33
|
-
padding-bottom: 24px;
|
|
33
|
+
padding: 24px;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
border-left: none;
|
|
48
48
|
padding-inline: 40px;
|
|
49
49
|
padding-bottom: 24px;
|
|
50
|
+
overflow: auto;
|
|
50
51
|
}
|
|
51
52
|
.content {
|
|
52
53
|
#header-widgets-region {
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { getUpFilter } from "./handle-add-up-options-from-item";
|
|
3
|
+
|
|
4
|
+
// Mock de las dependencias
|
|
5
|
+
const mockMapArrayToLabelValue = vi.fn((arr, descField, idField) =>
|
|
6
|
+
arr.map(item => ({
|
|
7
|
+
label: item[descField] || item[idField], // Usa el ID como fallback si description está vacía
|
|
8
|
+
value: item[idField]
|
|
9
|
+
}))
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
vi.mock('./path/to/your/utils', () => ({
|
|
13
|
+
mapArrayToLabelValue: mockMapArrayToLabelValue,
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
const upFilterId = 'history-up'; // Define el valor que uses en tu código
|
|
17
|
+
|
|
18
|
+
describe('getUpFilter', () => {
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
vi.clearAllMocks();
|
|
21
|
+
});
|
|
22
|
+
it('debe retornar filtro cuando hay UPs válidos con ID', () => {
|
|
23
|
+
const items = [
|
|
24
|
+
{
|
|
25
|
+
id: '1',
|
|
26
|
+
up: [
|
|
27
|
+
{ id: 'up1', description: 'UP 1' },
|
|
28
|
+
{ id: 'up2', description: 'UP 2' },
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
const result = getUpFilter(items);
|
|
34
|
+
|
|
35
|
+
expect(result).toEqual({
|
|
36
|
+
id: upFilterId,
|
|
37
|
+
title: 'UP',
|
|
38
|
+
values: [
|
|
39
|
+
{ label: 'UP 1', value: 'up1' },
|
|
40
|
+
{ label: 'UP 2', value: 'up2' },
|
|
41
|
+
],
|
|
42
|
+
enabledValues: [],
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('debe permitir UPs con description vacía pero ID válido', () => {
|
|
47
|
+
const items = [
|
|
48
|
+
{
|
|
49
|
+
id: '1',
|
|
50
|
+
up: [
|
|
51
|
+
{ id: 'up1', description: '' },
|
|
52
|
+
{ id: 'up2', description: null },
|
|
53
|
+
{ id: 'up3', description: undefined },
|
|
54
|
+
{ id: 'up4', description: 'UP 4' },
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
const result = getUpFilter(items);
|
|
60
|
+
|
|
61
|
+
expect(result).toEqual({
|
|
62
|
+
id: upFilterId,
|
|
63
|
+
title: 'UP',
|
|
64
|
+
values: [
|
|
65
|
+
{ label: 'up1', value: 'up1' },
|
|
66
|
+
{ label: 'up2', value: 'up2' },
|
|
67
|
+
{ label: 'up3', value: 'up3' },
|
|
68
|
+
{ label: 'UP 4', value: 'up4' },
|
|
69
|
+
],
|
|
70
|
+
enabledValues: [],
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('no debe incluir UPs con ID vacío, null, undefined o solo espacios', () => {
|
|
75
|
+
const items = [
|
|
76
|
+
{
|
|
77
|
+
id: '1',
|
|
78
|
+
up: [
|
|
79
|
+
{ id: '', description: 'UP con ID vacío' },
|
|
80
|
+
{ id: null, description: 'UP con ID null' },
|
|
81
|
+
{ id: undefined, description: 'UP con ID undefined' },
|
|
82
|
+
{ id: ' ', description: 'UP con ID solo espacios' },
|
|
83
|
+
{ id: '\t\n ', description: 'UP con ID espacios y tabs' },
|
|
84
|
+
{ id: 'up1', description: 'UP válido' },
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
|
|
89
|
+
const result = getUpFilter(items);
|
|
90
|
+
|
|
91
|
+
expect(result).toEqual({
|
|
92
|
+
id: upFilterId,
|
|
93
|
+
title: 'UP',
|
|
94
|
+
values: [{ label: 'UP válido', value: 'up1' }],
|
|
95
|
+
enabledValues: [],
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('debe filtrar UPs duplicados por ID', () => {
|
|
100
|
+
const items = [
|
|
101
|
+
{
|
|
102
|
+
id: '1',
|
|
103
|
+
up: [
|
|
104
|
+
{ id: 'up1', description: 'UP 1 - Primera aparición' },
|
|
105
|
+
{ id: 'up2', description: 'UP 2' },
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
id: '2',
|
|
110
|
+
up: [
|
|
111
|
+
{ id: 'up1', description: 'UP 1 - Duplicado' },
|
|
112
|
+
{ id: 'up3', description: 'UP 3' },
|
|
113
|
+
],
|
|
114
|
+
},
|
|
115
|
+
];
|
|
116
|
+
|
|
117
|
+
const result = getUpFilter(items);
|
|
118
|
+
|
|
119
|
+
expect(result).toEqual({
|
|
120
|
+
id: upFilterId,
|
|
121
|
+
title: 'UP',
|
|
122
|
+
values: [
|
|
123
|
+
{ label: 'UP 1 - Primera aparición', value: 'up1' },
|
|
124
|
+
{ label: 'UP 2', value: 'up2' },
|
|
125
|
+
{ label: 'UP 3', value: 'up3' },
|
|
126
|
+
],
|
|
127
|
+
enabledValues: [],
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('debe manejar items sin propiedad up', () => {
|
|
132
|
+
const items = [
|
|
133
|
+
{ id: '1' },
|
|
134
|
+
{ id: '2', up: null },
|
|
135
|
+
{ id: '3', up: undefined },
|
|
136
|
+
{ id: '4', up: [{ id: 'up1', description: 'UP 1' }] },
|
|
137
|
+
];
|
|
138
|
+
|
|
139
|
+
const result = getUpFilter(items);
|
|
140
|
+
|
|
141
|
+
expect(result).toEqual({
|
|
142
|
+
id: upFilterId,
|
|
143
|
+
title: 'UP',
|
|
144
|
+
values: [{ label: 'UP 1', value: 'up1' }],
|
|
145
|
+
enabledValues: [],
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('debe manejar array up vacío', () => {
|
|
150
|
+
const items = [
|
|
151
|
+
{ id: '1', up: [] },
|
|
152
|
+
{ id: '2', up: [{ id: 'up1', description: 'UP 1' }] },
|
|
153
|
+
];
|
|
154
|
+
|
|
155
|
+
const result = getUpFilter(items);
|
|
156
|
+
|
|
157
|
+
expect(result).toEqual({
|
|
158
|
+
id: upFilterId,
|
|
159
|
+
title: 'UP',
|
|
160
|
+
values: [{ label: 'UP 1', value: 'up1' }],
|
|
161
|
+
enabledValues: [],
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('debe retornar undefined cuando no hay UPs válidos', () => {
|
|
166
|
+
const items = [
|
|
167
|
+
{
|
|
168
|
+
id: '1',
|
|
169
|
+
up: [
|
|
170
|
+
{ id: '', description: 'UP con ID vacío' },
|
|
171
|
+
{ id: null, description: 'UP con ID null' },
|
|
172
|
+
],
|
|
173
|
+
},
|
|
174
|
+
];
|
|
175
|
+
|
|
176
|
+
const result = getUpFilter(items);
|
|
177
|
+
|
|
178
|
+
expect(result).toBeUndefined();
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('debe retornar undefined cuando items está vacío', () => {
|
|
182
|
+
const items = [];
|
|
183
|
+
|
|
184
|
+
const result = getUpFilter(items);
|
|
185
|
+
|
|
186
|
+
expect(result).toBeUndefined();
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('debe manejar objetos up que son null o undefined en el array', () => {
|
|
190
|
+
const items = [
|
|
191
|
+
{
|
|
192
|
+
id: '1',
|
|
193
|
+
up: [
|
|
194
|
+
null,
|
|
195
|
+
undefined,
|
|
196
|
+
{ id: 'up1', description: 'UP válido' },
|
|
197
|
+
null,
|
|
198
|
+
],
|
|
199
|
+
},
|
|
200
|
+
];
|
|
201
|
+
|
|
202
|
+
const result = getUpFilter(items);
|
|
203
|
+
|
|
204
|
+
expect(result).toEqual({
|
|
205
|
+
id: upFilterId,
|
|
206
|
+
title: 'UP',
|
|
207
|
+
values: [{ label: 'UP válido', value: 'up1' }],
|
|
208
|
+
enabledValues: [],
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it('debe rechazar IDs que son solo espacios en blanco', () => {
|
|
213
|
+
const items = [
|
|
214
|
+
{
|
|
215
|
+
id: '1',
|
|
216
|
+
up: [
|
|
217
|
+
{ id: ' ', description: 'UP con ID solo espacios' },
|
|
218
|
+
{ id: '\t\n \r', description: 'UP con tabs y saltos' },
|
|
219
|
+
{ id: 'up1', description: 'UP válido' },
|
|
220
|
+
{ id: ' up2 ', description: 'UP válido con espacios al inicio/final' },
|
|
221
|
+
],
|
|
222
|
+
},
|
|
223
|
+
];
|
|
224
|
+
|
|
225
|
+
const result = getUpFilter(items);
|
|
226
|
+
|
|
227
|
+
expect(result).toEqual({
|
|
228
|
+
id: upFilterId,
|
|
229
|
+
title: 'UP',
|
|
230
|
+
values: [
|
|
231
|
+
{ label: 'UP válido', value: 'up1' },
|
|
232
|
+
{ label: 'UP válido con espacios al inicio/final', value: ' up2 ' },
|
|
233
|
+
],
|
|
234
|
+
enabledValues: [],
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
});
|
|
@@ -4,8 +4,11 @@ import { IActivityHistoryItem } from "../../domain/model";
|
|
|
4
4
|
import { upFilterId } from "../model";
|
|
5
5
|
import { addUpFilters } from "./add/actions";
|
|
6
6
|
|
|
7
|
-
export const
|
|
8
|
-
const allUps = items
|
|
7
|
+
export const getUpFilter = (items: IActivityHistoryItem[]) => {
|
|
8
|
+
const allUps = items
|
|
9
|
+
.flatMap((item) => item.up ?? [])
|
|
10
|
+
.filter((up) => up?.id?.trim()) // Filtrar UPs que tienen ID válido (no vacío ni solo espacios)
|
|
11
|
+
.filter((up, index, self) => index === self.findIndex((u) => u.id === up.id)); // Filtrar duplicados
|
|
9
12
|
|
|
10
13
|
if (allUps.length > 0) {
|
|
11
14
|
const newUpFilter = {
|
|
@@ -15,6 +18,12 @@ export const handleAddUpFilter = (items: IActivityHistoryItem[], store: Store) =
|
|
|
15
18
|
enabledValues: [],
|
|
16
19
|
};
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
return newUpFilter;
|
|
19
22
|
}
|
|
20
23
|
};
|
|
24
|
+
|
|
25
|
+
export const handleAddUpFilter = (items: IActivityHistoryItem[], store: Store) => {
|
|
26
|
+
const newUpFilter = getUpFilter(items);
|
|
27
|
+
if (newUpFilter)
|
|
28
|
+
store.dispatch(addUpFilters(newUpFilter));
|
|
29
|
+
};
|