@gisce/react-ooui 1.1.2-rc.4 → 1.1.2-rc.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.
@@ -1 +1 @@
1
- {"version":3,"file":"GraphActionView.d.ts","sourceRoot":"","sources":["GraphActionView.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAO7C,oBAAY,oBAAoB,GAAG;IACjC,QAAQ,EAAE,GAAG,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,GAAG,CAAC;IACb,MAAM,EAAE,GAAG,CAAC;IACZ,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,eAAe,UAAW,oBAAoB,uBA2H1D,CAAC"}
1
+ {"version":3,"file":"GraphActionView.d.ts","sourceRoot":"","sources":["GraphActionView.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAO7C,oBAAY,oBAAoB,GAAG;IACjC,QAAQ,EAAE,GAAG,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,GAAG,CAAC;IACb,MAAM,EAAE,GAAG,CAAC;IACZ,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,eAAe,UAAW,oBAAoB,uBA8H1D,CAAC"}
@@ -5,6 +5,7 @@ export declare type GraphProps = {
5
5
  domain: any;
6
6
  context: any;
7
7
  limit?: number;
8
+ manualIds?: number[];
8
9
  };
9
10
  export declare const Graph: React.ForwardRefExoticComponent<GraphProps & React.RefAttributes<unknown>>;
10
11
  //# sourceMappingURL=Graph.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Graph.d.ts","sourceRoot":"","sources":["Graph.tsx"],"names":[],"mappings":"AAAA,OAAO,KAMN,MAAM,OAAO,CAAC;AAiBf,oBAAY,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,GAAG,CAAC;IACZ,OAAO,EAAE,GAAG,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAgHF,eAAO,MAAM,KAAK,4EAAwB,CAAC"}
1
+ {"version":3,"file":"Graph.d.ts","sourceRoot":"","sources":["Graph.tsx"],"names":[],"mappings":"AAAA,OAAO,KAMN,MAAM,OAAO,CAAC;AAiBf,oBAAY,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,GAAG,CAAC;IACZ,OAAO,EAAE,GAAG,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAkHF,eAAO,MAAM,KAAK,4EAAwB,CAAC"}
@@ -5,6 +5,7 @@ export declare type GraphChartProps = {
5
5
  context: any;
6
6
  xml: string;
7
7
  limit?: number;
8
+ manualIds?: number[];
8
9
  };
9
10
  export declare const GraphChart: (props: GraphChartProps) => JSX.Element;
10
11
  //# sourceMappingURL=GraphChart.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GraphChart.d.ts","sourceRoot":"","sources":["GraphChart.tsx"],"names":[],"mappings":";AAaA,oBAAY,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,GAAG,CAAC;IACZ,OAAO,EAAE,GAAG,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,UAAU,UAAW,eAAe,gBAgDhD,CAAC"}
1
+ {"version":3,"file":"GraphChart.d.ts","sourceRoot":"","sources":["GraphChart.tsx"],"names":[],"mappings":";AAaA,oBAAY,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,GAAG,CAAC;IACZ,OAAO,EAAE,GAAG,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,UAAU,UAAW,eAAe,gBAiDhD,CAAC"}
@@ -11,6 +11,7 @@ export declare type GraphInidicatorProps = {
11
11
  suffix?: string;
12
12
  field?: string;
13
13
  operator?: Operator;
14
+ manualIds?: number[];
14
15
  };
15
16
  export declare const GraphIndicator: (props: GraphInidicatorProps) => JSX.Element;
16
17
  //# sourceMappingURL=GraphIndicator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GraphIndicator.d.ts","sourceRoot":"","sources":["GraphIndicator.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAQvC,oBAAY,oBAAoB,GAAG;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,GAAG,CAAC;IACZ,OAAO,EAAE,GAAG,CAAC;IACb,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,cAAc,UAAW,oBAAoB,gBAuKzD,CAAC"}
1
+ {"version":3,"file":"GraphIndicator.d.ts","sourceRoot":"","sources":["GraphIndicator.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAQvC,oBAAY,oBAAoB,GAAG;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,GAAG,CAAC;IACZ,OAAO,EAAE,GAAG,CAAC;IACb,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,cAAc,UAAW,oBAAoB,gBAoNzD,CAAC"}
@@ -4,6 +4,7 @@ export declare type GraphDataQueryOpts = {
4
4
  domain?: any;
5
5
  context?: any;
6
6
  limit?: number;
7
+ manualIds?: number[];
7
8
  };
8
9
  export declare type GraphDataOpts = GraphDataQueryOpts & {
9
10
  xml: string;
@@ -1 +1 @@
1
- {"version":3,"file":"useGraphData.d.ts","sourceRoot":"","sources":["useGraphData.tsx"],"names":[],"mappings":"AACA,OAAO,EAKL,SAAS,EACV,MAAM,aAAa,CAAC;AAOrB,oBAAY,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,oBAAY,aAAa,GAAG,kBAAkB,GAAG;IAC/C,GAAG,EAAE,MAAM,CAAC;IACZ,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,aAAa;;;;;;CA8E/C,CAAC"}
1
+ {"version":3,"file":"useGraphData.d.ts","sourceRoot":"","sources":["useGraphData.tsx"],"names":[],"mappings":"AACA,OAAO,EAKL,SAAS,EACV,MAAM,aAAa,CAAC;AAOrB,oBAAY,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF,oBAAY,aAAa,GAAG,kBAAkB,GAAG;IAC/C,GAAG,EAAE,MAAM,CAAC;IACZ,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,aAAa;;;;;;CAgF/C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gisce/react-ooui",
3
- "version": "1.1.2-rc.4",
3
+ "version": "1.1.2-rc.5",
4
4
  "files": [
5
5
  "dist",
6
6
  "src",
@@ -142,6 +142,9 @@ export const GraphActionView = (props: GraphActionViewProps) => {
142
142
  context={context}
143
143
  domain={mergeParams(searchParams || [], domain)}
144
144
  limit={applyLimit ? limit : undefined}
145
+ manualIds={
146
+ applyLimit ? resultsActionView?.map((r) => r.id) : undefined
147
+ }
145
148
  />
146
149
  )}
147
150
  </>
@@ -27,10 +27,11 @@ export type GraphProps = {
27
27
  domain: any;
28
28
  context: any;
29
29
  limit?: number;
30
+ manualIds?: number[];
30
31
  };
31
32
 
32
33
  const GraphComp = (props: GraphProps, ref: any) => {
33
- const { view_id, model, context, domain, limit } = props;
34
+ const { view_id, model, context, domain, limit, manualIds } = props;
34
35
  const [loading, setLoading] = useState(false);
35
36
  const [graphOoui, setGraphOoui] = useState<GraphOoui>();
36
37
  const [graphXml, setGraphXml] = useState<string>();
@@ -116,6 +117,7 @@ const GraphComp = (props: GraphProps, ref: any) => {
116
117
  domain={domain}
117
118
  icon={indicator.icon!}
118
119
  suffix={indicator.suffix!}
120
+ manualIds={manualIds}
119
121
  {...indicatorFieldopts}
120
122
  />
121
123
  );
@@ -130,6 +132,7 @@ const GraphComp = (props: GraphProps, ref: any) => {
130
132
  domain={domain}
131
133
  xml={graphXml!}
132
134
  limit={limit}
135
+ manualIds={manualIds}
133
136
  />
134
137
  );
135
138
  }
@@ -17,10 +17,11 @@ export type GraphChartProps = {
17
17
  context: any;
18
18
  xml: string;
19
19
  limit?: number;
20
+ manualIds?: number[];
20
21
  };
21
22
 
22
23
  export const GraphChart = (props: GraphChartProps) => {
23
- const { model, domain, context, xml, limit } = props;
24
+ const { model, domain, context, xml, limit, manualIds } = props;
24
25
  const { t } = useContext(LocaleContext) as LocaleContextType;
25
26
 
26
27
  const { error, loading, values, type, evaluatedEntries } = useGraphData({
@@ -30,6 +31,7 @@ export const GraphChart = (props: GraphChartProps) => {
30
31
  domain,
31
32
  context,
32
33
  uninformedString: t("uninformed"),
34
+ manualIds,
33
35
  });
34
36
 
35
37
  if (error) {
@@ -24,6 +24,7 @@ export type GraphInidicatorProps = {
24
24
  suffix?: string;
25
25
  field?: string;
26
26
  operator?: Operator;
27
+ manualIds?: number[];
27
28
  };
28
29
 
29
30
  export const GraphIndicator = (props: GraphInidicatorProps) => {
@@ -38,6 +39,7 @@ export const GraphIndicator = (props: GraphInidicatorProps) => {
38
39
  suffix,
39
40
  field,
40
41
  operator,
42
+ manualIds,
41
43
  } = props;
42
44
  const [loading, setLoading] = useState(false);
43
45
  const [value, setValue] = useState<number>();
@@ -53,10 +55,52 @@ export const GraphIndicator = (props: GraphInidicatorProps) => {
53
55
  fetchData();
54
56
  }, [model, colorCondition]);
55
57
 
56
- async function fetchTotalValue(queryDomain: any) {
58
+ async function fetchValue({
59
+ domain,
60
+ isTotal,
61
+ }: {
62
+ domain: any;
63
+ isTotal: boolean;
64
+ }) {
65
+ if (isTotal) {
66
+ return await fetchTotalValue({ domain });
67
+ }
68
+
69
+ if (field && operator) {
70
+ const resultIds =
71
+ manualIds ||
72
+ (await ConnectionProvider.getHandler().searchAllIds({
73
+ params: domain,
74
+ model,
75
+ context,
76
+ }));
77
+
78
+ const results = await ConnectionProvider.getHandler().readObjects({
79
+ model,
80
+ ids: resultIds,
81
+ fieldsToRetrieve: [field],
82
+ context,
83
+ });
84
+
85
+ return getValueForOperator({
86
+ values: results.map((r: any) => r[field]),
87
+ operator,
88
+ });
89
+ } else {
90
+ return manualIds
91
+ ? manualIds.length
92
+ : await ConnectionProvider.getHandler().searchCount({
93
+ model,
94
+ params: domain,
95
+ context,
96
+ });
97
+ }
98
+ }
99
+
100
+ async function fetchTotalValue({ domain }: { domain: any }) {
57
101
  if (field && operator) {
58
102
  const resultIds = await ConnectionProvider.getHandler().searchAllIds({
59
- params: queryDomain,
103
+ params: domain,
60
104
  model,
61
105
  context,
62
106
  });
@@ -75,19 +119,18 @@ export const GraphIndicator = (props: GraphInidicatorProps) => {
75
119
  } else {
76
120
  return await ConnectionProvider.getHandler().searchCount({
77
121
  model,
78
- params: queryDomain,
122
+ params: domain,
79
123
  context,
80
124
  });
81
125
  }
82
126
  }
83
-
84
127
  async function fetchData() {
85
128
  setLoading(true);
86
129
  let totalRetrievedValue;
87
130
  let percent;
88
131
 
89
132
  try {
90
- const retrievedValue = await fetchTotalValue(domain);
133
+ const retrievedValue = await fetchValue({ domain, isTotal: false });
91
134
 
92
135
  setValue(retrievedValue);
93
136
 
@@ -97,7 +140,10 @@ export const GraphIndicator = (props: GraphInidicatorProps) => {
97
140
  values: {},
98
141
  context,
99
142
  });
100
- totalRetrievedValue = await fetchTotalValue(parsedDomain);
143
+ totalRetrievedValue = await fetchValue({
144
+ domain: parsedDomain,
145
+ isTotal: true,
146
+ });
101
147
 
102
148
  setTotalValue(totalRetrievedValue);
103
149
  }
@@ -17,6 +17,7 @@ export type GraphDataQueryOpts = {
17
17
  domain?: any;
18
18
  context?: any;
19
19
  limit?: number;
20
+ manualIds?: number[];
20
21
  };
21
22
 
22
23
  export type GraphDataOpts = GraphDataQueryOpts & {
@@ -32,6 +33,7 @@ export const useGraphData = (opts: GraphDataOpts) => {
32
33
  xml,
33
34
  limit,
34
35
  uninformedString,
36
+ manualIds,
35
37
  } = opts;
36
38
  const [loading, setLoading] = useState(false);
37
39
  const [error, setError] = useState<any>();
@@ -61,6 +63,7 @@ export const useGraphData = (opts: GraphDataOpts) => {
61
63
  limit,
62
64
  order: ooui.timerange ? ooui.x.name : null,
63
65
  fields: fieldsToRetrieve,
66
+ manualIds,
64
67
  }));
65
68
  } catch (e) {
66
69
  setError("Error fetching graph data values: " + JSON.stringify(e));
@@ -128,6 +131,7 @@ async function retrieveData({
128
131
  context,
129
132
  order,
130
133
  limit,
134
+ manualIds,
131
135
  }: {
132
136
  fields: string[];
133
137
  model: string;
@@ -135,7 +139,28 @@ async function retrieveData({
135
139
  context: any;
136
140
  order: string | null;
137
141
  limit?: number;
142
+ manualIds?: number[];
138
143
  }) {
144
+ const fieldsDefinition = await getFieldsForModel({ model, context, fields });
145
+
146
+ if (manualIds) {
147
+ let values: any[] = (await ConnectionProvider.getHandler().readObjects({
148
+ model,
149
+ ids: manualIds,
150
+ fieldsToRetrieve: fields,
151
+ context,
152
+ })) as any;
153
+
154
+ if (order) {
155
+ values = [...values].sort((a, b) => a[order] - b[order]);
156
+ }
157
+
158
+ return {
159
+ values,
160
+ fields: fieldsDefinition,
161
+ };
162
+ }
163
+
139
164
  const values: any[] = (await ConnectionProvider.getHandler().search({
140
165
  model,
141
166
  params: domain,
@@ -144,7 +169,6 @@ async function retrieveData({
144
169
  limit,
145
170
  order,
146
171
  })) as any;
147
- const fieldsDefinition = await getFieldsForModel({ model, context, fields });
148
172
  return {
149
173
  values,
150
174
  fields: fieldsDefinition,