@@ -94,6 +94,16 @@ export function valueIsObject(value) {
94
94
return className == 'Object' ;
95
95
}
96
96
97
+ export function toNumber ( { low, high } ) {
98
+ let res = high ;
99
+
100
+ for ( let i = 0 ; i < 32 ; i ++ ) {
101
+ res *= 2 ;
102
+ }
103
+
104
+ return low + res ;
105
+ }
106
+
97
107
export function getRecordType ( value ) {
98
108
// mui data-grid native column types are: 'string' (default),
99
109
// 'number', 'date', 'dateTime', 'boolean' and 'singleSelect'
@@ -122,6 +132,9 @@ export function getRecordType(value) {
122
132
} else if ( valueIsArray ( value ) ) {
123
133
return 'array' ;
124
134
} else if ( valueIsObject ( value ) ) {
135
+ if ( ! isNaN ( toNumber ( value ) ) ) {
136
+ return 'objectNumber' ;
137
+ }
125
138
return 'object' ;
126
139
}
127
140
@@ -167,13 +180,40 @@ export function replaceDashboardParameters(str, parameters) {
167
180
if ( ! str ) {
168
181
return '' ;
169
182
}
183
+ let rx = / ` .( [ ^ ` ] * ) ` / g;
184
+ let regexSquareBrackets = / \[ ( .* ?) \] / g;
185
+
186
+ /**
187
+ * Define function to access elements in an array/object type dashboard parameter.
188
+ * @param _ needed for str.replace(), unused.
189
+ * @param p1 - the original string.
190
+ * @returns an updated markdown with injected parameters.
191
+ */
192
+ const parameterElementReplacer = ( _ , p1 ) => {
193
+ // Find (in the markdown) occurences of the parameter `$neodash_movie_title[index]` or `$neodash_movie_title[key]`.
194
+ let matches = p1 . match ( regexSquareBrackets ) ;
195
+ let param = p1 . split ( '[' ) [ 0 ] . replace ( `$` , '' ) . trim ( ) ;
196
+ let val = parameters ?. [ param ] || null ;
197
+
198
+ // Inject the element at that index/key into the markdown as text.
199
+ matches ?. forEach ( ( m ) => {
200
+ let i = m . replace ( / [ [ \] ' ] + / g, '' ) ;
201
+ i = isNaN ( i ) ? i . replace ( / [ ' " ' ] + / g, '' ) : Number ( i ) ;
202
+ val = val ? val [ i ] : null ;
203
+ } ) ;
204
+
205
+ return RenderSubValue ( val ) ;
206
+ } ;
207
+
208
+ let newString = str . replace ( rx , parameterElementReplacer ) ;
209
+
170
210
Object . keys ( parameters ) . forEach ( ( key ) => {
171
- str = str . replaceAll ( `$${ key } ` , parameters [ key ] !== null ? parameters [ key ] : '' ) ;
211
+ newString = newString . replaceAll ( `$${ key } ` , parameters [ key ] !== null ? parameters [ key ] : '' ) ;
172
212
} ) ;
173
- return str ;
213
+
214
+ return newString ;
174
215
}
175
216
176
- // Replaces all global dashboard parameters inside a string with their values.
177
217
export function replaceDashboardParametersInString ( str , parameters ) {
178
218
Object . keys ( parameters ) . forEach ( ( key ) => {
179
219
str = str . replaceAll ( `$${ key } ` , parameters [ key ] ) ;
@@ -197,6 +237,7 @@ export const downloadComponentAsImage = (ref) => {
197
237
} ;
198
238
199
239
import { QueryResult , Record as Neo4jRecord } from 'neo4j-driver' ;
240
+ import { RenderSubValue } from '../report/ReportRecordProcessing' ;
200
241
import { DEFAULT_NODE_LABELS } from '../config/ReportConfig' ;
201
242
202
243
/**
0 commit comments