@@ -196,12 +196,12 @@ If LPT has been created before, method fires given callback immidiately.</Descri
196
196
defaultFilters = [],
197
197
exportToExcel = !!parseInt(container.getAttribute("export-csv"));
198
198
199
- // !ultra-bydlocode (get the widget object)
200
- while (widget["parent "]) {
199
+ // Following "parent" until we find widget object
200
+ while (! widget["widgetKey "]) {
201
201
widget = widget["parent"];
202
202
}
203
- // !ultra-bydlocode (possible you will have better suggestions to get widget key)
204
- widgetKey = parseInt(_.parent.parent.onwindowgrab.match(/[0-9]+/)[0]) ;
203
+
204
+ widgetKey = widget["widgetKey"] ;
205
205
206
206
if (exportToExcel) {
207
207
var widgetHead = document.getElementById(basicContainer.getAttribute("id").replace(/\/.*/, "/header"));
@@ -247,7 +247,7 @@ If LPT has been created before, method fires given callback immidiately.</Descri
247
247
(source = location.origin + "/" + container.getAttribute("data-source"))
248
248
+ "/Widgets?Namespace=" + container.getAttribute("namespace"),
249
249
{
250
- Dashboard: widget ["dashboardName"]
250
+ Dashboard: zenPage ["dashboardName"]
251
251
},
252
252
function (data) {
253
253
if (data.error) {
@@ -260,16 +260,6 @@ If LPT has been created before, method fires given callback immidiately.</Descri
260
260
}
261
261
}
262
262
//console.log(info);
263
- if (info.controls instanceof Array) {
264
- for (i in info.controls) {
265
- if ((info.controls[i].action === "applyFilter" || info.controls[i].action === "setFilter") && info.controls[i].value) {
266
- if ((filterValue = info.controls[i].value).charAt(0) === "%" && filterValue.indexOf(" ") > 1) {
267
- filterValue = filterValue.split(" ")[1] + "." + filterValue.split(" ")[0]
268
- }
269
- defaultFilters.push(info.controls[i].targetProperty + "." + filterValue);
270
- }
271
- }
272
- }
273
263
setup = {
274
264
container: container,
275
265
dataSource: {
@@ -286,6 +276,21 @@ If LPT has been created before, method fires given callback immidiately.</Descri
286
276
}
287
277
}
288
278
}
279
+ // Getting filters from controller, if it has filters added from URL or default...
280
+ // such filters are marked as "transient"
281
+ if (controller.filters.length) {
282
+ for (i in controller.filters) {
283
+ if (controller.filters[i].enabled && controller.filters[i].transient)
284
+ defaultFilters.push(controller.filters[i].spec);
285
+ }
286
+ }
287
+ // ... if not, we'll get filters from widget's controls
288
+ // Only if the controller didn't have transient filters - (!defaultFilters.length)
289
+ if (!defaultFilters.length && widget.filterState instanceof Object) {
290
+ for (i in widget.filterState)
291
+ if (widget.filterState[i]) defaultFilters.push(widget.constructMDXClause(i,widget.filterState[i]));
292
+ }
293
+
289
294
if (controller.contextFilterSpec) {
290
295
defaultFilters.push(controller.contextFilterSpec);
291
296
}
0 commit comments