@uxland/primary-shell 5.3.1 → 5.3.3
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 +53 -41
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +18 -21
- package/dist/index.umd.cjs.map +1 -1
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/domain/business-rules.d.ts +3 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/selectors.d.ts +4 -4
- package/dist/primary/shell/src/internal-plugins/activity-history/utils/get-unique-values-by-prop-path.d.ts +1 -1
- package/package.json +1 -1
- package/src/internal-plugins/activity-history/activity-history-item/domain/business-rules.ts +5 -0
- package/src/internal-plugins/activity-history/activity-history-item/list/UI/timeline/activity-history-timeline.ts +5 -0
- package/src/internal-plugins/activity-history/activity-history-item/list/UI/timeline/template.ts +32 -17
- package/src/internal-plugins/activity-history/utils/get-unique-values-by-prop-path.test.ts +6 -6
- package/src/internal-plugins/activity-history/utils/get-unique-values-by-prop-path.ts +4 -7
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/list/UI/timeline/activity-history-timeline.d.ts +0 -17
|
@@ -48,7 +48,7 @@ export declare const customFilterGroupsWithOptionsSelector: ((state: {
|
|
|
48
48
|
filters: {
|
|
49
49
|
options: {
|
|
50
50
|
id: string;
|
|
51
|
-
|
|
51
|
+
title: string;
|
|
52
52
|
}[];
|
|
53
53
|
id: string;
|
|
54
54
|
title: string;
|
|
@@ -72,7 +72,7 @@ export declare const customFilterGroupsWithOptionsSelector: ((state: {
|
|
|
72
72
|
filters: {
|
|
73
73
|
options: {
|
|
74
74
|
id: string;
|
|
75
|
-
|
|
75
|
+
title: string;
|
|
76
76
|
}[];
|
|
77
77
|
id: string;
|
|
78
78
|
title: string;
|
|
@@ -92,7 +92,7 @@ export declare const customFilterGroupsWithOptionsSelector: ((state: {
|
|
|
92
92
|
filters: {
|
|
93
93
|
options: {
|
|
94
94
|
id: string;
|
|
95
|
-
|
|
95
|
+
title: string;
|
|
96
96
|
}[];
|
|
97
97
|
id: string;
|
|
98
98
|
title: string;
|
|
@@ -116,7 +116,7 @@ export declare const customFilterGroupsWithOptionsSelector: ((state: {
|
|
|
116
116
|
filters: {
|
|
117
117
|
options: {
|
|
118
118
|
id: string;
|
|
119
|
-
|
|
119
|
+
title: string;
|
|
120
120
|
}[];
|
|
121
121
|
id: string;
|
|
122
122
|
title: string;
|
package/package.json
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
import { activityHistoryGroupedItems } from "../../../selectors";
|
|
11
11
|
import styles from "./styles.css?inline";
|
|
12
12
|
import { template } from "./template";
|
|
13
|
+
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
13
14
|
|
|
14
15
|
//@ts-ignore
|
|
15
16
|
@customElement("activity-history-timeline")
|
|
@@ -76,6 +77,10 @@ export class ActivityHistoryTimeline extends LitElement {
|
|
|
76
77
|
return text.replace(regex, `<span class="highlight">$1</span>`);
|
|
77
78
|
}
|
|
78
79
|
|
|
80
|
+
highlighted(text?: string) {
|
|
81
|
+
return text ? unsafeHTML(this.highlightMatch(text, this.searchString)) : null;
|
|
82
|
+
}
|
|
83
|
+
|
|
79
84
|
_scrollIntoDate(selectedDate: number) {
|
|
80
85
|
let closestElement = null;
|
|
81
86
|
let closestDifference = Number.POSITIVE_INFINITY;
|
package/src/internal-plugins/activity-history/activity-history-item/list/UI/timeline/template.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { ActivityHistoryTimeline } from "./activity-history-timeline";
|
|
|
3
3
|
import { repeat } from "lit/directives/repeat.js";
|
|
4
4
|
import { IEntityDescription } from "@primaria/plugins-core";
|
|
5
5
|
import { format } from "date-fns";
|
|
6
|
-
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
7
6
|
import notFound from "../../../../../../UI/images/not-found.svg";
|
|
8
7
|
import { ifDefined } from "lit/directives/if-defined.js";
|
|
9
8
|
import {
|
|
@@ -14,6 +13,7 @@ import {
|
|
|
14
13
|
} from "../../../domain/model";
|
|
15
14
|
import { translate } from "../../../../localization";
|
|
16
15
|
import { virtualize } from "@lit-labs/virtualizer/virtualize.js";
|
|
16
|
+
import { shouldShowRole } from "../../../domain/business-rules";
|
|
17
17
|
|
|
18
18
|
export const template = (props: ActivityHistoryTimeline) => {
|
|
19
19
|
if (!props._hasUpdatedOnce) {
|
|
@@ -72,25 +72,40 @@ export const template = (props: ActivityHistoryTimeline) => {
|
|
|
72
72
|
const visitHeaderTemplate = (
|
|
73
73
|
props: ActivityHistoryTimeline,
|
|
74
74
|
item: IActivityHistoryItem | undefined,
|
|
75
|
-
) =>
|
|
76
|
-
item
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
<div class="
|
|
80
|
-
<div class="title
|
|
81
|
-
<div
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
<div>
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
${unsafeHTML(props.highlightMatch(item.professional.speciality.description, props.searchString))}
|
|
75
|
+
) => {
|
|
76
|
+
if (!item) return nothing;
|
|
77
|
+
|
|
78
|
+
return html`
|
|
79
|
+
<div class="visit__header">
|
|
80
|
+
<div class="title">
|
|
81
|
+
<div class="title-date">
|
|
82
|
+
<div>${format(new Date(item.date), "dd/MM/yyyy")}</div>
|
|
83
|
+
</div>
|
|
84
|
+
<div class="title-description">
|
|
85
|
+
<div>
|
|
86
|
+
${renderProfessionalValues(props, item)}
|
|
87
|
+
</div>
|
|
89
88
|
</div>
|
|
90
89
|
</div>
|
|
91
90
|
</div>
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
`;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const renderProfessionalValues = (props: ActivityHistoryTimeline, item: IActivityHistoryItem) => {
|
|
95
|
+
const showRole = shouldShowRole(item);
|
|
96
|
+
const professionalItems = [
|
|
97
|
+
props.highlighted(item.professional.name),
|
|
98
|
+
showRole ? props.highlighted(item.professional.role.description) : null,
|
|
99
|
+
props.highlighted(item.center.description),
|
|
100
|
+
props.highlighted(item.professional.speciality.description),
|
|
101
|
+
].filter(Boolean);
|
|
102
|
+
|
|
103
|
+
const professionalValues = professionalItems.map(
|
|
104
|
+
(item, i) => html`${item}${i < professionalItems.length - 1 ? " | " : ""}`,
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
return professionalValues;
|
|
108
|
+
};
|
|
94
109
|
|
|
95
110
|
const diagnosticHeaderTemplate = (item: IActivityHistoryItem | undefined) =>
|
|
96
111
|
item &&
|
|
@@ -12,8 +12,8 @@ describe("getUniqueObjects", () => {
|
|
|
12
12
|
const result = getUniqueObjects(items, ["data", "id"], ["data", "label"]);
|
|
13
13
|
|
|
14
14
|
expect(result).toEqual([
|
|
15
|
-
{ id: "1",
|
|
16
|
-
{ id: "2",
|
|
15
|
+
{ id: "1", title: "Item 1 (duplicate)" }, // 👈 el último
|
|
16
|
+
{ id: "2", title: "Item 2" },
|
|
17
17
|
]);
|
|
18
18
|
});
|
|
19
19
|
|
|
@@ -26,7 +26,7 @@ describe("getUniqueObjects", () => {
|
|
|
26
26
|
|
|
27
27
|
const result = getUniqueObjects(items, ["data", "id"], ["data", "label"]);
|
|
28
28
|
|
|
29
|
-
expect(result).toEqual([{ id: "1",
|
|
29
|
+
expect(result).toEqual([{ id: "1", title: "Valid" }]);
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
it("should return an empty array if input is empty", () => {
|
|
@@ -43,8 +43,8 @@ describe("getUniqueObjects", () => {
|
|
|
43
43
|
const result = getUniqueObjects(items, ["a", "b", "c", "id"], ["a", "b", "c", "name"]);
|
|
44
44
|
|
|
45
45
|
expect(result).toEqual([
|
|
46
|
-
{ id: "x1",
|
|
47
|
-
{ id: "x2",
|
|
46
|
+
{ id: "x1", title: "Deep 1" },
|
|
47
|
+
{ id: "x2", title: "Deep 2" },
|
|
48
48
|
]);
|
|
49
49
|
});
|
|
50
50
|
|
|
@@ -56,6 +56,6 @@ describe("getUniqueObjects", () => {
|
|
|
56
56
|
|
|
57
57
|
const result = getUniqueObjects(items, ["a", "b", "id"], ["a", "b", "name"]);
|
|
58
58
|
|
|
59
|
-
expect(result).toEqual([{ id: "1",
|
|
59
|
+
expect(result).toEqual([{ id: "1", title: "Good" }]);
|
|
60
60
|
});
|
|
61
61
|
});
|
|
@@ -2,18 +2,15 @@ export function getUniqueObjects<T>(
|
|
|
2
2
|
items: T[],
|
|
3
3
|
propPathId: string[],
|
|
4
4
|
propPathDescription: string[],
|
|
5
|
-
): { id: string;
|
|
5
|
+
): { id: string; title: string }[] {
|
|
6
6
|
return Array.from(
|
|
7
7
|
items
|
|
8
8
|
.map((item) => ({
|
|
9
9
|
id: propPathId.reduce((acc, key) => acc?.[key], item),
|
|
10
|
-
|
|
10
|
+
title: propPathDescription.reduce((acc, key) => acc?.[key], item),
|
|
11
11
|
}))
|
|
12
|
-
.filter((obj) => typeof obj.id === "string" && typeof obj.
|
|
13
|
-
.reduce(
|
|
14
|
-
(map, obj) => map.set(obj.id, obj),
|
|
15
|
-
new Map<string, { id: string; description: string }>(),
|
|
16
|
-
)
|
|
12
|
+
.filter((obj) => typeof obj.id === "string" && typeof obj.title === "string")
|
|
13
|
+
.reduce((map, obj) => map.set(obj.id, obj), new Map<string, { id: string; title: string }>())
|
|
17
14
|
.values(),
|
|
18
15
|
);
|
|
19
16
|
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
|
-
import { IActivityHistoryGroup } from '../../../domain/model';
|
|
3
|
-
|
|
4
|
-
export declare class ActivityHistoryTimeline extends LitElement {
|
|
5
|
-
render(): import('lit').TemplateResult<1>;
|
|
6
|
-
static styles: import('lit').CSSResult;
|
|
7
|
-
historyGroups: IActivityHistoryGroup[];
|
|
8
|
-
isAnyCollectionLoadingWithoutAnyLoaded: boolean;
|
|
9
|
-
isSomeCollectionLoadedAndOtherLoading: boolean;
|
|
10
|
-
searchString: string;
|
|
11
|
-
_hasUpdatedOnce: boolean;
|
|
12
|
-
firstUpdated(): void;
|
|
13
|
-
updated(changedProperties: any): Promise<void>;
|
|
14
|
-
prepareComponents(historyGroups: any): Promise<void>;
|
|
15
|
-
highlightMatch(text: string, searchString: string): string;
|
|
16
|
-
_scrollIntoDate(selectedDate: number): void;
|
|
17
|
-
}
|