Skip to content

Commit c3eb72c

Browse files
fixed mdx querying mechanism (mdx type recognition)
1 parent 7680db3 commit c3eb72c

4 files changed

Lines changed: 46 additions & 21 deletions

File tree

source/js/DataSource.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ var DataSource = function (config, globalConfig, lpt) {
2626
*/
2727
this.DATA_SOURCE_PIVOT = config["pivot"] || "";
2828

29-
this.ACTION = config.action || "MDX";
30-
3129
this.FILTERS = [];
3230

3331
this.BASIC_FILTERS = [];
@@ -120,6 +118,7 @@ DataSource.prototype.getCurrentData = function (callback) {
120118
__ = this._convert,
121119
mdx = this.BASIC_MDX,
122120
mdxParser = new MDXParser(),
121+
mdxType = mdxParser.mdxType(mdx),
123122
ready = {
124123
state: 0,
125124
data: {},
@@ -164,8 +163,7 @@ DataSource.prototype.getCurrentData = function (callback) {
164163

165164
//console.log("Retrieved data:", ready);
166165

167-
(data.Info || {}).action = _.ACTION;
168-
if (_.ACTION === "MDXDrillthrough") {
166+
if (mdxType === "drillthrough") {
169167
callback((function (data) {
170168

171169
var arr = data["children"] || [],
@@ -189,8 +187,7 @@ DataSource.prototype.getCurrentData = function (callback) {
189187
cubeName: "No cube name",
190188
leftHeaderColumnsNumber: 0,
191189
rowCount: arr.length,
192-
topHeaderRowsNumber: headers.length,
193-
action: _.ACTION
190+
topHeaderRowsNumber: headers.length
194191
}
195192
};
196193

@@ -203,11 +200,10 @@ DataSource.prototype.getCurrentData = function (callback) {
203200
return __(obj);
204201

205202
})(data));
206-
} else if (_.ACTION = "MDX") {
203+
} else if (mdxType === "mdx") {
207204
callback(_._convert(data));
208205
} else {
209-
console.error("Not implemented URL action: " + _.ACTION);
210-
callback({ error: "Not implemented URL action: " + data || true });
206+
callback({ error: "Unrecognised MDX: " + mdx || true });
211207
}
212208

213209
};
@@ -222,7 +218,11 @@ DataSource.prototype.getCurrentData = function (callback) {
222218

223219
console.log("LPT MDX request:", mdx);
224220

225-
_._post(_.SOURCE_URL + "/" + _.ACTION + (_.NAMESPACE ? "?Namespace=" + _.NAMESPACE : ""), {
221+
_._post(
222+
_.SOURCE_URL + "/" +
223+
(mdxType === "drillthrough" ? "MDXDrillthrough" : "MDX")
224+
+ (_.NAMESPACE ? "?Namespace=" + _.NAMESPACE : ""
225+
), {
226226
MDX: mdx
227227
}, function (data) {
228228
_.LPT.pivotView.removeMessage();

source/js/LightPivotTable.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ LightPivotTable.prototype.tryDrillThrough = function (filters) {
195195

196196
// clone dataSource config object
197197
for (var i in _.CONFIG.dataSource) { ds[i] = _.CONFIG.dataSource[i]; }
198-
ds.action = "MDXDrillthrough";
199198

200199
ds.basicMDX = this.mdxParser.drillThrough(this.dataSource.BASIC_MDX, filters)
201200
|| this.dataSource.basicMDX;

source/js/MDXParser.js

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
var MDXParser = function () {
2-
3-
4-
5-
};
1+
/**
2+
* MDX parser.
3+
*
4+
* @author ZitRo
5+
* @constructor
6+
*/
7+
var MDXParser = function () {};
68

79
/**
810
* Debug method.
@@ -95,6 +97,27 @@ MDXParser.prototype.drillThrough = function (basicMDX, filters) {
9597

9698
};
9799

100+
/**
101+
* Returns type of MDX.
102+
*
103+
* @param {string} mdx
104+
*/
105+
MDXParser.prototype.mdxType = function (mdx) {
106+
107+
var m = mdx.toLowerCase(),
108+
dt = m.indexOf("drillthrough"),
109+
dd = m.indexOf("select");
110+
111+
if (dt > -1) {
112+
return "drillthrough";
113+
} else if (dd > -1) {
114+
return "mdx";
115+
} else {
116+
return "unknown";
117+
}
118+
119+
};
120+
98121
/**
99122
* @param {string} basicMDX
100123
* @param {string} filterSpec

source/js/PivotView.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ PivotView.prototype.recalculateSizes = function (container) {
451451
containerParent.appendChild(container); // attach
452452

453453
} catch (e) {
454-
console.error("Error when fixing sizes. Please, contact the developer.", "ERROR:", e);
454+
console.error("Error when fixing sizes.", "ERROR:", e);
455455
}
456456

457457
};
@@ -594,6 +594,12 @@ PivotView.prototype.renderRawData = function (data) {
594594
_._backClickHandler.call(_, e);
595595
});
596596
}
597+
if ( // hide unnesesarry column
598+
(this.controller.CONFIG["hideButtons"] || this.tablesStack.length < 2)
599+
&& info.leftHeaderColumnsNumber === 0
600+
) {
601+
header.style.display = "none";
602+
}
597603

598604
// render topHeader
599605
renderHeader(
@@ -611,10 +617,7 @@ PivotView.prototype.renderRawData = function (data) {
611617
info.topHeaderRowsNumber,
612618
rawData.length,
613619
LHTHead
614-
);
615-
if (this.controller.CONFIG["hideButtons"] && info.leftHeaderColumnsNumber === 0) {
616-
header.style.display = "none";
617-
}
620+
)
618621

619622
// render table
620623
for (y = info.topHeaderRowsNumber; y < rawData.length; y++) {

0 commit comments

Comments
 (0)