@devgateway/dvz-ui-react 1.7.2 → 1.7.4

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.
@@ -1,61 +1,61 @@
1
- import { getData as q, getCategory as J, getCategories as j } from "./data-api.js";
2
- import * as m from "immutable";
3
- import H from "papaparse";
4
- const y = "LOAD_DATA", T = "LOAD_DATA_DONE", D = "LOAD_DATA_ERROR", R = "LOAD_CATEGORIES", L = "LOAD_CATEGORIES_DONE", O = "LOAD_CATEGORIES_ERROR", F = "SET_PAGE_MODULE_PROPS", h = "RELOAD_CHILD_FILTER_ITEMS", N = "SET_FILTER", V = "SET_FILTERS", C = "SET_INITIAL_FILTER", P = "SET_APPLY", w = "CLEAN_FILTER", M = "UNSET_FILTER", Y = m.Map({ mode: "info" }), v = "SET_MEASURES", U = "CLEAN_MEASURES", K = ({ app: r, group: a }) => (s, e) => {
5
- s({ type: U, app: r, group: a });
6
- }, Q = ({ app: r, group: a, mGroup: s }) => (e, t) => {
7
- const o = Object.keys(s.measures).filter((l) => s.measures[l].selected), n = { ...s };
8
- n[r] = { measures: {} }, o.forEach((l) => {
9
- n[r].measures[l] = { ...s.measures[l] };
10
- }), n[r].format = s.format, e({ type: v, app: r, group: a, measure: n });
11
- }, W = ({ app: r, type: a, group: s, param: e, autoApply: t, params: o, parentParam: n, parentType: l, parentSelectedItems: i, uniqueStorage: g, dvzProxyDatasetId: p }) => (c, I) => {
1
+ import { getData as J, getCategory as j, getCategories as H } from "./data-api.js";
2
+ import * as A from "immutable";
3
+ import V from "papaparse";
4
+ const y = "LOAD_DATA", m = "LOAD_DATA_DONE", O = "LOAD_DATA_ERROR", R = "LOAD_CATEGORIES", L = "LOAD_CATEGORIES_DONE", D = "LOAD_CATEGORIES_ERROR", F = "SET_PAGE_MODULE_PROPS", h = "RELOAD_CHILD_FILTER_ITEMS", N = "SET_FILTER", Y = "SET_FILTERS", P = "SET_INITIAL_FILTER", C = "SET_APPLY", w = "CLEAN_FILTER", M = "UNSET_FILTER", $ = A.Map({ mode: "info" }), v = "SET_MEASURES", U = "CLEAN_MEASURES", B = "SET_POSTS_PAGINATION", K = "SET_POSTS_FILTER", b = "SET_INITIAL_POSTS_FILTER", X = ({ app: r, group: n }) => (s, e) => {
5
+ s({ type: U, app: r, group: n });
6
+ }, Z = ({ app: r, group: n, mGroup: s }) => (e, t) => {
7
+ const o = Object.keys(s.measures).filter((l) => s.measures[l].selected), a = { ...s };
8
+ a[r] = { measures: {} }, o.forEach((l) => {
9
+ a[r].measures[l] = { ...s.measures[l] };
10
+ }), a[r].format = s.format, e({ type: v, app: r, group: n, measure: a });
11
+ }, k = ({ app: r, type: n, group: s, param: e, autoApply: t, params: o, parentParam: a, parentType: l, parentSelectedItems: p, uniqueStorage: g, dvzProxyDatasetId: i }) => (c, I) => {
12
12
  const E = { ...o };
13
- E[n] = i, J({ app: r, params: E, type: a }).then(
13
+ E[a] = p, j({ app: r, params: E, type: n }).then(
14
14
  (f) => {
15
15
  c({
16
16
  type: h,
17
- filterType: a,
17
+ filterType: n,
18
18
  parentType: l,
19
19
  param: e,
20
20
  app: r,
21
21
  group: s,
22
22
  data: f,
23
23
  uniqueStorage: g,
24
- dvzProxyDatasetId: p,
24
+ dvzProxyDatasetId: i,
25
25
  autoApply: t
26
26
  });
27
27
  }
28
28
  );
29
- }, X = (r) => (a, s) => {
30
- const { app: e, group: t, param: o, value: n, autoApply: l, parent: i } = r;
31
- console.log("set filters"), a({ type: N, app: e, group: t, param: o, value: n, autoApply: l, parent: i });
32
- }, Z = ({ app: r, group: a }) => (s, e) => {
33
- s({ type: w, app: r, group: a });
34
- }, k = ({ app: r, group: a, param: s, parent: e }) => (t, o) => {
35
- t({ type: M, app: r, group: a, param: s, parent: e });
36
- }, ee = ({ app: r, group: a }) => (s, e) => {
37
- s({ type: P, app: r, group: a });
38
- }, te = ({ app: r, group: a, param: s, value: e }) => (t, o) => {
39
- t({ type: C, app: r, group: a, param: s, value: e });
40
- }, se = (r) => (a, s) => {
41
- const { app: e, params: t, dvzProxyDatasetId: o, uniqueStorage: n } = r;
42
- a({ type: R, params: t, app: e, uniqueStorage: n, dvzProxyDatasetId: o }), j({ app: e, params: t }).then((l) => (l.appliedFilters = t, a({
29
+ }, ee = (r) => (n, s) => {
30
+ const { app: e, group: t, param: o, value: a, autoApply: l, parent: p } = r;
31
+ console.log("set filters"), n({ type: N, app: e, group: t, param: o, value: a, autoApply: l, parent: p });
32
+ }, te = ({ app: r, group: n }) => (s, e) => {
33
+ s({ type: w, app: r, group: n });
34
+ }, se = ({ app: r, group: n, param: s, parent: e }) => (t, o) => {
35
+ t({ type: M, app: r, group: n, param: s, parent: e });
36
+ }, re = ({ app: r, group: n }) => (s, e) => {
37
+ s({ type: C, app: r, group: n });
38
+ }, ne = ({ app: r, group: n, param: s, value: e }) => (t, o) => {
39
+ t({ type: P, app: r, group: n, param: s, value: e });
40
+ }, ae = (r) => (n, s) => {
41
+ const { app: e, params: t, dvzProxyDatasetId: o, uniqueStorage: a } = r;
42
+ n({ type: R, params: t, app: e, uniqueStorage: a, dvzProxyDatasetId: o }), H({ app: e, params: t }).then((l) => (l.appliedFilters = t, n({
43
43
  type: L,
44
44
  app: e,
45
45
  data: l,
46
- uniqueStorage: n,
46
+ uniqueStorage: a,
47
47
  dvzProxyDatasetId: o
48
- }))).catch((l) => a({
49
- type: O,
48
+ }))).catch((l) => n({
49
+ type: D,
50
50
  app: e,
51
- uniqueStorage: n,
51
+ uniqueStorage: a,
52
52
  error: l,
53
53
  dvzProxyDatasetId: o
54
54
  }));
55
- }, re = ({ app: r, group: a, csv: s, store: e, params: t }) => (o, n) => {
56
- const l = n().get("data").getIn(["filters", r, a]);
55
+ }, oe = ({ app: r, group: n, csv: s, store: e, params: t }) => (o, a) => {
56
+ const l = a().get("data").getIn(["filters", r, n]);
57
57
  l ? t = { ...t, ...l.toJS() } : t = t || {};
58
- const i = H.parse(s, { header: !0, dynamicTyping: !0 }), g = i.data.filter((c) => {
58
+ const p = V.parse(s, { header: !0, dynamicTyping: !0 }), g = p.data.filter((c) => {
59
59
  let I = !1;
60
60
  return Object.keys(t).forEach((E) => {
61
61
  const f = t[E];
@@ -64,95 +64,107 @@ const y = "LOAD_DATA", T = "LOAD_DATA_DONE", D = "LOAD_DATA_ERROR", R = "LOAD_CA
64
64
  I = f.filter((_) => _ && _.toString().trim().toLowerCase() == S).length == 0;
65
65
  }
66
66
  }), !I;
67
- }), p = { ...i, data: g, appliedFilters: t };
68
- o({ type: T, app: r, group: a, store: e, data: { count: p.data.length, itemsSize: p.data.length, ...p } });
69
- }, ne = (r) => (a, s) => {
70
- const { app: e, group: t, source: o, store: n, params: l, parent: i } = r;
67
+ }), i = { ...p, data: g, appliedFilters: t };
68
+ o({ type: m, app: r, group: n, store: e, data: { count: i.data.length, itemsSize: i.data.length, ...i } });
69
+ }, le = (r) => (n, s) => {
70
+ const { app: e, group: t, source: o, store: a, params: l, parent: p } = r;
71
71
  let g = s().get("data").getIn(["filters", e, t]);
72
- i && l && Object.keys(l).forEach((I) => {
72
+ p && l && Object.keys(l).forEach((I) => {
73
73
  if (g && g.has(I)) {
74
74
  let E = l[I], S = g.get(I).filter((_) => E.indexOf(_) > -1);
75
75
  g = g.set(I, S);
76
76
  }
77
77
  });
78
- let p = { ...l };
79
- g && (p = { ...p, ...g.toJS() }), a({ type: y, app: e, group: t, params: p, store: n }), q({ app: e, source: o, params: p }).then((c) => (c.appliedFilters = p, a({ type: T, app: e, group: t, store: n, data: c, params: p }))).catch((c) => a({ type: D, app: e, group: t, store: n, error: c }));
80
- }, ae = ({ data: r }) => (a, s) => {
81
- a({ type: F, data: r });
82
- }, oe = (r = Y, a) => {
83
- switch (a.type) {
78
+ let i = { ...l };
79
+ g && (i = { ...i, ...g.toJS() }), n({ type: y, app: e, group: t, params: i, store: a }), J({ app: e, source: o, params: i }).then((c) => (c.appliedFilters = i, n({ type: m, app: e, group: t, store: a, data: c, params: i }))).catch((c) => n({ type: O, app: e, group: t, store: a, error: c }));
80
+ }, pe = ({ data: r }) => (n, s) => {
81
+ n({ type: F, data: r });
82
+ }, ie = (r = $, n) => {
83
+ switch (n.type) {
84
84
  case y: {
85
- const { store: s, app: e, group: t, params: o } = a, n = Date.now();
86
- return r.deleteIn([...s, "error"]).setIn([...s, "loading"], !0).setIn([...s, "time"], n).setIn([...s, "presetFilter"], o);
85
+ const { store: s, app: e, group: t, params: o } = n, a = Date.now();
86
+ return r.deleteIn([...s, "error"]).setIn([...s, "loading"], !0).setIn([...s, "time"], a).setIn([...s, "presetFilter"], o);
87
87
  }
88
- case D: {
89
- const { error: s, store: e, app: t, group: o } = a;
88
+ case O: {
89
+ const { error: s, store: e, app: t, group: o } = n;
90
90
  return r.setIn([...e, "loading"], !1).setIn([...e, "error"], s).setIn(["filters-settings", t, o, "apply"], null);
91
91
  }
92
- case T: {
93
- const { data: s, app: e, group: t, store: o } = a;
92
+ case m: {
93
+ const { data: s, app: e, group: t, store: o } = n;
94
94
  return r.setIn([...o, "loading"], !1).deleteIn([...o, "error"]).setIn([...o, "data"], s).setIn(["filters-settings", e, t, "apply"], null);
95
95
  }
96
96
  case F: {
97
- const { data: s } = a;
97
+ const { data: s } = n;
98
98
  return r.setIn(["pageModuleProps"], s);
99
99
  }
100
100
  case R: {
101
- const { data: s, app: e, uniqueStorage: t, dvzProxyDatasetId: o } = a, n = ["categories", e];
102
- return t && n.push(t), o && n.push(o), r.setIn([...n, "loading"], !0).deleteIn([...n, "error"]);
101
+ const { data: s, app: e, uniqueStorage: t, dvzProxyDatasetId: o } = n, a = ["categories", e];
102
+ return t && a.push(t), o && a.push(o), r.setIn([...a, "loading"], !0).deleteIn([...a, "error"]);
103
103
  }
104
104
  case L: {
105
- const { data: s, app: e, uniqueStorage: t, dvzProxyDatasetId: o } = a, n = ["categories", e];
106
- return o && n.push(o), t && n.push(t), r.setIn([...n, "loading"], !1).setIn([...n, "items"], m.fromJS(s));
105
+ const { data: s, app: e, uniqueStorage: t, dvzProxyDatasetId: o } = n, a = ["categories", e];
106
+ return o && a.push(o), t && a.push(t), r.setIn([...a, "loading"], !1).setIn([...a, "items"], A.fromJS(s));
107
107
  }
108
- case O: {
109
- const { data: s, app: e, uniqueStorage: t, dvzProxyDatasetId: o } = a, n = ["categories", e];
110
- return t && n.push(t), o && n.push(o), r.setIn([...n, "loading"], !1).setIn([...n, "error"], s);
108
+ case D: {
109
+ const { data: s, app: e, uniqueStorage: t, dvzProxyDatasetId: o } = n, a = ["categories", e];
110
+ return t && a.push(t), o && a.push(o), r.setIn([...a, "loading"], !1).setIn([...a, "error"], s);
111
111
  }
112
- case P: {
113
- const { app: s, group: e } = a;
112
+ case C: {
113
+ const { app: s, group: e } = n;
114
114
  return r.setIn(["filters-settings", s, e, "apply"], (/* @__PURE__ */ new Date()).getTime());
115
115
  }
116
116
  case N: {
117
- const s = Date.now(), { app: e, group: t, param: o, value: n, autoApply: l, parent: i } = a;
118
- return r.setIn(["filters-settings", e, t, "autoApply"], l).setIn(["filters", e, t, o], n.length === 0 ? [Number.MIN_SAFE_INTEGER] : n).setIn(["filters-settings", e, t, "apply"], null).setIn(["filters-settings", e, t, "lastUserFilterChange"], s).setIn(["filters-settings", e, t, "parent"], i || null);
117
+ const s = Date.now(), { app: e, group: t, param: o, value: a, autoApply: l, parent: p } = n;
118
+ return r.setIn(["filters-settings", e, t, "autoApply"], l).setIn(["filters", e, t, o], a.length === 0 ? [Number.MIN_SAFE_INTEGER] : a).setIn(["filters-settings", e, t, "apply"], null).setIn(["filters-settings", e, t, "lastUserFilterChange"], s).setIn(["filters-settings", e, t, "parent"], p || null);
119
119
  }
120
- case V: {
121
- const s = Date.now(), { app: e, group: t, filters: o, autoApply: n } = a;
122
- return r.setIn(["filters-settings", e, t, "autoApply"], n).setIn(["filters", e, t, param], value.length === 0 ? [Number.MIN_SAFE_INTEGER] : value).setIn(["filters-settings", e, t, "apply"], null).setIn(["filters-settings", e, t, "lastUserFilterChange"], s);
120
+ case Y: {
121
+ const s = Date.now(), { app: e, group: t, filters: o, autoApply: a } = n;
122
+ return r.setIn(["filters-settings", e, t, "autoApply"], a).setIn(["filters", e, t, param], value.length === 0 ? [Number.MIN_SAFE_INTEGER] : value).setIn(["filters-settings", e, t, "apply"], null).setIn(["filters-settings", e, t, "lastUserFilterChange"], s);
123
123
  }
124
124
  case h: {
125
- const { data: s, app: e, group: t, param: o, uniqueStorage: n, dvzProxyDatasetId: l, filterType: i, parentType: g, autoApply: p } = a, c = Date.now(), I = ["categories", e];
126
- l && I.push(l), n && I.push(n);
127
- const E = s.filter((u) => u.type == i), S = r.getIn([...I, "items"]).filter((u) => u.get("type") == i).get(0).get("items").map((u) => u.value), b = r.getIn([...I, "items"]).filter((u) => u.get("type") != i).push(m.Map(E[0])), x = r.getIn(["filters", e, t, o]), d = s[0].items.map((u) => u.value), G = x.filter((u) => d.indexOf(u) > -1), z = d.filter((u) => S.indexOf(u) == -1), A = Array.from(/* @__PURE__ */ new Set([...G, ...z]));
128
- return r.setIn([...I, "items"], b).setIn(["filters", e, t, o], Array.from(A)).setIn(["filters-settings", e, t, "autoApply"], p).setIn(["filters", e, t, o], A.length === 0 ? [Number.MIN_SAFE_INTEGER] : A).setIn(["filters-settings", e, t, "apply"], null).setIn(["filters-settings", e, t, "lastUserFilterChange"], c);
125
+ const { data: s, app: e, group: t, param: o, uniqueStorage: a, dvzProxyDatasetId: l, filterType: p, parentType: g, autoApply: i } = n, c = Date.now(), I = ["categories", e];
126
+ l && I.push(l), a && I.push(a);
127
+ const E = s.filter((u) => u.type == p), S = r.getIn([...I, "items"]).filter((u) => u.get("type") == p).get(0).get("items").map((u) => u.value), G = r.getIn([...I, "items"]).filter((u) => u.get("type") != p).push(A.Map(E[0])), x = r.getIn(["filters", e, t, o]), d = s[0].items.map((u) => u.value), z = x.filter((u) => d.indexOf(u) > -1), q = d.filter((u) => S.indexOf(u) == -1), T = Array.from(/* @__PURE__ */ new Set([...z, ...q]));
128
+ return r.setIn([...I, "items"], G).setIn(["filters", e, t, o], Array.from(T)).setIn(["filters-settings", e, t, "autoApply"], i).setIn(["filters", e, t, o], T.length === 0 ? [Number.MIN_SAFE_INTEGER] : T).setIn(["filters-settings", e, t, "apply"], null).setIn(["filters-settings", e, t, "lastUserFilterChange"], c);
129
129
  }
130
- case C: {
131
- const s = Date.now(), { app: e, group: t, param: o, value: n } = a;
132
- return r.setIn(["filters", "initial", e, t, o], n.length === 0 ? [Number.MIN_SAFE_INTEGER] : n).setIn(["filters", e, t, o], n.length === 0 ? [Number.MIN_SAFE_INTEGER] : n).setIn(["filters-settings", e, t, "lastInitialFilterChange"], s).setIn(["filters-settings", e, t, "lastUserFilterChange"], s);
130
+ case P: {
131
+ const s = Date.now(), { app: e, group: t, param: o, value: a } = n;
132
+ return r.setIn(["filters", "initial", e, t, o], a.length === 0 ? [Number.MIN_SAFE_INTEGER] : a).setIn(["filters", e, t, o], a.length === 0 ? [Number.MIN_SAFE_INTEGER] : a).setIn(["filters-settings", e, t, "lastInitialFilterChange"], s).setIn(["filters-settings", e, t, "lastUserFilterChange"], s);
133
133
  }
134
134
  case M: {
135
- const s = Date.now(), { app: e, group: t, param: o, parent: n } = a;
136
- return r.deleteIn(["filters", e, t, o]).setIn(["filters-settings", e, t, "lastUserFilterChange"], s).setIn(["filters-settings", e, t, "parent"], n || null);
135
+ const s = Date.now(), { app: e, group: t, param: o, parent: a } = n;
136
+ return r.deleteIn(["filters", e, t, o]).setIn(["filters-settings", e, t, "lastUserFilterChange"], s).setIn(["filters-settings", e, t, "parent"], a || null);
137
137
  }
138
138
  case w: {
139
- const { app: s, group: e } = a, t = r.getIn(["filters", "initial", s, e]);
139
+ const { app: s, group: e } = n, t = r.getIn(["filters", "initial", s, e]);
140
140
  return r.setIn(["filters", s, e], t);
141
141
  }
142
142
  case v: {
143
- const { app: s, group: e, measure: t } = a;
143
+ const { app: s, group: e, measure: t } = n;
144
144
  return r.setIn(["measures", s, e], t);
145
145
  }
146
146
  case U: {
147
- const { app: s, group: e, measure: t } = a;
147
+ const { app: s, group: e, measure: t } = n;
148
148
  return r.deleteIn(["measures", s, e]);
149
149
  }
150
+ case B: {
151
+ const { group: s, totalPages: e, totalItems: t } = n;
152
+ return r.setIn(["postsPagination", s], { totalPages: e, totalItems: t });
153
+ }
154
+ case K: {
155
+ const { type: s, group: e, ...t } = n;
156
+ return r.setIn(["posts", e], t);
157
+ }
158
+ case b: {
159
+ const { type: s, group: e, ...t } = n;
160
+ return r.setIn(["posts", e], t).setIn(["posts", "initialFilters", e], t);
161
+ }
150
162
  default:
151
163
  return r;
152
164
  }
153
- }, le = ({ group: r, dispatch: a, initialFilters: s }) => {
154
- a({
155
- type: SET_INITIAL_POSTS_FILTER,
165
+ }, Ie = ({ group: r, dispatch: n, initialFilters: s }) => {
166
+ n({
167
+ type: b,
156
168
  group: r,
157
169
  ...s,
158
170
  reset: !0,
@@ -160,18 +172,18 @@ const y = "LOAD_DATA", T = "LOAD_DATA_DONE", D = "LOAD_DATA_ERROR", R = "LOAD_CA
160
172
  });
161
173
  };
162
174
  export {
163
- ee as applyFilter,
164
- Z as cleanFilter,
165
- K as cleanMeasures,
166
- le as clearPostsFilter,
167
- oe as default,
168
- se as getCategories,
169
- ne as getData,
170
- W as loadFilterItems,
171
- re as setData,
172
- X as setFilter,
173
- te as setInitialFilters,
174
- Q as setMeasures,
175
- ae as setPageModuleProps,
176
- k as unsetFilter
175
+ re as applyFilter,
176
+ te as cleanFilter,
177
+ X as cleanMeasures,
178
+ Ie as clearPostsFilter,
179
+ ie as default,
180
+ ae as getCategories,
181
+ le as getData,
182
+ k as loadFilterItems,
183
+ oe as setData,
184
+ ee as setFilter,
185
+ ne as setInitialFilters,
186
+ Z as setMeasures,
187
+ pe as setPageModuleProps,
188
+ se as unsetFilter
177
189
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devgateway/dvz-ui-react",
3
- "version": "1.7.2",
3
+ "version": "1.7.4",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",