@uxland/primary-shell 3.5.4 → 4.0.0
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 +21429 -11677
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +536 -494
- package/dist/index.umd.cjs.map +1 -1
- package/dist/primary/shell/src/UI/shared-components/index.d.ts +1 -0
- package/dist/primary/shell/src/index.d.ts +1 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/add/add-async-history-items/request.d.ts +5 -4
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/add/add-history-item/request.d.ts +1 -1
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/add/add-history-items/request.d.ts +1 -1
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/domain/specs/common-filter-spec.d.ts +9 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/domain/specs/custom-filter-spec.d.ts +10 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/domain/specs/false-spec.d.ts +6 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/domain/specs/prop-path-spec.d.ts +9 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/domain/specs/type-spec.d.ts +14 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/export-to-pdf/export-pdf-modal/export-pdf-modal.d.ts +1 -1
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/UI/activity-history-filters/activity-history-filters.d.ts +7 -2
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/common-filters/common-filters.d.ts +3 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/common-filters/selectors.d.ts +92 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/common-filters/set-common-filter/actions.d.ts +4 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/{set-common-filter → common-filters/set-common-filter}/handler.d.ts +1 -1
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/common-filters/set-common-filter/reducer.d.ts +6 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/add-custom-filters/actions.d.ts +1 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/add-custom-filters/bootstrapper.d.ts +4 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/add-custom-filters/handler.d.ts +6 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/add-custom-filters/reducer.d.ts +4 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/add-custom-filters/request.d.ts +6 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/selectors.d.ts +33 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/set-custom-filter-group/actions.d.ts +4 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/set-custom-filter-group/bootstrapper.d.ts +4 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/set-custom-filter-group/handler.d.ts +6 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/set-custom-filter-group/reducer.d.ts +6 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/set-custom-filter-group/request.d.ts +10 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/set-custom-filter-value/actions.d.ts +1 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/set-custom-filter-value/bootstrapper.d.ts +4 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/set-custom-filter-value/handler.d.ts +6 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/set-custom-filter-value/reducer.d.ts +4 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/set-custom-filter-value/request.d.ts +10 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/index.d.ts +1 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/model.d.ts +35 -5
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/selectors.d.ts +0 -154
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/slice.d.ts +20 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/index.d.ts +5 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/list/handle-error/actions.d.ts +4 -1
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/list/handle-error/reducers.d.ts +7 -2
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/selectors.d.ts +294 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/update/request.d.ts +1 -1
- package/dist/primary/shell/src/internal-plugins/activity-history/index.d.ts +1 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/infrastructure/state/store.d.ts +4 -4
- package/dist/primary/shell/src/internal-plugins/activity-history/localization.d.ts +3 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/utils/get-unique-values-by-prop-path.d.ts +4 -0
- package/dist/primary/shell/src/locales.d.ts +5 -0
- package/package.json +3 -3
- package/src/UI/components/shell-header/template.ts +4 -3
- package/src/UI/shared-components/index.ts +1 -0
- package/src/index.ts +1 -1
- package/src/internal-plugins/activity-history/activity-history-item/add/add-async-history-items/bootstrapper.ts +2 -2
- package/src/internal-plugins/activity-history/activity-history-item/add/add-async-history-items/handler.ts +5 -4
- package/src/internal-plugins/activity-history/activity-history-item/add/add-async-history-items/request.ts +5 -4
- package/src/internal-plugins/activity-history/activity-history-item/add/add-history-item/bootstrapper.ts +2 -2
- package/src/internal-plugins/activity-history/activity-history-item/add/add-history-item/request.ts +1 -1
- package/src/internal-plugins/activity-history/activity-history-item/add/add-history-items/bootstrapper.ts +2 -2
- package/src/internal-plugins/activity-history/activity-history-item/add/add-history-items/request.ts +1 -1
- package/src/internal-plugins/activity-history/activity-history-item/domain/specs/common-filter-spec.ts +18 -0
- package/src/internal-plugins/activity-history/activity-history-item/domain/specs/custom-filter-spec.ts +59 -0
- package/src/internal-plugins/activity-history/activity-history-item/domain/specs/false-spec.ts +8 -0
- package/src/internal-plugins/activity-history/activity-history-item/domain/specs/prop-path-spec.ts +19 -0
- package/src/internal-plugins/activity-history/activity-history-item/domain/specs/type-spec.ts +26 -0
- package/src/internal-plugins/activity-history/activity-history-item/export-to-pdf/export-pdf-modal/export-pdf-modal.css +3 -3
- package/src/internal-plugins/activity-history/activity-history-item/export-to-pdf/export-pdf-modal/template.ts +1 -2
- package/src/internal-plugins/activity-history/activity-history-item/filter/UI/activity-history-filters/activity-history-filters.ts +40 -5
- package/src/internal-plugins/activity-history/activity-history-item/filter/UI/activity-history-filters/styles.css +20 -4
- package/src/internal-plugins/activity-history/activity-history-item/filter/UI/activity-history-filters/template.ts +85 -13
- package/src/internal-plugins/activity-history/activity-history-item/filter/bootstrapper.ts +19 -1
- package/src/internal-plugins/activity-history/activity-history-item/filter/common-filters/common-filters.ts +26 -0
- package/src/internal-plugins/activity-history/activity-history-item/filter/common-filters/selectors.ts +14 -0
- package/src/internal-plugins/activity-history/activity-history-item/filter/{actions.ts → common-filters/set-common-filter/actions.ts} +1 -1
- package/src/internal-plugins/activity-history/activity-history-item/filter/{set-common-filter → common-filters/set-common-filter}/handler.ts +2 -2
- package/src/internal-plugins/activity-history/activity-history-item/filter/common-filters/set-common-filter/reducer.ts +18 -0
- package/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/add-custom-filters/actions.ts +3 -0
- package/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/add-custom-filters/bootstrapper.ts +14 -0
- package/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/add-custom-filters/handler.ts +14 -0
- package/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/add-custom-filters/reducer.ts +9 -0
- package/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/add-custom-filters/request.ts +5 -0
- package/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/selectors.ts +20 -0
- package/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/set-custom-filter-group/actions.ts +3 -0
- package/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/set-custom-filter-group/bootstrapper.ts +14 -0
- package/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/set-custom-filter-group/handler.ts +13 -0
- package/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/set-custom-filter-group/reducer.ts +17 -0
- package/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/set-custom-filter-group/request.ts +3 -0
- package/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/set-custom-filter-value/actions.ts +3 -0
- package/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/set-custom-filter-value/bootstrapper.ts +14 -0
- package/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/set-custom-filter-value/handler.ts +13 -0
- package/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/set-custom-filter-value/reducer.ts +41 -0
- package/src/internal-plugins/activity-history/activity-history-item/filter/custom-filters/set-custom-filter-value/request.ts +10 -0
- package/src/internal-plugins/activity-history/activity-history-item/filter/index.ts +1 -0
- package/src/internal-plugins/activity-history/activity-history-item/filter/model.ts +44 -5
- package/src/internal-plugins/activity-history/activity-history-item/filter/selectors.ts +0 -24
- package/src/internal-plugins/activity-history/activity-history-item/filter/slice.ts +11 -15
- package/src/internal-plugins/activity-history/activity-history-item/index.ts +5 -0
- package/src/internal-plugins/activity-history/activity-history-item/list/UI/main-view/activity-history-main.ts +1 -1
- package/src/internal-plugins/activity-history/activity-history-item/list/UI/main-view/template.ts +3 -3
- package/src/internal-plugins/activity-history/activity-history-item/list/UI/timeline/activity-history-timeline.ts +1 -1
- package/src/internal-plugins/activity-history/activity-history-item/list/handle-error/reducers.ts +7 -2
- package/src/internal-plugins/activity-history/activity-history-item/search/activity-history-search-bar/styles.css +1 -1
- package/src/internal-plugins/activity-history/activity-history-item/search/activity-history-search-results/styles.css +1 -1
- package/src/internal-plugins/activity-history/activity-history-item/selectors.ts +107 -0
- package/src/internal-plugins/activity-history/activity-history-item/update/bootstrapper.ts +2 -2
- package/src/internal-plugins/activity-history/activity-history-item/update/request.ts +1 -1
- package/src/internal-plugins/activity-history/index.ts +1 -0
- package/src/internal-plugins/activity-history/localization.ts +3 -0
- package/src/internal-plugins/activity-history/utils/get-unique-values-by-prop-path.ts +19 -0
- package/src/locales.ts +5 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/actions.d.ts +0 -1
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/common-filters.d.ts +0 -3
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/constants.d.ts +0 -7
- package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/list/selectors.d.ts +0 -156
- package/src/internal-plugins/activity-history/activity-history-item/filter/common-filters.ts +0 -29
- package/src/internal-plugins/activity-history/activity-history-item/filter/constants.ts +0 -8
- package/src/internal-plugins/activity-history/activity-history-item/list/selectors.ts +0 -62
- /package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/{set-common-filter → common-filters/set-common-filter}/bootstrapper.d.ts +0 -0
- /package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/filter/{set-common-filter → common-filters/set-common-filter}/request.d.ts +0 -0
- /package/src/internal-plugins/activity-history/activity-history-item/filter/{set-common-filter → common-filters/set-common-filter}/bootstrapper.ts +0 -0
- /package/src/internal-plugins/activity-history/activity-history-item/filter/{set-common-filter → common-filters/set-common-filter}/request.ts +0 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { IActivityHistoryCommonFilterGroup, IActivityHistoryCustomFilterGroup } from "../../filter";
|
|
2
|
+
import { IActivityHistoryItem } from "../model";
|
|
3
|
+
import { FalseSpec } from "./false-spec";
|
|
4
|
+
import { PropPathSpec } from "./prop-path-spec";
|
|
5
|
+
import { Spec } from "./spec";
|
|
6
|
+
|
|
7
|
+
export class CustomFilterSpec extends Spec<IActivityHistoryItem> {
|
|
8
|
+
constructor(private filters: IActivityHistoryCustomFilterGroup[]) {
|
|
9
|
+
super();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
isSatisfiedBy(item: IActivityHistoryItem): boolean {
|
|
13
|
+
const enabledGroups = this.filters.filter((group) => group.enabled);
|
|
14
|
+
|
|
15
|
+
if (enabledGroups.length === 0) {
|
|
16
|
+
return true; // No hay filtros activados, se aceptan todos los items
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return enabledGroups.every((group) => {
|
|
20
|
+
if (!this.belongsToGroup(item, group)) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const enabledFilters = group.filters.filter(
|
|
25
|
+
(filter) => filter.enabled || filter.singleOption,
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
if (enabledFilters.length === 0) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return enabledFilters.every((filter) => {
|
|
33
|
+
if (filter.singleOption) {
|
|
34
|
+
// Si el filtro booleano está DESACTIVADO, debe filtrar los elementos con ese valor
|
|
35
|
+
return !filter.enabled
|
|
36
|
+
? new PropPathSpec(filter.propPathValue, false).isSatisfiedBy(item)
|
|
37
|
+
: true; // Si está activado, no filtra nada
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (!filter.enabledValues || filter.enabledValues.length === 0) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const propSpec = filter.enabledValues.reduce((acc, value) => {
|
|
45
|
+
return acc.or(new PropPathSpec(filter.propPathValue, value));
|
|
46
|
+
}, new FalseSpec());
|
|
47
|
+
|
|
48
|
+
return propSpec.isSatisfiedBy(item);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private belongsToGroup(
|
|
54
|
+
item: IActivityHistoryItem,
|
|
55
|
+
group: IActivityHistoryCustomFilterGroup,
|
|
56
|
+
): boolean {
|
|
57
|
+
return item.type === group.id;
|
|
58
|
+
}
|
|
59
|
+
}
|
package/src/internal-plugins/activity-history/activity-history-item/domain/specs/prop-path-spec.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IActivityHistoryItem } from "../model";
|
|
2
|
+
import { Spec } from "./spec";
|
|
3
|
+
|
|
4
|
+
export class PropPathSpec extends Spec<IActivityHistoryItem> {
|
|
5
|
+
constructor(
|
|
6
|
+
public propPath: string[],
|
|
7
|
+
private value: any,
|
|
8
|
+
) {
|
|
9
|
+
super();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
isSatisfiedBy(context: IActivityHistoryItem): boolean {
|
|
13
|
+
// Reducir el context siguiendo el path hasta llegar al valor final
|
|
14
|
+
const propValue = this.propPath.reduce((acc, key) => acc?.[key], context);
|
|
15
|
+
|
|
16
|
+
// Comparar con el valor esperado
|
|
17
|
+
return propValue === this.value;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { IActivityHistoryCustomFilterGroup } from "../../filter";
|
|
2
|
+
import { IActivityHistoryItem } from "../model";
|
|
3
|
+
import { FalseSpec } from "./false-spec";
|
|
4
|
+
import { Spec } from "./spec";
|
|
5
|
+
|
|
6
|
+
export class TypeSpec extends Spec<IActivityHistoryItem> {
|
|
7
|
+
constructor(public itemType: string) {
|
|
8
|
+
super();
|
|
9
|
+
}
|
|
10
|
+
isSatisfiedBy(context: IActivityHistoryItem): boolean {
|
|
11
|
+
return context?.type === this.itemType;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class ComposedTypeSpec extends Spec<IActivityHistoryItem> {
|
|
16
|
+
constructor(public filters: IActivityHistoryCustomFilterGroup[]) {
|
|
17
|
+
super();
|
|
18
|
+
}
|
|
19
|
+
isSatisfiedBy(item: IActivityHistoryItem): boolean {
|
|
20
|
+
const enabledGroupTypes = this.filters.filter((f) => f.enabled).map((f) => f.id);
|
|
21
|
+
const finalSpec = enabledGroupTypes.reduce((acc, groupId) => {
|
|
22
|
+
return acc.or(new TypeSpec(groupId));
|
|
23
|
+
}, new FalseSpec());
|
|
24
|
+
return finalSpec.isSatisfiedBy(item);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -43,8 +43,8 @@ dss-datepicker {
|
|
|
43
43
|
width: 234px;
|
|
44
44
|
height: 48px;
|
|
45
45
|
border-radius: var(--dss-radius-sm);
|
|
46
|
-
border: var(--
|
|
47
|
-
padding: var(--
|
|
48
|
-
gap: var(--
|
|
46
|
+
border: var(--dss-border-width-sm);
|
|
47
|
+
padding: var(--dss-spacing-sm);
|
|
48
|
+
gap: var(--dss-spacing-xs);
|
|
49
49
|
color: var(--color-neutral-100);
|
|
50
50
|
}
|
|
@@ -37,8 +37,7 @@ export const template = (props: ExportPdfModal) => {
|
|
|
37
37
|
<div class="datepicker-canvas">
|
|
38
38
|
<dss-datepicker-range inputsize="md" @onRangeChange=${(e) => {
|
|
39
39
|
props.selectedPeriodDate = e.detail;
|
|
40
|
-
}} helpText
|
|
41
|
-
Sense seleccionar data de fi, s'aplicarà la de l'última entrada.">
|
|
40
|
+
}} helpText=${translate("modal.helpText")}>
|
|
42
41
|
<label slot="label-range-start" for="myDatepickerRangeStart">${translate("modal.startDate")}</label>
|
|
43
42
|
<input slot="input-range-start" id="myDatepickerRangeStart" type="text" class="dss-input">
|
|
44
43
|
<label slot="label-range-end" for="myDatepickerRangeEnd">${translate("modal.endDate")}</label>
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { LitElement, css, html, unsafeCSS } from "lit";
|
|
2
|
-
import { customElement, state } from "lit/decorators.js";
|
|
2
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
3
3
|
import { PrimariaApi } from "../../../../../../api/api";
|
|
4
|
-
import { IActivityHistoryFilter } from "../../model";
|
|
5
4
|
import { lazyInject } from "../../../../infrastructure/ioc/container";
|
|
6
5
|
import { TYPES } from "../../../../infrastructure/ioc/types";
|
|
7
6
|
import { connectedProperty } from "../../../../infrastructure/state/connected-property";
|
|
7
|
+
import { IActivityHistoryCommonFilter, IActivityHistoryCustomFilterGroup } from "../../model";
|
|
8
8
|
import styles from "./styles.css?inline";
|
|
9
9
|
import { template } from "./template";
|
|
10
|
-
import {
|
|
11
|
-
import { SetCommonFilter } from "../../set-common-filter/request";
|
|
10
|
+
import { SetCustomFilterGroup } from "../../custom-filters/set-custom-filter-group/request";
|
|
11
|
+
import { SetCommonFilter } from "../../common-filters/set-common-filter/request";
|
|
12
|
+
import { activityHistoryCommonFiltersSelector } from "../../common-filters/selectors";
|
|
13
|
+
import { SetCustomFilterValue } from "../../custom-filters/set-custom-filter-value/request";
|
|
14
|
+
import { customFilterGroupsWithOptionsSelector } from "../../../selectors";
|
|
12
15
|
|
|
13
16
|
//@ts-ignore
|
|
14
17
|
@customElement("activity-history-filters")
|
|
@@ -22,7 +25,10 @@ export class ActivityHistoryFilters extends LitElement {
|
|
|
22
25
|
`;
|
|
23
26
|
|
|
24
27
|
@connectedProperty(activityHistoryCommonFiltersSelector)
|
|
25
|
-
|
|
28
|
+
commonFilters: IActivityHistoryCommonFilter[];
|
|
29
|
+
|
|
30
|
+
@connectedProperty(customFilterGroupsWithOptionsSelector)
|
|
31
|
+
customFilterGroups: IActivityHistoryCustomFilterGroup[];
|
|
26
32
|
|
|
27
33
|
@lazyInject(TYPES.primaryApi)
|
|
28
34
|
api: PrimariaApi;
|
|
@@ -30,6 +36,15 @@ export class ActivityHistoryFilters extends LitElement {
|
|
|
30
36
|
@state()
|
|
31
37
|
filtersExpanded = false;
|
|
32
38
|
|
|
39
|
+
@property({ type: Boolean })
|
|
40
|
+
wrapperMaximized: boolean;
|
|
41
|
+
|
|
42
|
+
updated(changedProperties) {
|
|
43
|
+
if (changedProperties.has("wrapperMaximized")) {
|
|
44
|
+
this.filtersExpanded = this.wrapperMaximized;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
33
48
|
_toggleFilters() {
|
|
34
49
|
this.filtersExpanded = !this.filtersExpanded;
|
|
35
50
|
}
|
|
@@ -37,4 +52,24 @@ export class ActivityHistoryFilters extends LitElement {
|
|
|
37
52
|
_onChangeCommonFilterValue(filterId: string, value: boolean) {
|
|
38
53
|
this.api.broker.send(new SetCommonFilter({ id: filterId, enabled: value }));
|
|
39
54
|
}
|
|
55
|
+
|
|
56
|
+
_onChangeCustomFilterGroupValue(filterGroupId: string, value: boolean) {
|
|
57
|
+
this.api.broker.send(new SetCustomFilterGroup({ id: filterGroupId, enabled: value }));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
_onChangeCustomFilterValue(
|
|
61
|
+
filterGroupId: string,
|
|
62
|
+
filterId: string,
|
|
63
|
+
optionId: string,
|
|
64
|
+
value: boolean,
|
|
65
|
+
) {
|
|
66
|
+
this.api.broker.send(
|
|
67
|
+
new SetCustomFilterValue({
|
|
68
|
+
filterGroupId,
|
|
69
|
+
filterId,
|
|
70
|
+
optionId,
|
|
71
|
+
enabled: value,
|
|
72
|
+
}),
|
|
73
|
+
);
|
|
74
|
+
}
|
|
40
75
|
}
|
|
@@ -26,14 +26,30 @@
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
.filter-container{
|
|
29
|
-
|
|
29
|
+
display: flex;
|
|
30
30
|
flex-direction: column;
|
|
31
31
|
padding: 16px 8px 8px 8px;
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
overflow:auto;
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
.filter-container .filter{
|
|
37
36
|
padding: 8px 0;
|
|
38
37
|
border-bottom: 1px solid var(--color-neutral-200);
|
|
39
|
-
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.filter-group{
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-direction: column;
|
|
43
|
+
padding-top: 12px;
|
|
44
|
+
|
|
45
|
+
.custom-filter{
|
|
46
|
+
display: flex;
|
|
47
|
+
flex-direction: column;
|
|
48
|
+
padding: 6px 8px 6px var(--dss-spacing-xl);
|
|
49
|
+
|
|
50
|
+
.custom-filter-content{
|
|
51
|
+
display: flex;
|
|
52
|
+
flex-direction: column;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -1,19 +1,57 @@
|
|
|
1
1
|
import { html } from "lit";
|
|
2
2
|
import { ActivityHistoryFilters } from "./activity-history-filters";
|
|
3
3
|
import { repeat } from "lit/directives/repeat.js";
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import {
|
|
5
|
+
ActivityHistoryFilterType,
|
|
6
|
+
IActivityHistoryCommonFilter,
|
|
7
|
+
IActivityHistoryCustomFilter,
|
|
8
|
+
IActivityHistoryCustomFilterGroup,
|
|
9
|
+
IActivityHistoryFilterGroup,
|
|
10
|
+
} from "../../model";
|
|
6
11
|
import { translate } from "../../../../localization";
|
|
7
12
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const filterTemplates = {
|
|
14
|
+
[ActivityHistoryFilterType.Switch]: (id, title, handleChange, isSelected, isEnabled) => html`
|
|
15
|
+
<dss-input-switch size="sm" .checked=${isSelected} @onChangeValue=${handleChange} >
|
|
16
|
+
<input slot="input" id="switch-${id}" aria-label=${title} type="checkbox" ?disabled=${!isEnabled}>
|
|
17
|
+
<label slot="label" for="switch-${id}">${title}</label>
|
|
18
|
+
</dss-input-switch>`,
|
|
19
|
+
|
|
20
|
+
[ActivityHistoryFilterType.Checkbox]: (id, title, handleChange, isSelected, isEnabled) => html`
|
|
21
|
+
<dss-checkbox variant="default" .checked=${isSelected} @onChange=${(e) => handleChange(e)}>
|
|
22
|
+
<input slot="input" id="checkboxStory-${id}" type="checkbox" ?disabled=${!isEnabled}>
|
|
23
|
+
<label slot="label" for="checkboxStory-${id}">${title}</label>
|
|
24
|
+
</dss-checkbox>`,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const getFilterTemplate = (
|
|
28
|
+
filter: IActivityHistoryCommonFilter | IActivityHistoryCustomFilter,
|
|
29
|
+
onChangeValue: (...args: any[]) => void,
|
|
30
|
+
filterGroup?: IActivityHistoryFilterGroup,
|
|
31
|
+
option?: { id: string; title: string },
|
|
32
|
+
) => {
|
|
33
|
+
const isCustom = !!filterGroup?.id && !!option;
|
|
34
|
+
//const id = isCustom ? `${filterGroupId}-${filter.id}-${option.id}` : filter.id;
|
|
35
|
+
const id = crypto.randomUUID();
|
|
36
|
+
const title = isCustom ? option.title : filter.title;
|
|
37
|
+
|
|
38
|
+
const handleChange = (e) => {
|
|
39
|
+
if (filter.singleOption) onChangeValue(filterGroup?.id, filter.id, null, e.detail);
|
|
40
|
+
else if (isCustom && option) onChangeValue(filterGroup?.id, filter.id, option.id, e.detail);
|
|
41
|
+
else onChangeValue(filter.id, e.detail);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const isSelected =
|
|
45
|
+
isCustom && option
|
|
46
|
+
? (filter as IActivityHistoryCustomFilter).enabledValues?.includes(option.id)
|
|
47
|
+
: filter.enabled;
|
|
48
|
+
|
|
49
|
+
const isEnabled =
|
|
50
|
+
(isCustom && option) || filter.singleOption
|
|
51
|
+
? (filterGroup as IActivityHistoryCustomFilterGroup).enabled
|
|
52
|
+
: true;
|
|
53
|
+
|
|
54
|
+
return filterTemplates[filter.type]?.(id, title, handleChange, isSelected, isEnabled) || html``;
|
|
17
55
|
};
|
|
18
56
|
|
|
19
57
|
export const template = (props: ActivityHistoryFilters) =>
|
|
@@ -21,10 +59,44 @@ export const template = (props: ActivityHistoryFilters) =>
|
|
|
21
59
|
<div class="filters-sidebar" ?expanded=${props.filtersExpanded} >
|
|
22
60
|
${
|
|
23
61
|
props.filtersExpanded
|
|
24
|
-
? html`<div class="filters-sidebar-opened">${translate("filters.filters")}<dss-icon-button @click=${() => props._toggleFilters()} size="md" variant="primary" icon="keyboard_double_arrow_left"></dss-icon-button></div
|
|
25
|
-
|
|
62
|
+
? html`<div class="filters-sidebar-opened">${translate("filters.filters")}<dss-icon-button ?hidden=${props.wrapperMaximized} @click=${() => props._toggleFilters()} size="md" variant="primary" icon="keyboard_double_arrow_left"></dss-icon-button></div>
|
|
63
|
+
<div class="filter-container">
|
|
64
|
+
${repeat(props.commonFilters, (filter: IActivityHistoryCommonFilter) => html`<div class="filter">${getFilterTemplate(filter, props._onChangeCommonFilterValue.bind(props))}</div> `)}
|
|
65
|
+
${repeat(
|
|
66
|
+
props.customFilterGroups,
|
|
67
|
+
(group: IActivityHistoryCustomFilterGroup) => html`
|
|
68
|
+
<div class="filter-group">
|
|
69
|
+
<dss-input-switch size="sm" .checked=${group.enabled} @onChangeValue=${(e) => props._onChangeCustomFilterGroupValue(group.id, e.detail)}>
|
|
70
|
+
<input slot="input" id="switch-${group.id}" aria-label=${group.title} type="checkbox">
|
|
71
|
+
<label slot="label" for="switch-${group.id}">${group.title}</label>
|
|
72
|
+
</dss-input-switch>
|
|
73
|
+
${
|
|
74
|
+
group?.filters &&
|
|
75
|
+
repeat(group.filters, (filter: IActivityHistoryCustomFilter) =>
|
|
76
|
+
customFilterTemplate(filter, props, group),
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
</div> `,
|
|
80
|
+
)}
|
|
26
81
|
</div> `
|
|
27
82
|
: html`<dss-icon-button @click=${() => props._toggleFilters()} size="md" variant="primary" icon="keyboard_double_arrow_right"></dss-icon-button>`
|
|
28
83
|
}
|
|
29
84
|
</div>
|
|
30
85
|
`;
|
|
86
|
+
|
|
87
|
+
const customFilterTemplate = (
|
|
88
|
+
filter: IActivityHistoryCustomFilter,
|
|
89
|
+
props: ActivityHistoryFilters,
|
|
90
|
+
group: IActivityHistoryCustomFilterGroup,
|
|
91
|
+
) =>
|
|
92
|
+
html`
|
|
93
|
+
<div class="custom-filter">
|
|
94
|
+
${
|
|
95
|
+
filter.singleOption
|
|
96
|
+
? getFilterTemplate(filter, props._onChangeCustomFilterValue.bind(props), group)
|
|
97
|
+
: html`<div class="custom-filter-title">${filter.title}</div>
|
|
98
|
+
<div class="custom-filter-content">${repeat(filter.options, (option) => html`${getFilterTemplate(filter, props._onChangeCustomFilterValue.bind(props), group, option)}`)}</div>`
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
</div>
|
|
102
|
+
`;
|
|
@@ -3,12 +3,30 @@ import "../../activity-history-item/filter/UI/activity-history-filters/activity-
|
|
|
3
3
|
import {
|
|
4
4
|
bootstrapSetCommonFilter,
|
|
5
5
|
teardownSetCommonFilter,
|
|
6
|
-
} from "./set-common-filter/bootstrapper";
|
|
6
|
+
} from "./common-filters/set-common-filter/bootstrapper";
|
|
7
|
+
import {
|
|
8
|
+
bootstrapAddCustomFilter,
|
|
9
|
+
teardownAddCustomFilter,
|
|
10
|
+
} from "./custom-filters/add-custom-filters/bootstrapper";
|
|
11
|
+
import {
|
|
12
|
+
bootstrapSetCustomFilterGroup,
|
|
13
|
+
teardownSetCustomFilterGroup,
|
|
14
|
+
} from "./custom-filters/set-custom-filter-group/bootstrapper";
|
|
15
|
+
import {
|
|
16
|
+
bootstrapSetCustomFilterValue,
|
|
17
|
+
teardownSetCustomFilterValue,
|
|
18
|
+
} from "./custom-filters/set-custom-filter-value/bootstrapper";
|
|
7
19
|
|
|
8
20
|
export const bootstrapFilters = (broker: BrokerExtensions) => {
|
|
9
21
|
bootstrapSetCommonFilter(broker);
|
|
22
|
+
bootstrapAddCustomFilter(broker);
|
|
23
|
+
bootstrapSetCustomFilterGroup(broker);
|
|
24
|
+
bootstrapSetCustomFilterValue(broker);
|
|
10
25
|
};
|
|
11
26
|
|
|
12
27
|
export const teardownFilters = () => {
|
|
13
28
|
teardownSetCommonFilter();
|
|
29
|
+
teardownAddCustomFilter();
|
|
30
|
+
teardownSetCustomFilterGroup();
|
|
31
|
+
teardownSetCustomFilterValue();
|
|
14
32
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { OwnSpec } from "../../domain/specs/own-spec";
|
|
2
|
+
import { RelevantSpec } from "../../domain/specs/relevant-spec";
|
|
3
|
+
import { IActivityHistoryCommonFilterGroup, ActivityHistoryFilterType } from "../model";
|
|
4
|
+
|
|
5
|
+
export const commonFilters: IActivityHistoryCommonFilterGroup[] = [
|
|
6
|
+
{
|
|
7
|
+
id: "common",
|
|
8
|
+
title: "Comuns",
|
|
9
|
+
filters: [
|
|
10
|
+
{
|
|
11
|
+
id: "relevant",
|
|
12
|
+
title: "Veure rellevants",
|
|
13
|
+
spec: RelevantSpec,
|
|
14
|
+
enabled: false,
|
|
15
|
+
type: ActivityHistoryFilterType.Switch,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: "own",
|
|
19
|
+
title: "Veure meus",
|
|
20
|
+
spec: OwnSpec,
|
|
21
|
+
enabled: false,
|
|
22
|
+
type: ActivityHistoryFilterType.Switch,
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createSelector } from "@reduxjs/toolkit";
|
|
2
|
+
import { isCommonFilterGroup } from "../model";
|
|
3
|
+
import { activityHistoryFiltersSelector } from "../selectors";
|
|
4
|
+
|
|
5
|
+
export const activityHistoryCommonFiltersSelector = createSelector(
|
|
6
|
+
activityHistoryFiltersSelector,
|
|
7
|
+
(filters) => filters.find(isCommonFilterGroup)?.filters || [],
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
export const isEnabledCommonFilterSelector = (filterId: string) =>
|
|
11
|
+
createSelector(
|
|
12
|
+
activityHistoryCommonFiltersSelector,
|
|
13
|
+
(filterSpecs) => filterSpecs?.find((s) => s.id === filterId)?.enabled,
|
|
14
|
+
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { StoreBaseHandler } from "
|
|
2
|
-
import { setCommonFilterValue } from "
|
|
1
|
+
import { StoreBaseHandler } from "../../../../infrastructure/base-handlers";
|
|
2
|
+
import { setCommonFilterValue } from "./actions";
|
|
3
3
|
import { SetCommonFilter } from "./request";
|
|
4
4
|
|
|
5
5
|
export class SetCommonFilterHandler extends StoreBaseHandler {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PayloadAction } from "@reduxjs/toolkit";
|
|
2
|
+
|
|
3
|
+
export function setCommonFilterValueReducer(
|
|
4
|
+
state,
|
|
5
|
+
action: PayloadAction<{ id: string; enabled: boolean }>,
|
|
6
|
+
) {
|
|
7
|
+
state.filters = state.filters.map((f) => {
|
|
8
|
+
if (f.id === "common") {
|
|
9
|
+
return {
|
|
10
|
+
...f,
|
|
11
|
+
filters: f.filters.map((ff) =>
|
|
12
|
+
ff.id === action.payload.id ? { ...ff, enabled: action.payload.enabled } : ff,
|
|
13
|
+
),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
return f;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BrokerExtensions } from "@primaria/plugins-core";
|
|
2
|
+
import { BrokerDisposableHandler } from "../../../../../../api/broker/primaria-broker";
|
|
3
|
+
import { AddCustomFiltersHandler } from "./handler";
|
|
4
|
+
import { AddCustomFiltersCommand } from "./request";
|
|
5
|
+
|
|
6
|
+
let request: BrokerDisposableHandler;
|
|
7
|
+
|
|
8
|
+
export const bootstrapAddCustomFilter = (broker: BrokerExtensions) => {
|
|
9
|
+
request = broker.registerRequest(AddCustomFiltersCommand, AddCustomFiltersHandler);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const teardownAddCustomFilter = () => {
|
|
13
|
+
request?.dispose();
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { StoreBaseHandler } from "../../../../infrastructure/base-handlers";
|
|
2
|
+
import { addCustomFilters } from "./actions";
|
|
3
|
+
import { AddCustomFiltersCommand } from "./request";
|
|
4
|
+
|
|
5
|
+
export class AddCustomFiltersHandler extends StoreBaseHandler {
|
|
6
|
+
async handle(request: AddCustomFiltersCommand) {
|
|
7
|
+
try {
|
|
8
|
+
//TODO ensure are valid filters
|
|
9
|
+
this.store.dispatch(addCustomFilters(request.payload));
|
|
10
|
+
} catch (e) {
|
|
11
|
+
console.log(e.message);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PayloadAction } from "@reduxjs/toolkit";
|
|
2
|
+
import { IActivityHistoryCommonFilterGroup } from "../model";
|
|
3
|
+
|
|
4
|
+
export function addCustomFiltersReducer(
|
|
5
|
+
state,
|
|
6
|
+
action: PayloadAction<IActivityHistoryCommonFilterGroup>,
|
|
7
|
+
) {
|
|
8
|
+
state.filters = [...state.filters, action.payload];
|
|
9
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createSelector } from "@reduxjs/toolkit";
|
|
2
|
+
import {
|
|
3
|
+
IActivityHistoryCustomFilterGroup,
|
|
4
|
+
IActivityHistoryFilterGroup,
|
|
5
|
+
isNotCommonFilterGroup,
|
|
6
|
+
} from "../model";
|
|
7
|
+
import { activityHistoryFiltersSelector } from "../selectors";
|
|
8
|
+
|
|
9
|
+
export const activityHistoryCustomFilterGroupsSelector = createSelector(
|
|
10
|
+
activityHistoryFiltersSelector,
|
|
11
|
+
(filters: IActivityHistoryFilterGroup[]) => {
|
|
12
|
+
const customFilters = filters.filter(isNotCommonFilterGroup);
|
|
13
|
+
return customFilters.sort(sortBySortProperty);
|
|
14
|
+
},
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
const sortBySortProperty = (
|
|
18
|
+
a: IActivityHistoryCustomFilterGroup,
|
|
19
|
+
b: IActivityHistoryCustomFilterGroup,
|
|
20
|
+
) => Number(a.sort) - Number(b.sort);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BrokerExtensions } from "@primaria/plugins-core";
|
|
2
|
+
import { BrokerDisposableHandler } from "../../../../../../api/broker/primaria-broker";
|
|
3
|
+
import { SetCustomFilterGroup } from "./request";
|
|
4
|
+
import { SetCustomFilterGroupHandler } from "./handler";
|
|
5
|
+
|
|
6
|
+
let request: BrokerDisposableHandler;
|
|
7
|
+
|
|
8
|
+
export const bootstrapSetCustomFilterGroup = (broker: BrokerExtensions) => {
|
|
9
|
+
request = broker.registerRequest(SetCustomFilterGroup, SetCustomFilterGroupHandler);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const teardownSetCustomFilterGroup = () => {
|
|
13
|
+
request?.dispose();
|
|
14
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { StoreBaseHandler } from "../../../../infrastructure/base-handlers";
|
|
2
|
+
import { setCustomFilterGroupValue } from "./actions";
|
|
3
|
+
import { SetCustomFilterGroup } from "./request";
|
|
4
|
+
|
|
5
|
+
export class SetCustomFilterGroupHandler extends StoreBaseHandler {
|
|
6
|
+
async handle(request: SetCustomFilterGroup) {
|
|
7
|
+
try {
|
|
8
|
+
this.store.dispatch(setCustomFilterGroupValue(request.payload));
|
|
9
|
+
} catch (e) {
|
|
10
|
+
console.log(e.message);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PayloadAction } from "@reduxjs/toolkit";
|
|
2
|
+
|
|
3
|
+
export function setCustomFilterGroupValueReducer(
|
|
4
|
+
state,
|
|
5
|
+
action: PayloadAction<{ id: string; enabled: boolean }>,
|
|
6
|
+
) {
|
|
7
|
+
//seteamos el valor de enabled en el filterGroup, y ademas vamos a todos los hijos y deshabilitamos todas sus opciones si estamos deshabilitando el grupo.
|
|
8
|
+
state.filters = state.filters.map((f) => {
|
|
9
|
+
if (f.id === action.payload.id) {
|
|
10
|
+
return {
|
|
11
|
+
...f,
|
|
12
|
+
enabled: action.payload.enabled,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
return f;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BrokerExtensions } from "@primaria/plugins-core";
|
|
2
|
+
import { BrokerDisposableHandler } from "../../../../../../api/broker/primaria-broker";
|
|
3
|
+
import { SetCustomFilterValue } from "./request";
|
|
4
|
+
import { SetCustomFilterValueHandler } from "./handler";
|
|
5
|
+
|
|
6
|
+
let request: BrokerDisposableHandler;
|
|
7
|
+
|
|
8
|
+
export const bootstrapSetCustomFilterValue = (broker: BrokerExtensions) => {
|
|
9
|
+
request = broker.registerRequest(SetCustomFilterValue, SetCustomFilterValueHandler);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const teardownSetCustomFilterValue = () => {
|
|
13
|
+
request?.dispose();
|
|
14
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { StoreBaseHandler } from "../../../../infrastructure/base-handlers";
|
|
2
|
+
import { setCustomFilterValue } from "./actions";
|
|
3
|
+
import { SetCustomFilterValue } from "./request";
|
|
4
|
+
|
|
5
|
+
export class SetCustomFilterValueHandler extends StoreBaseHandler {
|
|
6
|
+
async handle(request: SetCustomFilterValue) {
|
|
7
|
+
try {
|
|
8
|
+
this.store.dispatch(setCustomFilterValue(request.payload));
|
|
9
|
+
} catch (e) {
|
|
10
|
+
console.log(e.message);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|