|
183 | 183 | exportToExcel = !!parseInt(container.getAttribute("export-csv"));
|
184 | 184 |
|
185 | 185 | // !ultra-bydlocode (get the widget object)
|
186 |
| - while (widget["parent"]) { |
| 186 | + // ++ VP |
| 187 | + // Following "parent" until we find widget object |
| 188 | + while (!widget["widgetKey"]) { |
187 | 189 | widget = widget["parent"];
|
188 | 190 | }
|
| 191 | + // -- VP |
| 192 | +
|
189 | 193 | // !ultra-bydlocode (possible you will have better suggestions to get widget key)
|
190 | 194 | widgetKey = parseInt(_.parent.parent.onwindowgrab.match(/[0-9]+/)[0]);
|
191 | 195 |
|
|
233 | 237 | (source = location.origin + "/" + container.getAttribute("data-source"))
|
234 | 238 | + "/Widgets?Namespace=" + container.getAttribute("namespace"),
|
235 | 239 | {
|
236 |
| - Dashboard: widget["dashboardName"] |
| 240 | + Dashboard: zenPage["dashboardName"] |
237 | 241 | },
|
238 | 242 | function (data) {
|
239 | 243 | if (data.error) {
|
|
246 | 250 | }
|
247 | 251 | }
|
248 | 252 | //console.log(info);
|
249 |
| - if (info.controls instanceof Array) { |
250 |
| - for (i in info.controls) { |
251 |
| - if ((info.controls[i].action === "applyFilter" || info.controls[i].action === "setFilter") && info.controls[i].value) { |
252 |
| - if ((filterValue = info.controls[i].value).charAt(0) === "%" && filterValue.indexOf(" ") > 1) { |
253 |
| - filterValue = filterValue.split(" ")[1] + "." + filterValue.split(" ")[0] |
254 |
| - } |
255 |
| - defaultFilters.push(info.controls[i].targetProperty + "." + filterValue); |
256 |
| - } |
257 |
| - } |
258 |
| - } |
259 | 253 | setup = {
|
260 | 254 | container: container,
|
261 | 255 | dataSource: {
|
|
272 | 266 | }
|
273 | 267 | }
|
274 | 268 | }
|
| 269 | + // ++ VP |
| 270 | + // Getting filters from controller, if it has filters filled... |
| 271 | + if (controller.filters.length) { |
| 272 | + for (i in controller.filters) { |
| 273 | + if (controller.filters[i].enabled) defaultFilters.push(controller.filters[i].spec); |
| 274 | + } |
| 275 | + // ... if not, we'll get filters from widget's controls |
| 276 | + } else if (widget.filterState instanceof Object) { |
| 277 | + for (i in widget.filterState) |
| 278 | + if (widget.filterState[i]) defaultFilters.push(widget.constructMDXClause(i,widget.filterState[i])); |
| 279 | + } |
| 280 | + // -- VP |
| 281 | + |
275 | 282 | if (controller.contextFilterSpec) {
|
276 | 283 | defaultFilters.push(controller.contextFilterSpec);
|
277 | 284 | }
|
|
0 commit comments