Skip to content

Commit 1a0c488

Browse files
Listing data view enhance
1 parent b6e0d3c commit 1a0c488

File tree

4 files changed

+82
-12
lines changed

4 files changed

+82
-12
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "LightPivotTable",
33
"author": "ZitRo",
4-
"version": "1.4.13",
4+
"version": "1.5.0",
55
"description": "A lightweight pivot table for MDX2JSON source for InterSystems Cache",
66
"main": "test/testServer.js",
77
"repository": {

source/css/LightPivot.css

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,19 @@
276276

277277
/* lpt-dataWait */
278278
.lpt .lpt-hoverMessage {
279+
position: absolute;
280+
box-sizing: border-box;
281+
left: 0;
282+
top: 0;
283+
width: 100%;
284+
height: 100%;
285+
overflow: auto;
286+
padding: .5em;
279287
z-index: 999;
280288
opacity: 0;
281289
font-size: xx-large;
282290
font-family: serif;
283-
background: rgba(255, 255, 255, 0.85);
291+
background: rgba(255, 255, 255, 0.95);
284292
white-space: normal;
285293
line-height: 1;
286294
-webkit-transition: opacity 1s ease;
@@ -538,4 +546,15 @@
538546
border-top: none;
539547
border-bottom: none;
540548
outline: none;
549+
}
550+
551+
.lpt-messageHead {
552+
font-size: 14pt;
553+
font-weight: 900;
554+
text-decoration: underline;
555+
margin-bottom: .2em;
556+
}
557+
558+
.lpt-messageBody {
559+
font-size: 12pt;
541560
}

source/js/DataController.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,9 @@ DataController.prototype.setData = function (data) {
106106
this.postDataProcessing(data);
107107

108108
if (data.info.mdxType === "drillthrough") {
109-
this.setDrillThroughHandler(function (params) {
110-
_.controller.pivotView.displayMessage(params["cellData"]["value"] || "", true);
111-
return false;
112-
});
109+
this.setDrillThroughHandler(
110+
this.controller.pivotView.listingClickHandler.bind(this.controller.pivotView)
111+
);
113112
}
114113
//console.log(data);
115114
this._trigger();

source/js/PivotView.js

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ PivotView.prototype._getSelectedText = function () {
433433
* @param {event} event
434434
* @param {function} [drillThroughHandler]
435435
*/
436-
PivotView.prototype._cellClickHandler = function (cell, x, y, event, drillThroughHandler) {
436+
PivotView.prototype._cellClickHandler = function (cell, x, y, event, drillThroughHandler, data) {
437437

438438
var data = this.controller.dataController.getData(),
439439
f = [], f1, f2, callbackRes = true, result,
@@ -473,21 +473,73 @@ PivotView.prototype._cellClickHandler = function (cell, x, y, event, drillThroug
473473
callbackRes = this.controller.CONFIG.triggers["cellDrillThrough"]({
474474
event: event,
475475
filters: f,
476-
cellData: cell
477-
});
476+
cellData: cell,
477+
x: x,
478+
y: y
479+
}, data);
478480
}
479481
if (typeof drillThroughHandler === "function") {
480482
callbackRes = !(!(false !== drillThroughHandler({
481483
event: event,
482484
filters: f,
483-
cellData: cell
484-
})) || !(callbackRes !== false));
485+
cellData: cell,
486+
x: x,
487+
y: y
488+
}, data)) || !(callbackRes !== false));
485489
}
486490
if (callbackRes !== false) this.controller.tryDrillThrough(f);
487491
}
488492

489493
};
490494

495+
PivotView.prototype.listingClickHandler = function (params, data) {
496+
497+
if (data.info.leftHeaderColumnsNumber !== 0) {
498+
console.warn("Listing handler called not for a listing!");
499+
return;
500+
}
501+
502+
var self = this,
503+
el = function (e) { return document.createElement(e); },
504+
d1 = document.createElement("div"),
505+
headers = data.rawData[0].map(function (v) {
506+
return v.value + (v.source && v.source.title ? "(" + v.source.title + ")" : "");
507+
}),
508+
values = data.rawData[params.y].map(function (v) { return v.value; });
509+
510+
d1.className = "lpt-hoverMessage";
511+
d1.style.fontSize = "12pt";
512+
d1.style.opacity = 0;
513+
514+
var h, val, hr;
515+
for (var i = 0; i < headers.length; i++) {
516+
h = el("div"); val = el("div"); hr = el("hr");
517+
h.className = "lpt-messageHead";
518+
h.textContent = headers[i];
519+
val.className = "lpt-messageBody";
520+
if (values[i] !== "")
521+
val.textContent = values[i];
522+
else
523+
val.innerHTML = "&nbsp;";
524+
d1.appendChild(h);
525+
d1.appendChild(val);
526+
d1.appendChild(hr);
527+
}
528+
529+
this.elements.base.appendChild(d1);
530+
531+
setTimeout(function () {
532+
if (d1) d1.style.opacity = 1;
533+
}, 1);
534+
d1.addEventListener(this.controller.CONFIG["triggerEvent"] || "click", function () {
535+
if (self._getSelectedText()) return;
536+
self.removeMessage();
537+
});
538+
539+
return false;
540+
541+
};
542+
491543
/**
492544
* Display hovering message.
493545
*
@@ -1295,7 +1347,7 @@ PivotView.prototype.renderRawData = function (data) {
12951347
td.addEventListener(CLICK_EVENT, (function (x, y, cell) {
12961348
return function (event) {
12971349
_._cellClickHandler.call(
1298-
_, cell, x, y, event, info.drillThroughHandler
1350+
_, cell, x, y, event, info.drillThroughHandler, data
12991351
);
13001352
};
13011353
})(x, y, rawData[y][x]));

0 commit comments

Comments
 (0)