@datarailsshared/dr_renderer 1.4.97 → 1.4.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/highcharts_renderer.js +1 -0
- package/src/pivottable.js +456 -453
package/package.json
CHANGED
@@ -4839,6 +4839,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4839
4839
|
dateValuesDictionary: pivotOptions ? pivotOptions.dateValuesDictionary : null,
|
4840
4840
|
keysObject: pivotOptions ? pivotOptions.keysObject : null,
|
4841
4841
|
isDrillDownDisabled: pivotOptions ? pivotOptions.isDrillDownDisabled : false,
|
4842
|
+
pivotUiFnRemoved: pivotOptions ? pivotOptions.pivotUiFnRemoved : false,
|
4842
4843
|
};
|
4843
4844
|
|
4844
4845
|
if (!subopts.rendererOptions) {
|
package/src/pivottable.js
CHANGED
@@ -665,6 +665,7 @@ let initPivotTable = function($, window, document) {
|
|
665
665
|
this.getFormattedColKeys = (keys) => opts.getFormattedColKeys(this, keys);
|
666
666
|
this.getFormattedRowKeys = (keys) => opts.getFormattedRowKeys(this, keys);
|
667
667
|
this.isDrillDownDisabled = opts.isDrillDownDisabled;
|
668
|
+
this.pivotUiFnRemoved = opts.pivotUiFnRemoved;
|
668
669
|
|
669
670
|
PivotData.forEachRecord(this.input, this.derivedAttributes, (function(_this) {
|
670
671
|
return function(record) {
|
@@ -1214,500 +1215,502 @@ let initPivotTable = function($, window, document) {
|
|
1214
1215
|
Pivot Table UI: calls Pivot Table core above with options set by user
|
1215
1216
|
*/
|
1216
1217
|
$.fn.pivotUI = function(input, inputOpts, overwrite, locale) {
|
1217
|
-
|
1218
|
-
|
1219
|
-
overwrite
|
1220
|
-
|
1221
|
-
|
1222
|
-
locale
|
1223
|
-
|
1224
|
-
|
1225
|
-
locale
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1218
|
+
if (!this.pivotUiFnRemoved) {
|
1219
|
+
var a, aggregator, attr, attrLength, attrValues, c, colOrderArrow, defaults, e, existingOpts, fn1, i, initialRender, l, len1, len2, len3, localeDefaults, localeStrings, materializedInput, n, o, opts, ordering, pivotTable, recordsProcessed, ref, ref1, ref2, ref3, refresh, refreshDelayed, renderer, rendererControl, rowOrderArrow, shownAttributes, shownInAggregators, shownInDragDrop, tr1, tr2, uiTable, unused, unusedAttrsVerticalAutoCutoff, unusedAttrsVerticalAutoOverride, x;
|
1220
|
+
if (overwrite == null) {
|
1221
|
+
overwrite = false;
|
1222
|
+
}
|
1223
|
+
if (locale == null) {
|
1224
|
+
locale = "en";
|
1225
|
+
}
|
1226
|
+
if (locales[locale] == null) {
|
1227
|
+
locale = "en";
|
1228
|
+
}
|
1229
|
+
defaults = {
|
1230
|
+
derivedAttributes: {},
|
1231
|
+
aggregators: locales[locale].aggregators,
|
1232
|
+
renderers: locales[locale].renderers,
|
1233
|
+
hiddenAttributes: [],
|
1234
|
+
hiddenFromAggregators: [],
|
1235
|
+
hiddenFromDragDrop: [],
|
1236
|
+
menuLimit: 500,
|
1237
|
+
cols: [],
|
1238
|
+
rows: [],
|
1239
|
+
vals: [],
|
1240
|
+
rowOrder: "key_a_to_z",
|
1241
|
+
colOrder: "key_a_to_z",
|
1242
|
+
dataClass: PivotData,
|
1243
|
+
exclusions: {},
|
1244
|
+
inclusions: {},
|
1245
|
+
unusedAttrsVertical: 85,
|
1246
|
+
autoSortUnusedAttrs: false,
|
1247
|
+
onRefresh: null,
|
1248
|
+
showUI: true,
|
1249
|
+
filter: function() {
|
1250
|
+
return true;
|
1251
|
+
},
|
1252
|
+
sorters: {}
|
1253
|
+
};
|
1254
|
+
localeStrings = $.extend(true, {}, locales.en.localeStrings, locales[locale].localeStrings);
|
1255
|
+
localeDefaults = {
|
1256
|
+
rendererOptions: {
|
1257
|
+
localeStrings: localeStrings
|
1258
|
+
},
|
1255
1259
|
localeStrings: localeStrings
|
1256
|
-
}
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
if (!opts.filter(record)) {
|
1272
|
-
return;
|
1273
|
-
}
|
1274
|
-
materializedInput.push(record);
|
1275
|
-
for (attr in record) {
|
1276
|
-
if (!hasProp.call(record, attr)) continue;
|
1277
|
-
if (attrValues[attr] == null) {
|
1278
|
-
attrValues[attr] = {};
|
1279
|
-
if (recordsProcessed > 0) {
|
1280
|
-
attrValues[attr]["null"] = recordsProcessed;
|
1281
|
-
}
|
1260
|
+
};
|
1261
|
+
existingOpts = this.data("pivotUIOptions");
|
1262
|
+
if ((existingOpts == null) || overwrite) {
|
1263
|
+
opts = $.extend(true, {}, localeDefaults, $.extend({}, defaults, inputOpts));
|
1264
|
+
} else {
|
1265
|
+
opts = existingOpts;
|
1266
|
+
}
|
1267
|
+
try {
|
1268
|
+
attrValues = {};
|
1269
|
+
materializedInput = [];
|
1270
|
+
recordsProcessed = 0;
|
1271
|
+
PivotData.forEachRecord(input, opts.derivedAttributes, function(record) {
|
1272
|
+
var attr, base, ref, value;
|
1273
|
+
if (!opts.filter(record)) {
|
1274
|
+
return;
|
1282
1275
|
}
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1276
|
+
materializedInput.push(record);
|
1277
|
+
for (attr in record) {
|
1278
|
+
if (!hasProp.call(record, attr)) continue;
|
1279
|
+
if (attrValues[attr] == null) {
|
1280
|
+
attrValues[attr] = {};
|
1281
|
+
if (recordsProcessed > 0) {
|
1282
|
+
attrValues[attr]["null"] = recordsProcessed;
|
1283
|
+
}
|
1284
|
+
}
|
1288
1285
|
}
|
1289
|
-
attrValues
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
}).attr("cellpadding", 5);
|
1296
|
-
rendererControl = $("<td>").addClass("pvtUiCell");
|
1297
|
-
renderer = $("<select>").addClass('pvtRenderer').appendTo(rendererControl).bind("change", function() {
|
1298
|
-
return refresh();
|
1299
|
-
});
|
1300
|
-
ref = opts.renderers;
|
1301
|
-
for (x in ref) {
|
1302
|
-
if (!hasProp.call(ref, x)) continue;
|
1303
|
-
$("<option>").val(x).html(x).appendTo(renderer);
|
1304
|
-
}
|
1305
|
-
unused = $("<td>").addClass('pvtAxisContainer pvtUnused pvtUiCell');
|
1306
|
-
shownAttributes = (function() {
|
1307
|
-
var results;
|
1308
|
-
results = [];
|
1309
|
-
for (a in attrValues) {
|
1310
|
-
if (indexOf.call(opts.hiddenAttributes, a) < 0) {
|
1311
|
-
results.push(a);
|
1286
|
+
for (attr in attrValues) {
|
1287
|
+
value = (ref = record[attr]) != null ? ref : "null";
|
1288
|
+
if ((base = attrValues[attr])[value] == null) {
|
1289
|
+
base[value] = 0;
|
1290
|
+
}
|
1291
|
+
attrValues[attr][value]++;
|
1312
1292
|
}
|
1293
|
+
return recordsProcessed++;
|
1294
|
+
});
|
1295
|
+
uiTable = $("<table>", {
|
1296
|
+
"class": "pvtUi"
|
1297
|
+
}).attr("cellpadding", 5);
|
1298
|
+
rendererControl = $("<td>").addClass("pvtUiCell");
|
1299
|
+
renderer = $("<select>").addClass('pvtRenderer').appendTo(rendererControl).bind("change", function() {
|
1300
|
+
return refresh();
|
1301
|
+
});
|
1302
|
+
ref = opts.renderers;
|
1303
|
+
for (x in ref) {
|
1304
|
+
if (!hasProp.call(ref, x)) continue;
|
1305
|
+
$("<option>").val(x).html(x).appendTo(renderer);
|
1313
1306
|
}
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
results.push(c);
|
1307
|
+
unused = $("<td>").addClass('pvtAxisContainer pvtUnused pvtUiCell');
|
1308
|
+
shownAttributes = (function() {
|
1309
|
+
var results;
|
1310
|
+
results = [];
|
1311
|
+
for (a in attrValues) {
|
1312
|
+
if (indexOf.call(opts.hiddenAttributes, a) < 0) {
|
1313
|
+
results.push(a);
|
1314
|
+
}
|
1323
1315
|
}
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1316
|
+
return results;
|
1317
|
+
})();
|
1318
|
+
shownInAggregators = (function() {
|
1319
|
+
var l, len1, results;
|
1320
|
+
results = [];
|
1321
|
+
for (l = 0, len1 = shownAttributes.length; l < len1; l++) {
|
1322
|
+
c = shownAttributes[l];
|
1323
|
+
if (indexOf.call(opts.hiddenFromAggregators, c) < 0) {
|
1324
|
+
results.push(c);
|
1325
|
+
}
|
1334
1326
|
}
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
if (opts.unusedAttrsVertical === "auto") {
|
1340
|
-
unusedAttrsVerticalAutoCutoff = 120;
|
1341
|
-
} else {
|
1342
|
-
unusedAttrsVerticalAutoCutoff = parseInt(opts.unusedAttrsVertical);
|
1343
|
-
}
|
1344
|
-
if (!isNaN(unusedAttrsVerticalAutoCutoff)) {
|
1345
|
-
attrLength = 0;
|
1346
|
-
for (l = 0, len1 = shownInDragDrop.length; l < len1; l++) {
|
1347
|
-
a = shownInDragDrop[l];
|
1348
|
-
attrLength += a.length;
|
1349
|
-
}
|
1350
|
-
unusedAttrsVerticalAutoOverride = attrLength > unusedAttrsVerticalAutoCutoff;
|
1351
|
-
}
|
1352
|
-
if (opts.unusedAttrsVertical === true || unusedAttrsVerticalAutoOverride) {
|
1353
|
-
unused.addClass('pvtVertList');
|
1354
|
-
} else {
|
1355
|
-
unused.addClass('pvtHorizList');
|
1356
|
-
}
|
1357
|
-
fn1 = function(attr) {
|
1358
|
-
var attrElem, checkContainer, closeFilterBox, controls, filterItem, filterItemExcluded, finalButtons, hasExcludedItem, len2, n, placeholder, ref1, sorter, triangleLink, v, value, valueCount, valueList, values;
|
1359
|
-
values = (function() {
|
1360
|
-
var results;
|
1327
|
+
return results;
|
1328
|
+
})();
|
1329
|
+
shownInDragDrop = (function() {
|
1330
|
+
var l, len1, results;
|
1361
1331
|
results = [];
|
1362
|
-
for (
|
1363
|
-
|
1332
|
+
for (l = 0, len1 = shownAttributes.length; l < len1; l++) {
|
1333
|
+
c = shownAttributes[l];
|
1334
|
+
if (indexOf.call(opts.hiddenFromDragDrop, c) < 0) {
|
1335
|
+
results.push(c);
|
1336
|
+
}
|
1364
1337
|
}
|
1365
1338
|
return results;
|
1366
1339
|
})();
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1340
|
+
unusedAttrsVerticalAutoOverride = false;
|
1341
|
+
if (opts.unusedAttrsVertical === "auto") {
|
1342
|
+
unusedAttrsVerticalAutoCutoff = 120;
|
1343
|
+
} else {
|
1344
|
+
unusedAttrsVerticalAutoCutoff = parseInt(opts.unusedAttrsVertical);
|
1345
|
+
}
|
1346
|
+
if (!isNaN(unusedAttrsVerticalAutoCutoff)) {
|
1347
|
+
attrLength = 0;
|
1348
|
+
for (l = 0, len1 = shownInDragDrop.length; l < len1; l++) {
|
1349
|
+
a = shownInDragDrop[l];
|
1350
|
+
attrLength += a.length;
|
1351
|
+
}
|
1352
|
+
unusedAttrsVerticalAutoOverride = attrLength > unusedAttrsVerticalAutoCutoff;
|
1353
|
+
}
|
1354
|
+
if (opts.unusedAttrsVertical === true || unusedAttrsVerticalAutoOverride) {
|
1355
|
+
unused.addClass('pvtVertList');
|
1372
1356
|
} else {
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
}
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1357
|
+
unused.addClass('pvtHorizList');
|
1358
|
+
}
|
1359
|
+
fn1 = function(attr) {
|
1360
|
+
var attrElem, checkContainer, closeFilterBox, controls, filterItem, filterItemExcluded, finalButtons, hasExcludedItem, len2, n, placeholder, ref1, sorter, triangleLink, v, value, valueCount, valueList, values;
|
1361
|
+
values = (function() {
|
1362
|
+
var results;
|
1363
|
+
results = [];
|
1364
|
+
for (v in attrValues[attr]) {
|
1365
|
+
results.push(v);
|
1366
|
+
}
|
1367
|
+
return results;
|
1368
|
+
})();
|
1369
|
+
hasExcludedItem = false;
|
1370
|
+
valueList = $("<div>").addClass('pvtFilterBox').hide();
|
1371
|
+
valueList.append($("<h4>").append($("<span>").text(attr), $("<span>").addClass("count").text("(" + values.length + ")")));
|
1372
|
+
if (values.length > opts.menuLimit) {
|
1373
|
+
valueList.append($("<p>").html(opts.localeStrings.tooMany));
|
1374
|
+
} else {
|
1375
|
+
if (values.length > 5) {
|
1376
|
+
controls = $("<p>").appendTo(valueList);
|
1377
|
+
sorter = getSort(opts.sorters, attr);
|
1378
|
+
placeholder = opts.localeStrings.filterResults;
|
1379
|
+
$("<input>", {
|
1380
|
+
type: "text"
|
1381
|
+
}).appendTo(controls).attr({
|
1382
|
+
placeholder: placeholder,
|
1383
|
+
"class": "pvtSearch"
|
1384
|
+
}).bind("keyup", function() {
|
1385
|
+
var accept, accept_gen, filter;
|
1386
|
+
filter = $(this).val().toLowerCase().trim();
|
1387
|
+
accept_gen = function(prefix, accepted) {
|
1388
|
+
return function(v) {
|
1389
|
+
var real_filter, ref1;
|
1390
|
+
real_filter = filter.substring(prefix.length).trim();
|
1391
|
+
if (real_filter.length === 0) {
|
1392
|
+
return true;
|
1393
|
+
}
|
1394
|
+
return ref1 = Math.sign(sorter(v.toLowerCase(), real_filter)), indexOf.call(accepted, ref1) >= 0;
|
1395
|
+
};
|
1396
|
+
};
|
1397
|
+
accept = filter.indexOf(">=") === 0 ? accept_gen(">=", [1, 0]) : filter.indexOf("<=") === 0 ? accept_gen("<=", [-1, 0]) : filter.indexOf(">") === 0 ? accept_gen(">", [1]) : filter.indexOf("<") === 0 ? accept_gen("<", [-1]) : filter.indexOf("~") === 0 ? function(v) {
|
1398
|
+
if (filter.substring(1).trim().length === 0) {
|
1390
1399
|
return true;
|
1391
1400
|
}
|
1392
|
-
return
|
1401
|
+
return v.toLowerCase().match(filter.substring(1));
|
1402
|
+
} : function(v) {
|
1403
|
+
return v.toLowerCase().indexOf(filter) !== -1;
|
1393
1404
|
};
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
return v.toLowerCase().indexOf(filter) !== -1;
|
1402
|
-
};
|
1403
|
-
return valueList.find('.pvtCheckContainer p label span.value').each(function() {
|
1404
|
-
if (accept($(this).text())) {
|
1405
|
-
return $(this).parent().parent().show();
|
1406
|
-
} else {
|
1407
|
-
return $(this).parent().parent().hide();
|
1408
|
-
}
|
1405
|
+
return valueList.find('.pvtCheckContainer p label span.value').each(function() {
|
1406
|
+
if (accept($(this).text())) {
|
1407
|
+
return $(this).parent().parent().show();
|
1408
|
+
} else {
|
1409
|
+
return $(this).parent().parent().hide();
|
1410
|
+
}
|
1411
|
+
});
|
1409
1412
|
});
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
}
|
1413
|
+
controls.append($("<br>"));
|
1414
|
+
$("<button>", {
|
1415
|
+
type: "button"
|
1416
|
+
}).appendTo(controls).html(opts.localeStrings.selectAll).bind("click", function() {
|
1417
|
+
valueList.find("input:visible:not(:checked)").prop("checked", true).toggleClass("changed");
|
1418
|
+
return false;
|
1419
|
+
});
|
1420
|
+
$("<button>", {
|
1421
|
+
type: "button"
|
1422
|
+
}).appendTo(controls).html(opts.localeStrings.selectNone).bind("click", function() {
|
1423
|
+
valueList.find("input:visible:checked").prop("checked", false).toggleClass("changed");
|
1424
|
+
return false;
|
1425
|
+
});
|
1426
|
+
}
|
1427
|
+
checkContainer = $("<div>").addClass("pvtCheckContainer").appendTo(valueList);
|
1428
|
+
ref1 = values.sort(getSort(opts.sorters, attr));
|
1429
|
+
for (n = 0, len2 = ref1.length; n < len2; n++) {
|
1430
|
+
value = ref1[n];
|
1431
|
+
valueCount = attrValues[attr][value];
|
1432
|
+
filterItem = $("<label>");
|
1433
|
+
filterItemExcluded = false;
|
1434
|
+
if (opts.inclusions[attr]) {
|
1435
|
+
filterItemExcluded = (indexOf.call(opts.inclusions[attr], value) < 0);
|
1436
|
+
} else if (opts.exclusions[attr]) {
|
1437
|
+
filterItemExcluded = (indexOf.call(opts.exclusions[attr], value) >= 0);
|
1438
|
+
}
|
1439
|
+
hasExcludedItem || (hasExcludedItem = filterItemExcluded);
|
1440
|
+
$("<input>").attr("type", "checkbox").addClass('pvtFilter').attr("checked", !filterItemExcluded).data("filter", [attr, value]).appendTo(filterItem).bind("change", function() {
|
1441
|
+
return $(this).toggleClass("changed");
|
1442
|
+
});
|
1443
|
+
filterItem.append($("<span>").addClass("value").text(value));
|
1444
|
+
filterItem.append($("<span>").addClass("count").text("(" + valueCount + ")"));
|
1445
|
+
checkContainer.append($("<p>").append(filterItem));
|
1446
|
+
}
|
1424
1447
|
}
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1430
|
-
filterItem = $("<label>");
|
1431
|
-
filterItemExcluded = false;
|
1432
|
-
if (opts.inclusions[attr]) {
|
1433
|
-
filterItemExcluded = (indexOf.call(opts.inclusions[attr], value) < 0);
|
1434
|
-
} else if (opts.exclusions[attr]) {
|
1435
|
-
filterItemExcluded = (indexOf.call(opts.exclusions[attr], value) >= 0);
|
1448
|
+
closeFilterBox = function() {
|
1449
|
+
if (valueList.find("[type='checkbox']").length > valueList.find("[type='checkbox']:checked").length) {
|
1450
|
+
attrElem.addClass("pvtFilteredAttribute");
|
1451
|
+
} else {
|
1452
|
+
attrElem.removeClass("pvtFilteredAttribute");
|
1436
1453
|
}
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1454
|
+
valueList.find('.pvtSearch').val('');
|
1455
|
+
valueList.find('.pvtCheckContainer p').show();
|
1456
|
+
return valueList.hide();
|
1457
|
+
};
|
1458
|
+
finalButtons = $("<p>").appendTo(valueList);
|
1459
|
+
if (values.length <= opts.menuLimit) {
|
1460
|
+
$("<button>", {
|
1461
|
+
type: "button"
|
1462
|
+
}).text(opts.localeStrings.apply).appendTo(finalButtons).bind("click", function() {
|
1463
|
+
if (valueList.find(".changed").removeClass("changed").length) {
|
1464
|
+
refresh();
|
1465
|
+
}
|
1466
|
+
return closeFilterBox();
|
1440
1467
|
});
|
1441
|
-
filterItem.append($("<span>").addClass("value").text(value));
|
1442
|
-
filterItem.append($("<span>").addClass("count").text("(" + valueCount + ")"));
|
1443
|
-
checkContainer.append($("<p>").append(filterItem));
|
1444
|
-
}
|
1445
|
-
}
|
1446
|
-
closeFilterBox = function() {
|
1447
|
-
if (valueList.find("[type='checkbox']").length > valueList.find("[type='checkbox']:checked").length) {
|
1448
|
-
attrElem.addClass("pvtFilteredAttribute");
|
1449
|
-
} else {
|
1450
|
-
attrElem.removeClass("pvtFilteredAttribute");
|
1451
1468
|
}
|
1452
|
-
valueList.find('.pvtSearch').val('');
|
1453
|
-
valueList.find('.pvtCheckContainer p').show();
|
1454
|
-
return valueList.hide();
|
1455
|
-
};
|
1456
|
-
finalButtons = $("<p>").appendTo(valueList);
|
1457
|
-
if (values.length <= opts.menuLimit) {
|
1458
1469
|
$("<button>", {
|
1459
1470
|
type: "button"
|
1460
|
-
}).text(opts.localeStrings.
|
1461
|
-
|
1462
|
-
|
1463
|
-
}
|
1471
|
+
}).text(opts.localeStrings.cancel).appendTo(finalButtons).bind("click", function() {
|
1472
|
+
valueList.find(".changed:checked").removeClass("changed").prop("checked", false);
|
1473
|
+
valueList.find(".changed:not(:checked)").removeClass("changed").prop("checked", true);
|
1464
1474
|
return closeFilterBox();
|
1465
1475
|
});
|
1476
|
+
triangleLink = $("<span>").addClass('pvtTriangle').html(" ▾").bind("click", function(e) {
|
1477
|
+
var left, ref2, top;
|
1478
|
+
ref2 = $(e.currentTarget).position(), left = ref2.left, top = ref2.top;
|
1479
|
+
return valueList.css({
|
1480
|
+
left: left + 10,
|
1481
|
+
top: top + 10
|
1482
|
+
}).show();
|
1483
|
+
});
|
1484
|
+
attrElem = $("<li>").addClass("axis_" + i).append($("<span>").addClass('pvtAttr').text(attr).data("attrName", attr).append(triangleLink));
|
1485
|
+
if (hasExcludedItem) {
|
1486
|
+
attrElem.addClass('pvtFilteredAttribute');
|
1487
|
+
}
|
1488
|
+
return unused.append(attrElem).append(valueList);
|
1489
|
+
};
|
1490
|
+
for (i in shownInDragDrop) {
|
1491
|
+
if (!hasProp.call(shownInDragDrop, i)) continue;
|
1492
|
+
attr = shownInDragDrop[i];
|
1493
|
+
fn1(attr);
|
1494
|
+
}
|
1495
|
+
tr1 = $("<tr>").appendTo(uiTable);
|
1496
|
+
aggregator = $("<select>").addClass('pvtAggregator').bind("change", function() {
|
1497
|
+
return refresh();
|
1498
|
+
});
|
1499
|
+
ref1 = opts.aggregators;
|
1500
|
+
for (x in ref1) {
|
1501
|
+
if (!hasProp.call(ref1, x)) continue;
|
1502
|
+
aggregator.append($("<option>").val(x).html(x));
|
1466
1503
|
}
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1504
|
+
ordering = {
|
1505
|
+
key_a_to_z: {
|
1506
|
+
rowSymbol: "↕",
|
1507
|
+
colSymbol: "↔",
|
1508
|
+
next: "value_a_to_z"
|
1509
|
+
},
|
1510
|
+
value_a_to_z: {
|
1511
|
+
rowSymbol: "↓",
|
1512
|
+
colSymbol: "→",
|
1513
|
+
next: "value_z_to_a"
|
1514
|
+
},
|
1515
|
+
value_z_to_a: {
|
1516
|
+
rowSymbol: "↑",
|
1517
|
+
colSymbol: "←",
|
1518
|
+
next: "key_a_to_z"
|
1519
|
+
}
|
1520
|
+
};
|
1521
|
+
rowOrderArrow = $("<a>", {
|
1522
|
+
role: "button"
|
1523
|
+
}).addClass("pvtRowOrder").data("order", opts.rowOrder).html(ordering[opts.rowOrder].rowSymbol).bind("click", function() {
|
1524
|
+
$(this).data("order", ordering[$(this).data("order")].next);
|
1525
|
+
$(this).html(ordering[$(this).data("order")].rowSymbol);
|
1526
|
+
return refresh();
|
1473
1527
|
});
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
}).show();
|
1528
|
+
colOrderArrow = $("<a>", {
|
1529
|
+
role: "button"
|
1530
|
+
}).addClass("pvtColOrder").data("order", opts.colOrder).html(ordering[opts.colOrder].colSymbol).bind("click", function() {
|
1531
|
+
$(this).data("order", ordering[$(this).data("order")].next);
|
1532
|
+
$(this).html(ordering[$(this).data("order")].colSymbol);
|
1533
|
+
return refresh();
|
1481
1534
|
});
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1535
|
+
$("<td>").addClass('pvtVals pvtUiCell').appendTo(tr1).append(aggregator).append(rowOrderArrow).append(colOrderArrow).append($("<br>"));
|
1536
|
+
$("<td>").addClass('pvtAxisContainer pvtHorizList pvtCols pvtUiCell').appendTo(tr1);
|
1537
|
+
tr2 = $("<tr>").appendTo(uiTable);
|
1538
|
+
tr2.append($("<td>").addClass('pvtAxisContainer pvtRows pvtUiCell').attr("valign", "top"));
|
1539
|
+
pivotTable = $("<td>").attr("valign", "top").addClass('pvtRendererArea').appendTo(tr2);
|
1540
|
+
if (opts.unusedAttrsVertical === true || unusedAttrsVerticalAutoOverride) {
|
1541
|
+
uiTable.find('tr:nth-child(1)').prepend(rendererControl);
|
1542
|
+
uiTable.find('tr:nth-child(2)').prepend(unused);
|
1543
|
+
} else {
|
1544
|
+
uiTable.prepend($("<tr>").append(rendererControl).append(unused));
|
1485
1545
|
}
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1491
|
-
fn1(attr);
|
1492
|
-
}
|
1493
|
-
tr1 = $("<tr>").appendTo(uiTable);
|
1494
|
-
aggregator = $("<select>").addClass('pvtAggregator').bind("change", function() {
|
1495
|
-
return refresh();
|
1496
|
-
});
|
1497
|
-
ref1 = opts.aggregators;
|
1498
|
-
for (x in ref1) {
|
1499
|
-
if (!hasProp.call(ref1, x)) continue;
|
1500
|
-
aggregator.append($("<option>").val(x).html(x));
|
1501
|
-
}
|
1502
|
-
ordering = {
|
1503
|
-
key_a_to_z: {
|
1504
|
-
rowSymbol: "↕",
|
1505
|
-
colSymbol: "↔",
|
1506
|
-
next: "value_a_to_z"
|
1507
|
-
},
|
1508
|
-
value_a_to_z: {
|
1509
|
-
rowSymbol: "↓",
|
1510
|
-
colSymbol: "→",
|
1511
|
-
next: "value_z_to_a"
|
1512
|
-
},
|
1513
|
-
value_z_to_a: {
|
1514
|
-
rowSymbol: "↑",
|
1515
|
-
colSymbol: "←",
|
1516
|
-
next: "key_a_to_z"
|
1546
|
+
this.html(uiTable);
|
1547
|
+
ref2 = opts.cols;
|
1548
|
+
for (n = 0, len2 = ref2.length; n < len2; n++) {
|
1549
|
+
x = ref2[n];
|
1550
|
+
this.find(".pvtCols").append(this.find(".axis_" + ($.inArray(x, shownInDragDrop))));
|
1517
1551
|
}
|
1518
|
-
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
if (!opts.showUI) {
|
1562
|
-
this.find(".pvtUiCell").hide();
|
1563
|
-
}
|
1564
|
-
initialRender = true;
|
1565
|
-
refreshDelayed = (function(_this) {
|
1566
|
-
return function() {
|
1567
|
-
var exclusions, inclusions, len4, newDropdown, numInputsToProcess, pivotUIOptions, pvtVals, ref4, ref5, subopts, t, u, unusedAttrsContainer, vals;
|
1568
|
-
subopts = {
|
1569
|
-
derivedAttributes: opts.derivedAttributes,
|
1570
|
-
localeStrings: opts.localeStrings,
|
1571
|
-
rendererOptions: opts.rendererOptions,
|
1572
|
-
sorters: opts.sorters,
|
1573
|
-
cols: [],
|
1574
|
-
rows: [],
|
1575
|
-
dataClass: opts.dataClass
|
1576
|
-
};
|
1577
|
-
numInputsToProcess = (ref4 = opts.aggregators[aggregator.val()]([])().numInputs) != null ? ref4 : 0;
|
1578
|
-
vals = [];
|
1579
|
-
_this.find(".pvtRows li span.pvtAttr").each(function() {
|
1580
|
-
return subopts.rows.push($(this).data("attrName"));
|
1581
|
-
});
|
1582
|
-
_this.find(".pvtCols li span.pvtAttr").each(function() {
|
1583
|
-
return subopts.cols.push($(this).data("attrName"));
|
1584
|
-
});
|
1585
|
-
_this.find(".pvtVals select.pvtAttrDropdown").each(function() {
|
1586
|
-
if (numInputsToProcess === 0) {
|
1587
|
-
return $(this).remove();
|
1588
|
-
} else {
|
1589
|
-
numInputsToProcess--;
|
1590
|
-
if ($(this).val() !== "") {
|
1591
|
-
return vals.push($(this).val());
|
1552
|
+
ref3 = opts.rows;
|
1553
|
+
for (o = 0, len3 = ref3.length; o < len3; o++) {
|
1554
|
+
x = ref3[o];
|
1555
|
+
this.find(".pvtRows").append(this.find(".axis_" + ($.inArray(x, shownInDragDrop))));
|
1556
|
+
}
|
1557
|
+
if (opts.aggregatorName != null) {
|
1558
|
+
this.find(".pvtAggregator").val(opts.aggregatorName);
|
1559
|
+
}
|
1560
|
+
if (opts.rendererName != null) {
|
1561
|
+
this.find(".pvtRenderer").val(opts.rendererName);
|
1562
|
+
}
|
1563
|
+
if (!opts.showUI) {
|
1564
|
+
this.find(".pvtUiCell").hide();
|
1565
|
+
}
|
1566
|
+
initialRender = true;
|
1567
|
+
refreshDelayed = (function(_this) {
|
1568
|
+
return function() {
|
1569
|
+
var exclusions, inclusions, len4, newDropdown, numInputsToProcess, pivotUIOptions, pvtVals, ref4, ref5, subopts, t, u, unusedAttrsContainer, vals;
|
1570
|
+
subopts = {
|
1571
|
+
derivedAttributes: opts.derivedAttributes,
|
1572
|
+
localeStrings: opts.localeStrings,
|
1573
|
+
rendererOptions: opts.rendererOptions,
|
1574
|
+
sorters: opts.sorters,
|
1575
|
+
cols: [],
|
1576
|
+
rows: [],
|
1577
|
+
dataClass: opts.dataClass
|
1578
|
+
};
|
1579
|
+
numInputsToProcess = (ref4 = opts.aggregators[aggregator.val()]([])().numInputs) != null ? ref4 : 0;
|
1580
|
+
vals = [];
|
1581
|
+
_this.find(".pvtRows li span.pvtAttr").each(function() {
|
1582
|
+
return subopts.rows.push($(this).data("attrName"));
|
1583
|
+
});
|
1584
|
+
_this.find(".pvtCols li span.pvtAttr").each(function() {
|
1585
|
+
return subopts.cols.push($(this).data("attrName"));
|
1586
|
+
});
|
1587
|
+
_this.find(".pvtVals select.pvtAttrDropdown").each(function() {
|
1588
|
+
if (numInputsToProcess === 0) {
|
1589
|
+
return $(this).remove();
|
1590
|
+
} else {
|
1591
|
+
numInputsToProcess--;
|
1592
|
+
if ($(this).val() !== "") {
|
1593
|
+
return vals.push($(this).val());
|
1594
|
+
}
|
1592
1595
|
}
|
1593
|
-
}
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1596
|
+
});
|
1597
|
+
if (numInputsToProcess !== 0) {
|
1598
|
+
pvtVals = _this.find(".pvtVals");
|
1599
|
+
for (x = t = 0, ref5 = numInputsToProcess; 0 <= ref5 ? t < ref5 : t > ref5; x = 0 <= ref5 ? ++t : --t) {
|
1600
|
+
newDropdown = $("<select>").addClass('pvtAttrDropdown').append($("<option>")).bind("change", function() {
|
1601
|
+
return refresh();
|
1602
|
+
});
|
1603
|
+
for (u = 0, len4 = shownInAggregators.length; u < len4; u++) {
|
1604
|
+
attr = shownInAggregators[u];
|
1605
|
+
newDropdown.append($("<option>").val(attr).text(attr));
|
1606
|
+
}
|
1607
|
+
pvtVals.append(newDropdown);
|
1604
1608
|
}
|
1605
|
-
pvtVals.append(newDropdown);
|
1606
1609
|
}
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
initialRender = false;
|
1616
|
-
}
|
1617
|
-
subopts.aggregatorName = aggregator.val();
|
1618
|
-
subopts.vals = vals;
|
1619
|
-
subopts.aggregator = opts.aggregators[aggregator.val()](vals);
|
1620
|
-
subopts.renderer = opts.renderers[renderer.val()];
|
1621
|
-
subopts.rowOrder = rowOrderArrow.data("order");
|
1622
|
-
subopts.colOrder = colOrderArrow.data("order");
|
1623
|
-
exclusions = {};
|
1624
|
-
_this.find('input.pvtFilter').not(':checked').each(function() {
|
1625
|
-
var filter;
|
1626
|
-
filter = $(this).data("filter");
|
1627
|
-
if (exclusions[filter[0]] != null) {
|
1628
|
-
return exclusions[filter[0]].push(filter[1]);
|
1629
|
-
} else {
|
1630
|
-
return exclusions[filter[0]] = [filter[1]];
|
1610
|
+
if (initialRender) {
|
1611
|
+
vals = opts.vals;
|
1612
|
+
i = 0;
|
1613
|
+
_this.find(".pvtVals select.pvtAttrDropdown").each(function() {
|
1614
|
+
$(this).val(vals[i]);
|
1615
|
+
return i++;
|
1616
|
+
});
|
1617
|
+
initialRender = false;
|
1631
1618
|
}
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1619
|
+
subopts.aggregatorName = aggregator.val();
|
1620
|
+
subopts.vals = vals;
|
1621
|
+
subopts.aggregator = opts.aggregators[aggregator.val()](vals);
|
1622
|
+
subopts.renderer = opts.renderers[renderer.val()];
|
1623
|
+
subopts.rowOrder = rowOrderArrow.data("order");
|
1624
|
+
subopts.colOrder = colOrderArrow.data("order");
|
1625
|
+
exclusions = {};
|
1626
|
+
_this.find('input.pvtFilter').not(':checked').each(function() {
|
1627
|
+
var filter;
|
1628
|
+
filter = $(this).data("filter");
|
1629
|
+
if (exclusions[filter[0]] != null) {
|
1630
|
+
return exclusions[filter[0]].push(filter[1]);
|
1640
1631
|
} else {
|
1641
|
-
return
|
1632
|
+
return exclusions[filter[0]] = [filter[1]];
|
1642
1633
|
}
|
1643
|
-
}
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1634
|
+
});
|
1635
|
+
inclusions = {};
|
1636
|
+
_this.find('input.pvtFilter:checked').each(function() {
|
1637
|
+
var filter;
|
1638
|
+
filter = $(this).data("filter");
|
1639
|
+
if (exclusions[filter[0]] != null) {
|
1640
|
+
if (inclusions[filter[0]] != null) {
|
1641
|
+
return inclusions[filter[0]].push(filter[1]);
|
1642
|
+
} else {
|
1643
|
+
return inclusions[filter[0]] = [filter[1]];
|
1644
|
+
}
|
1645
|
+
}
|
1646
|
+
});
|
1647
|
+
subopts.filter = function(record) {
|
1648
|
+
var excludedItems, k, ref6, ref7;
|
1649
|
+
if (!opts.filter(record)) {
|
1653
1650
|
return false;
|
1654
1651
|
}
|
1652
|
+
for (k in exclusions) {
|
1653
|
+
excludedItems = exclusions[k];
|
1654
|
+
if (ref6 = "" + ((ref7 = record[k]) != null ? ref7 : 'null'), indexOf.call(excludedItems, ref6) >= 0) {
|
1655
|
+
return false;
|
1656
|
+
}
|
1657
|
+
}
|
1658
|
+
return true;
|
1659
|
+
};
|
1660
|
+
pivotTable.pivot(materializedInput, subopts);
|
1661
|
+
pivotUIOptions = $.extend({}, opts, {
|
1662
|
+
cols: subopts.cols,
|
1663
|
+
rows: subopts.rows,
|
1664
|
+
colOrder: subopts.colOrder,
|
1665
|
+
rowOrder: subopts.rowOrder,
|
1666
|
+
vals: vals,
|
1667
|
+
exclusions: exclusions,
|
1668
|
+
inclusions: inclusions,
|
1669
|
+
inclusionsInfo: inclusions,
|
1670
|
+
aggregatorName: aggregator.val(),
|
1671
|
+
rendererName: renderer.val()
|
1672
|
+
});
|
1673
|
+
_this.data("pivotUIOptions", pivotUIOptions);
|
1674
|
+
if (opts.autoSortUnusedAttrs) {
|
1675
|
+
unusedAttrsContainer = _this.find("td.pvtUnused.pvtAxisContainer");
|
1676
|
+
$(unusedAttrsContainer).children("li").sort(function(a, b) {
|
1677
|
+
return naturalSort($(a).text(), $(b).text());
|
1678
|
+
}).appendTo(unusedAttrsContainer);
|
1679
|
+
}
|
1680
|
+
pivotTable.css("opacity", 1);
|
1681
|
+
if (opts.onRefresh != null) {
|
1682
|
+
return opts.onRefresh(pivotUIOptions);
|
1655
1683
|
}
|
1656
|
-
return true;
|
1657
1684
|
};
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1670
|
-
|
1671
|
-
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
refresh = (function(_this) {
|
1685
|
-
return function() {
|
1686
|
-
pivotTable.css("opacity", 0.5);
|
1687
|
-
return setTimeout(refreshDelayed, 10);
|
1688
|
-
};
|
1689
|
-
})(this);
|
1690
|
-
refresh();
|
1691
|
-
this.find(".pvtAxisContainer").sortable({
|
1692
|
-
update: function(e, ui) {
|
1693
|
-
if (ui.sender == null) {
|
1694
|
-
return refresh();
|
1695
|
-
}
|
1696
|
-
},
|
1697
|
-
connectWith: this.find(".pvtAxisContainer"),
|
1698
|
-
items: 'li',
|
1699
|
-
placeholder: 'pvtPlaceholder'
|
1700
|
-
});
|
1701
|
-
} catch (error) {
|
1702
|
-
e = error;
|
1703
|
-
if (typeof console !== "undefined" && console !== null) {
|
1704
|
-
console.error(e.stack);
|
1685
|
+
})(this);
|
1686
|
+
refresh = (function(_this) {
|
1687
|
+
return function() {
|
1688
|
+
pivotTable.css("opacity", 0.5);
|
1689
|
+
return setTimeout(refreshDelayed, 10);
|
1690
|
+
};
|
1691
|
+
})(this);
|
1692
|
+
refresh();
|
1693
|
+
this.find(".pvtAxisContainer").sortable({
|
1694
|
+
update: function(e, ui) {
|
1695
|
+
if (ui.sender == null) {
|
1696
|
+
return refresh();
|
1697
|
+
}
|
1698
|
+
},
|
1699
|
+
connectWith: this.find(".pvtAxisContainer"),
|
1700
|
+
items: 'li',
|
1701
|
+
placeholder: 'pvtPlaceholder'
|
1702
|
+
});
|
1703
|
+
} catch (error) {
|
1704
|
+
e = error;
|
1705
|
+
if (typeof console !== "undefined" && console !== null) {
|
1706
|
+
console.error(e.stack);
|
1707
|
+
}
|
1708
|
+
// This function is not used internally or in webclient_angular/export_widget_service
|
1709
|
+
// TODO if it not removed in DR-39041, upgrade the error propagation
|
1710
|
+
this.html("An error occurred rendering the PivotTable UI.");
|
1705
1711
|
}
|
1706
|
-
|
1707
|
-
// TODO if it not removed in DR-39041, upgrade the error propagation
|
1708
|
-
this.html("An error occurred rendering the PivotTable UI.");
|
1712
|
+
return this;
|
1709
1713
|
}
|
1710
|
-
return this;
|
1711
1714
|
};
|
1712
1715
|
|
1713
1716
|
/*
|