@datarailsshared/dr_renderer 1.3.57 → 1.4.5

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/src/pivottable.js CHANGED
@@ -1,4 +1,5 @@
1
1
  const helpers = require('./dr-renderer-helpers');
2
+ const { GenericRenderingError, GenericComputationalError} = require('./errors');
2
3
 
3
4
  // from pivottable@2.23.0
4
5
  let initPivotTable = function($, window, document) {
@@ -9,7 +10,7 @@ let initPivotTable = function($, window, document) {
9
10
  /*
10
11
  Utilities
11
12
  */
12
- var PivotData, addSeparators, aggregatorTemplates, aggregators, dayNamesEn, derivers, getSort, locales, mthNamesEn, naturalSort, numberFormat, pivotTableRenderer, rd, renderers, rx, rz, sortAs, usFmt, usFmtInt, usFmtPct, zeroPad, errorHandling;
13
+ var PivotData, addSeparators, aggregatorTemplates, aggregators, dayNamesEn, derivers, getSort, locales, mthNamesEn, naturalSort, numberFormat, pivotTableRenderer, rd, renderers, rx, rz, sortAs, usFmt, usFmtInt, usFmtPct, zeroPad;
13
14
  addSeparators = function(nStr, thousandsSep, decimalSep) {
14
15
  var rgx, x, x1, x2;
15
16
  nStr += '';
@@ -434,9 +435,6 @@ let initPivotTable = function($, window, document) {
434
435
  aggregators: aggregators,
435
436
  renderers: renderers,
436
437
  localeStrings: {
437
- renderError: "An error occurred rendering the PivotTable results.",
438
- computeError: "An error occurred computing the PivotTable results.",
439
- uiRenderError: "An error occurred rendering the PivotTable UI.",
440
438
  selectAll: "Select All",
441
439
  selectNone: "Select None",
442
440
  tooMany: "(too many to list)",
@@ -614,47 +612,6 @@ let initPivotTable = function($, window, document) {
614
612
  }
615
613
  return naturalSort;
616
614
  };
617
- errorHandling = {
618
- placeholders: {
619
- nodata: {
620
- title: 'No Data Available',
621
- text: 'This might happen because of a global filter or a change in the underlying data',
622
- btnText: '',
623
- class: 'nodata',
624
- },
625
- noPermission: {
626
- title: 'No Permission',
627
- text: 'You do not have permission to view the data',
628
- btnText: 'Request Permission',
629
- class: 'no-permission',
630
- },
631
- tooMuchData: {
632
- title: 'There is too much data. Please edit this widget',
633
- text: '',
634
- btnText: 'Edit Widget',
635
- class: 'too-much-data',
636
- },
637
- noPublishItem: {
638
- title: 'We can’t find the published item in the source file',
639
- text: '',
640
- btnText: 'Go to filebox',
641
- class: 'no-publish-item',
642
- },
643
- },
644
- getErrorPlaceholder: function(placeholder) {
645
- if (placeholder && typeof placeholder === 'object') {
646
- return $(`
647
- <div class="noData">
648
- <div class="noData-title">${placeholder.title}</div>
649
- <i class="noData-image ${placeholder.class}"></i>
650
- <div class="noData-text">${placeholder.text}</div>
651
- <div class="noData-error-action"></div>
652
- </div>
653
- `);
654
- }
655
- return null;
656
- },
657
- };
658
615
 
659
616
  /*
660
617
  Data Model class
@@ -684,6 +641,7 @@ let initPivotTable = function($, window, document) {
684
641
  this.filter = (ref9 = opts.filter) != null ? ref9 : (function() {
685
642
  return true;
686
643
  });
644
+ this.isSmartQueriesEnabled = opts.rendererOptions?.chartOptions?.isSmartQueriesEnabled || false;
687
645
  this.tree = {};
688
646
 
689
647
  this.isKeysSortingDoneOnBackendSide = opts.keysObject && typeof opts.keysObject === 'object' && helpers.backendSortingKeysAreNotEmpty(opts.keysObject);
@@ -708,11 +666,12 @@ let initPivotTable = function($, window, document) {
708
666
  this.getFormattedColKeys = (keys) => opts.getFormattedColKeys(this, keys);
709
667
  this.getFormattedRowKeys = (keys) => opts.getFormattedRowKeys(this, keys);
710
668
  this.isDrillDownDisabled = opts.isDrillDownDisabled;
669
+ this.pivotUiFnRemoved = opts.pivotUiFnRemoved;
711
670
 
712
671
  PivotData.forEachRecord(this.input, this.derivedAttributes, (function(_this) {
713
672
  return function(record) {
714
673
  if (_this.filter(record)) {
715
- return _this.processRecord(record);
674
+ return _this.processRecord(record, _this.isSmartQueriesEnabled);
716
675
  }
717
676
  };
718
677
  })(this));
@@ -964,7 +923,6 @@ let initPivotTable = function($, window, document) {
964
923
  numberFormat: numberFormat,
965
924
  sortAs: sortAs,
966
925
  PivotData: PivotData,
967
- errorHandling: errorHandling,
968
926
  };
969
927
  if (window.$) {
970
928
  window.$.pivotUtilities = $.pivotUtilities
@@ -1229,24 +1187,23 @@ let initPivotTable = function($, window, document) {
1229
1187
  localeStrings: localeStrings
1230
1188
  };
1231
1189
  opts = $.extend(true, {}, localeDefaults, $.extend({}, defaults, inputOpts));
1232
- result = null;
1233
1190
  try {
1234
1191
  pivotData = new opts.dataClass(input, opts);
1235
1192
  try {
1236
1193
  result = opts.renderer(pivotData, opts.rendererOptions);
1237
1194
  } catch (error) {
1238
- e = error;
1239
- if (typeof console !== "undefined" && console !== null) {
1240
- console.error(e.stack);
1241
- }
1242
- result = $("<span>").html(opts.localeStrings.renderError);
1195
+ const genericRenderingError = new GenericRenderingError();
1196
+ console.error(genericRenderingError.title);
1197
+ throw genericRenderingError;
1243
1198
  }
1244
1199
  } catch (error) {
1245
- e = error;
1246
- if (typeof console !== "undefined" && console !== null) {
1247
- console.error(e.stack);
1200
+ if (error instanceof GenericRenderingError) {
1201
+ throw error;
1202
+ } else {
1203
+ const genericComputationalError = new GenericComputationalError();
1204
+ console.error(genericComputationalError.title);
1205
+ throw genericComputationalError;
1248
1206
  }
1249
- result = $("<span>").html(opts.localeStrings.computeError);
1250
1207
  }
1251
1208
  x = this[0];
1252
1209
  while (x.hasChildNodes()) {
@@ -1259,498 +1216,502 @@ let initPivotTable = function($, window, document) {
1259
1216
  Pivot Table UI: calls Pivot Table core above with options set by user
1260
1217
  */
1261
1218
  $.fn.pivotUI = function(input, inputOpts, overwrite, locale) {
1262
- 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;
1263
- if (overwrite == null) {
1264
- overwrite = false;
1265
- }
1266
- if (locale == null) {
1267
- locale = "en";
1268
- }
1269
- if (locales[locale] == null) {
1270
- locale = "en";
1271
- }
1272
- defaults = {
1273
- derivedAttributes: {},
1274
- aggregators: locales[locale].aggregators,
1275
- renderers: locales[locale].renderers,
1276
- hiddenAttributes: [],
1277
- hiddenFromAggregators: [],
1278
- hiddenFromDragDrop: [],
1279
- menuLimit: 500,
1280
- cols: [],
1281
- rows: [],
1282
- vals: [],
1283
- rowOrder: "key_a_to_z",
1284
- colOrder: "key_a_to_z",
1285
- dataClass: PivotData,
1286
- exclusions: {},
1287
- inclusions: {},
1288
- unusedAttrsVertical: 85,
1289
- autoSortUnusedAttrs: false,
1290
- onRefresh: null,
1291
- showUI: true,
1292
- filter: function() {
1293
- return true;
1294
- },
1295
- sorters: {}
1296
- };
1297
- localeStrings = $.extend(true, {}, locales.en.localeStrings, locales[locale].localeStrings);
1298
- localeDefaults = {
1299
- rendererOptions: {
1219
+ if (!this.pivotUiFnRemoved) {
1220
+ 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;
1221
+ if (overwrite == null) {
1222
+ overwrite = false;
1223
+ }
1224
+ if (locale == null) {
1225
+ locale = "en";
1226
+ }
1227
+ if (locales[locale] == null) {
1228
+ locale = "en";
1229
+ }
1230
+ defaults = {
1231
+ derivedAttributes: {},
1232
+ aggregators: locales[locale].aggregators,
1233
+ renderers: locales[locale].renderers,
1234
+ hiddenAttributes: [],
1235
+ hiddenFromAggregators: [],
1236
+ hiddenFromDragDrop: [],
1237
+ menuLimit: 500,
1238
+ cols: [],
1239
+ rows: [],
1240
+ vals: [],
1241
+ rowOrder: "key_a_to_z",
1242
+ colOrder: "key_a_to_z",
1243
+ dataClass: PivotData,
1244
+ exclusions: {},
1245
+ inclusions: {},
1246
+ unusedAttrsVertical: 85,
1247
+ autoSortUnusedAttrs: false,
1248
+ onRefresh: null,
1249
+ showUI: true,
1250
+ filter: function() {
1251
+ return true;
1252
+ },
1253
+ sorters: {}
1254
+ };
1255
+ localeStrings = $.extend(true, {}, locales.en.localeStrings, locales[locale].localeStrings);
1256
+ localeDefaults = {
1257
+ rendererOptions: {
1258
+ localeStrings: localeStrings
1259
+ },
1300
1260
  localeStrings: localeStrings
1301
- },
1302
- localeStrings: localeStrings
1303
- };
1304
- existingOpts = this.data("pivotUIOptions");
1305
- if ((existingOpts == null) || overwrite) {
1306
- opts = $.extend(true, {}, localeDefaults, $.extend({}, defaults, inputOpts));
1307
- } else {
1308
- opts = existingOpts;
1309
- }
1310
- try {
1311
- attrValues = {};
1312
- materializedInput = [];
1313
- recordsProcessed = 0;
1314
- PivotData.forEachRecord(input, opts.derivedAttributes, function(record) {
1315
- var attr, base, ref, value;
1316
- if (!opts.filter(record)) {
1317
- return;
1318
- }
1319
- materializedInput.push(record);
1320
- for (attr in record) {
1321
- if (!hasProp.call(record, attr)) continue;
1322
- if (attrValues[attr] == null) {
1323
- attrValues[attr] = {};
1324
- if (recordsProcessed > 0) {
1325
- attrValues[attr]["null"] = recordsProcessed;
1326
- }
1261
+ };
1262
+ existingOpts = this.data("pivotUIOptions");
1263
+ if ((existingOpts == null) || overwrite) {
1264
+ opts = $.extend(true, {}, localeDefaults, $.extend({}, defaults, inputOpts));
1265
+ } else {
1266
+ opts = existingOpts;
1267
+ }
1268
+ try {
1269
+ attrValues = {};
1270
+ materializedInput = [];
1271
+ recordsProcessed = 0;
1272
+ PivotData.forEachRecord(input, opts.derivedAttributes, function(record) {
1273
+ var attr, base, ref, value;
1274
+ if (!opts.filter(record)) {
1275
+ return;
1327
1276
  }
1328
- }
1329
- for (attr in attrValues) {
1330
- value = (ref = record[attr]) != null ? ref : "null";
1331
- if ((base = attrValues[attr])[value] == null) {
1332
- base[value] = 0;
1277
+ materializedInput.push(record);
1278
+ for (attr in record) {
1279
+ if (!hasProp.call(record, attr)) continue;
1280
+ if (attrValues[attr] == null) {
1281
+ attrValues[attr] = {};
1282
+ if (recordsProcessed > 0) {
1283
+ attrValues[attr]["null"] = recordsProcessed;
1284
+ }
1285
+ }
1333
1286
  }
1334
- attrValues[attr][value]++;
1335
- }
1336
- return recordsProcessed++;
1337
- });
1338
- uiTable = $("<table>", {
1339
- "class": "pvtUi"
1340
- }).attr("cellpadding", 5);
1341
- rendererControl = $("<td>").addClass("pvtUiCell");
1342
- renderer = $("<select>").addClass('pvtRenderer').appendTo(rendererControl).bind("change", function() {
1343
- return refresh();
1344
- });
1345
- ref = opts.renderers;
1346
- for (x in ref) {
1347
- if (!hasProp.call(ref, x)) continue;
1348
- $("<option>").val(x).html(x).appendTo(renderer);
1349
- }
1350
- unused = $("<td>").addClass('pvtAxisContainer pvtUnused pvtUiCell');
1351
- shownAttributes = (function() {
1352
- var results;
1353
- results = [];
1354
- for (a in attrValues) {
1355
- if (indexOf.call(opts.hiddenAttributes, a) < 0) {
1356
- results.push(a);
1287
+ for (attr in attrValues) {
1288
+ value = (ref = record[attr]) != null ? ref : "null";
1289
+ if ((base = attrValues[attr])[value] == null) {
1290
+ base[value] = 0;
1291
+ }
1292
+ attrValues[attr][value]++;
1357
1293
  }
1294
+ return recordsProcessed++;
1295
+ });
1296
+ uiTable = $("<table>", {
1297
+ "class": "pvtUi"
1298
+ }).attr("cellpadding", 5);
1299
+ rendererControl = $("<td>").addClass("pvtUiCell");
1300
+ renderer = $("<select>").addClass('pvtRenderer').appendTo(rendererControl).bind("change", function() {
1301
+ return refresh();
1302
+ });
1303
+ ref = opts.renderers;
1304
+ for (x in ref) {
1305
+ if (!hasProp.call(ref, x)) continue;
1306
+ $("<option>").val(x).html(x).appendTo(renderer);
1358
1307
  }
1359
- return results;
1360
- })();
1361
- shownInAggregators = (function() {
1362
- var l, len1, results;
1363
- results = [];
1364
- for (l = 0, len1 = shownAttributes.length; l < len1; l++) {
1365
- c = shownAttributes[l];
1366
- if (indexOf.call(opts.hiddenFromAggregators, c) < 0) {
1367
- results.push(c);
1308
+ unused = $("<td>").addClass('pvtAxisContainer pvtUnused pvtUiCell');
1309
+ shownAttributes = (function() {
1310
+ var results;
1311
+ results = [];
1312
+ for (a in attrValues) {
1313
+ if (indexOf.call(opts.hiddenAttributes, a) < 0) {
1314
+ results.push(a);
1315
+ }
1368
1316
  }
1369
- }
1370
- return results;
1371
- })();
1372
- shownInDragDrop = (function() {
1373
- var l, len1, results;
1374
- results = [];
1375
- for (l = 0, len1 = shownAttributes.length; l < len1; l++) {
1376
- c = shownAttributes[l];
1377
- if (indexOf.call(opts.hiddenFromDragDrop, c) < 0) {
1378
- results.push(c);
1317
+ return results;
1318
+ })();
1319
+ shownInAggregators = (function() {
1320
+ var l, len1, results;
1321
+ results = [];
1322
+ for (l = 0, len1 = shownAttributes.length; l < len1; l++) {
1323
+ c = shownAttributes[l];
1324
+ if (indexOf.call(opts.hiddenFromAggregators, c) < 0) {
1325
+ results.push(c);
1326
+ }
1379
1327
  }
1380
- }
1381
- return results;
1382
- })();
1383
- unusedAttrsVerticalAutoOverride = false;
1384
- if (opts.unusedAttrsVertical === "auto") {
1385
- unusedAttrsVerticalAutoCutoff = 120;
1386
- } else {
1387
- unusedAttrsVerticalAutoCutoff = parseInt(opts.unusedAttrsVertical);
1388
- }
1389
- if (!isNaN(unusedAttrsVerticalAutoCutoff)) {
1390
- attrLength = 0;
1391
- for (l = 0, len1 = shownInDragDrop.length; l < len1; l++) {
1392
- a = shownInDragDrop[l];
1393
- attrLength += a.length;
1394
- }
1395
- unusedAttrsVerticalAutoOverride = attrLength > unusedAttrsVerticalAutoCutoff;
1396
- }
1397
- if (opts.unusedAttrsVertical === true || unusedAttrsVerticalAutoOverride) {
1398
- unused.addClass('pvtVertList');
1399
- } else {
1400
- unused.addClass('pvtHorizList');
1401
- }
1402
- fn1 = function(attr) {
1403
- var attrElem, checkContainer, closeFilterBox, controls, filterItem, filterItemExcluded, finalButtons, hasExcludedItem, len2, n, placeholder, ref1, sorter, triangleLink, v, value, valueCount, valueList, values;
1404
- values = (function() {
1405
- var results;
1328
+ return results;
1329
+ })();
1330
+ shownInDragDrop = (function() {
1331
+ var l, len1, results;
1406
1332
  results = [];
1407
- for (v in attrValues[attr]) {
1408
- results.push(v);
1333
+ for (l = 0, len1 = shownAttributes.length; l < len1; l++) {
1334
+ c = shownAttributes[l];
1335
+ if (indexOf.call(opts.hiddenFromDragDrop, c) < 0) {
1336
+ results.push(c);
1337
+ }
1409
1338
  }
1410
1339
  return results;
1411
1340
  })();
1412
- hasExcludedItem = false;
1413
- valueList = $("<div>").addClass('pvtFilterBox').hide();
1414
- valueList.append($("<h4>").append($("<span>").text(attr), $("<span>").addClass("count").text("(" + values.length + ")")));
1415
- if (values.length > opts.menuLimit) {
1416
- valueList.append($("<p>").html(opts.localeStrings.tooMany));
1341
+ unusedAttrsVerticalAutoOverride = false;
1342
+ if (opts.unusedAttrsVertical === "auto") {
1343
+ unusedAttrsVerticalAutoCutoff = 120;
1417
1344
  } else {
1418
- if (values.length > 5) {
1419
- controls = $("<p>").appendTo(valueList);
1420
- sorter = getSort(opts.sorters, attr);
1421
- placeholder = opts.localeStrings.filterResults;
1422
- $("<input>", {
1423
- type: "text"
1424
- }).appendTo(controls).attr({
1425
- placeholder: placeholder,
1426
- "class": "pvtSearch"
1427
- }).bind("keyup", function() {
1428
- var accept, accept_gen, filter;
1429
- filter = $(this).val().toLowerCase().trim();
1430
- accept_gen = function(prefix, accepted) {
1431
- return function(v) {
1432
- var real_filter, ref1;
1433
- real_filter = filter.substring(prefix.length).trim();
1434
- if (real_filter.length === 0) {
1345
+ unusedAttrsVerticalAutoCutoff = parseInt(opts.unusedAttrsVertical);
1346
+ }
1347
+ if (!isNaN(unusedAttrsVerticalAutoCutoff)) {
1348
+ attrLength = 0;
1349
+ for (l = 0, len1 = shownInDragDrop.length; l < len1; l++) {
1350
+ a = shownInDragDrop[l];
1351
+ attrLength += a.length;
1352
+ }
1353
+ unusedAttrsVerticalAutoOverride = attrLength > unusedAttrsVerticalAutoCutoff;
1354
+ }
1355
+ if (opts.unusedAttrsVertical === true || unusedAttrsVerticalAutoOverride) {
1356
+ unused.addClass('pvtVertList');
1357
+ } else {
1358
+ unused.addClass('pvtHorizList');
1359
+ }
1360
+ fn1 = function(attr) {
1361
+ var attrElem, checkContainer, closeFilterBox, controls, filterItem, filterItemExcluded, finalButtons, hasExcludedItem, len2, n, placeholder, ref1, sorter, triangleLink, v, value, valueCount, valueList, values;
1362
+ values = (function() {
1363
+ var results;
1364
+ results = [];
1365
+ for (v in attrValues[attr]) {
1366
+ results.push(v);
1367
+ }
1368
+ return results;
1369
+ })();
1370
+ hasExcludedItem = false;
1371
+ valueList = $("<div>").addClass('pvtFilterBox').hide();
1372
+ valueList.append($("<h4>").append($("<span>").text(attr), $("<span>").addClass("count").text("(" + values.length + ")")));
1373
+ if (values.length > opts.menuLimit) {
1374
+ valueList.append($("<p>").html(opts.localeStrings.tooMany));
1375
+ } else {
1376
+ if (values.length > 5) {
1377
+ controls = $("<p>").appendTo(valueList);
1378
+ sorter = getSort(opts.sorters, attr);
1379
+ placeholder = opts.localeStrings.filterResults;
1380
+ $("<input>", {
1381
+ type: "text"
1382
+ }).appendTo(controls).attr({
1383
+ placeholder: placeholder,
1384
+ "class": "pvtSearch"
1385
+ }).bind("keyup", function() {
1386
+ var accept, accept_gen, filter;
1387
+ filter = $(this).val().toLowerCase().trim();
1388
+ accept_gen = function(prefix, accepted) {
1389
+ return function(v) {
1390
+ var real_filter, ref1;
1391
+ real_filter = filter.substring(prefix.length).trim();
1392
+ if (real_filter.length === 0) {
1393
+ return true;
1394
+ }
1395
+ return ref1 = Math.sign(sorter(v.toLowerCase(), real_filter)), indexOf.call(accepted, ref1) >= 0;
1396
+ };
1397
+ };
1398
+ 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) {
1399
+ if (filter.substring(1).trim().length === 0) {
1435
1400
  return true;
1436
1401
  }
1437
- return ref1 = Math.sign(sorter(v.toLowerCase(), real_filter)), indexOf.call(accepted, ref1) >= 0;
1402
+ return v.toLowerCase().match(filter.substring(1));
1403
+ } : function(v) {
1404
+ return v.toLowerCase().indexOf(filter) !== -1;
1438
1405
  };
1439
- };
1440
- 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) {
1441
- if (filter.substring(1).trim().length === 0) {
1442
- return true;
1443
- }
1444
- return v.toLowerCase().match(filter.substring(1));
1445
- } : function(v) {
1446
- return v.toLowerCase().indexOf(filter) !== -1;
1447
- };
1448
- return valueList.find('.pvtCheckContainer p label span.value').each(function() {
1449
- if (accept($(this).text())) {
1450
- return $(this).parent().parent().show();
1451
- } else {
1452
- return $(this).parent().parent().hide();
1453
- }
1406
+ return valueList.find('.pvtCheckContainer p label span.value').each(function() {
1407
+ if (accept($(this).text())) {
1408
+ return $(this).parent().parent().show();
1409
+ } else {
1410
+ return $(this).parent().parent().hide();
1411
+ }
1412
+ });
1454
1413
  });
1455
- });
1456
- controls.append($("<br>"));
1457
- $("<button>", {
1458
- type: "button"
1459
- }).appendTo(controls).html(opts.localeStrings.selectAll).bind("click", function() {
1460
- valueList.find("input:visible:not(:checked)").prop("checked", true).toggleClass("changed");
1461
- return false;
1462
- });
1463
- $("<button>", {
1464
- type: "button"
1465
- }).appendTo(controls).html(opts.localeStrings.selectNone).bind("click", function() {
1466
- valueList.find("input:visible:checked").prop("checked", false).toggleClass("changed");
1467
- return false;
1468
- });
1414
+ controls.append($("<br>"));
1415
+ $("<button>", {
1416
+ type: "button"
1417
+ }).appendTo(controls).html(opts.localeStrings.selectAll).bind("click", function() {
1418
+ valueList.find("input:visible:not(:checked)").prop("checked", true).toggleClass("changed");
1419
+ return false;
1420
+ });
1421
+ $("<button>", {
1422
+ type: "button"
1423
+ }).appendTo(controls).html(opts.localeStrings.selectNone).bind("click", function() {
1424
+ valueList.find("input:visible:checked").prop("checked", false).toggleClass("changed");
1425
+ return false;
1426
+ });
1427
+ }
1428
+ checkContainer = $("<div>").addClass("pvtCheckContainer").appendTo(valueList);
1429
+ ref1 = values.sort(getSort(opts.sorters, attr));
1430
+ for (n = 0, len2 = ref1.length; n < len2; n++) {
1431
+ value = ref1[n];
1432
+ valueCount = attrValues[attr][value];
1433
+ filterItem = $("<label>");
1434
+ filterItemExcluded = false;
1435
+ if (opts.inclusions[attr]) {
1436
+ filterItemExcluded = (indexOf.call(opts.inclusions[attr], value) < 0);
1437
+ } else if (opts.exclusions[attr]) {
1438
+ filterItemExcluded = (indexOf.call(opts.exclusions[attr], value) >= 0);
1439
+ }
1440
+ hasExcludedItem || (hasExcludedItem = filterItemExcluded);
1441
+ $("<input>").attr("type", "checkbox").addClass('pvtFilter').attr("checked", !filterItemExcluded).data("filter", [attr, value]).appendTo(filterItem).bind("change", function() {
1442
+ return $(this).toggleClass("changed");
1443
+ });
1444
+ filterItem.append($("<span>").addClass("value").text(value));
1445
+ filterItem.append($("<span>").addClass("count").text("(" + valueCount + ")"));
1446
+ checkContainer.append($("<p>").append(filterItem));
1447
+ }
1469
1448
  }
1470
- checkContainer = $("<div>").addClass("pvtCheckContainer").appendTo(valueList);
1471
- ref1 = values.sort(getSort(opts.sorters, attr));
1472
- for (n = 0, len2 = ref1.length; n < len2; n++) {
1473
- value = ref1[n];
1474
- valueCount = attrValues[attr][value];
1475
- filterItem = $("<label>");
1476
- filterItemExcluded = false;
1477
- if (opts.inclusions[attr]) {
1478
- filterItemExcluded = (indexOf.call(opts.inclusions[attr], value) < 0);
1479
- } else if (opts.exclusions[attr]) {
1480
- filterItemExcluded = (indexOf.call(opts.exclusions[attr], value) >= 0);
1449
+ closeFilterBox = function() {
1450
+ if (valueList.find("[type='checkbox']").length > valueList.find("[type='checkbox']:checked").length) {
1451
+ attrElem.addClass("pvtFilteredAttribute");
1452
+ } else {
1453
+ attrElem.removeClass("pvtFilteredAttribute");
1481
1454
  }
1482
- hasExcludedItem || (hasExcludedItem = filterItemExcluded);
1483
- $("<input>").attr("type", "checkbox").addClass('pvtFilter').attr("checked", !filterItemExcluded).data("filter", [attr, value]).appendTo(filterItem).bind("change", function() {
1484
- return $(this).toggleClass("changed");
1455
+ valueList.find('.pvtSearch').val('');
1456
+ valueList.find('.pvtCheckContainer p').show();
1457
+ return valueList.hide();
1458
+ };
1459
+ finalButtons = $("<p>").appendTo(valueList);
1460
+ if (values.length <= opts.menuLimit) {
1461
+ $("<button>", {
1462
+ type: "button"
1463
+ }).text(opts.localeStrings.apply).appendTo(finalButtons).bind("click", function() {
1464
+ if (valueList.find(".changed").removeClass("changed").length) {
1465
+ refresh();
1466
+ }
1467
+ return closeFilterBox();
1485
1468
  });
1486
- filterItem.append($("<span>").addClass("value").text(value));
1487
- filterItem.append($("<span>").addClass("count").text("(" + valueCount + ")"));
1488
- checkContainer.append($("<p>").append(filterItem));
1489
1469
  }
1490
- }
1491
- closeFilterBox = function() {
1492
- if (valueList.find("[type='checkbox']").length > valueList.find("[type='checkbox']:checked").length) {
1493
- attrElem.addClass("pvtFilteredAttribute");
1494
- } else {
1495
- attrElem.removeClass("pvtFilteredAttribute");
1496
- }
1497
- valueList.find('.pvtSearch').val('');
1498
- valueList.find('.pvtCheckContainer p').show();
1499
- return valueList.hide();
1500
- };
1501
- finalButtons = $("<p>").appendTo(valueList);
1502
- if (values.length <= opts.menuLimit) {
1503
1470
  $("<button>", {
1504
1471
  type: "button"
1505
- }).text(opts.localeStrings.apply).appendTo(finalButtons).bind("click", function() {
1506
- if (valueList.find(".changed").removeClass("changed").length) {
1507
- refresh();
1508
- }
1472
+ }).text(opts.localeStrings.cancel).appendTo(finalButtons).bind("click", function() {
1473
+ valueList.find(".changed:checked").removeClass("changed").prop("checked", false);
1474
+ valueList.find(".changed:not(:checked)").removeClass("changed").prop("checked", true);
1509
1475
  return closeFilterBox();
1510
1476
  });
1477
+ triangleLink = $("<span>").addClass('pvtTriangle').html(" &#x25BE;").bind("click", function(e) {
1478
+ var left, ref2, top;
1479
+ ref2 = $(e.currentTarget).position(), left = ref2.left, top = ref2.top;
1480
+ return valueList.css({
1481
+ left: left + 10,
1482
+ top: top + 10
1483
+ }).show();
1484
+ });
1485
+ attrElem = $("<li>").addClass("axis_" + i).append($("<span>").addClass('pvtAttr').text(attr).data("attrName", attr).append(triangleLink));
1486
+ if (hasExcludedItem) {
1487
+ attrElem.addClass('pvtFilteredAttribute');
1488
+ }
1489
+ return unused.append(attrElem).append(valueList);
1490
+ };
1491
+ for (i in shownInDragDrop) {
1492
+ if (!hasProp.call(shownInDragDrop, i)) continue;
1493
+ attr = shownInDragDrop[i];
1494
+ fn1(attr);
1511
1495
  }
1512
- $("<button>", {
1513
- type: "button"
1514
- }).text(opts.localeStrings.cancel).appendTo(finalButtons).bind("click", function() {
1515
- valueList.find(".changed:checked").removeClass("changed").prop("checked", false);
1516
- valueList.find(".changed:not(:checked)").removeClass("changed").prop("checked", true);
1517
- return closeFilterBox();
1496
+ tr1 = $("<tr>").appendTo(uiTable);
1497
+ aggregator = $("<select>").addClass('pvtAggregator').bind("change", function() {
1498
+ return refresh();
1518
1499
  });
1519
- triangleLink = $("<span>").addClass('pvtTriangle').html(" &#x25BE;").bind("click", function(e) {
1520
- var left, ref2, top;
1521
- ref2 = $(e.currentTarget).position(), left = ref2.left, top = ref2.top;
1522
- return valueList.css({
1523
- left: left + 10,
1524
- top: top + 10
1525
- }).show();
1500
+ ref1 = opts.aggregators;
1501
+ for (x in ref1) {
1502
+ if (!hasProp.call(ref1, x)) continue;
1503
+ aggregator.append($("<option>").val(x).html(x));
1504
+ }
1505
+ ordering = {
1506
+ key_a_to_z: {
1507
+ rowSymbol: "&varr;",
1508
+ colSymbol: "&harr;",
1509
+ next: "value_a_to_z"
1510
+ },
1511
+ value_a_to_z: {
1512
+ rowSymbol: "&darr;",
1513
+ colSymbol: "&rarr;",
1514
+ next: "value_z_to_a"
1515
+ },
1516
+ value_z_to_a: {
1517
+ rowSymbol: "&uarr;",
1518
+ colSymbol: "&larr;",
1519
+ next: "key_a_to_z"
1520
+ }
1521
+ };
1522
+ rowOrderArrow = $("<a>", {
1523
+ role: "button"
1524
+ }).addClass("pvtRowOrder").data("order", opts.rowOrder).html(ordering[opts.rowOrder].rowSymbol).bind("click", function() {
1525
+ $(this).data("order", ordering[$(this).data("order")].next);
1526
+ $(this).html(ordering[$(this).data("order")].rowSymbol);
1527
+ return refresh();
1528
+ });
1529
+ colOrderArrow = $("<a>", {
1530
+ role: "button"
1531
+ }).addClass("pvtColOrder").data("order", opts.colOrder).html(ordering[opts.colOrder].colSymbol).bind("click", function() {
1532
+ $(this).data("order", ordering[$(this).data("order")].next);
1533
+ $(this).html(ordering[$(this).data("order")].colSymbol);
1534
+ return refresh();
1526
1535
  });
1527
- attrElem = $("<li>").addClass("axis_" + i).append($("<span>").addClass('pvtAttr').text(attr).data("attrName", attr).append(triangleLink));
1528
- if (hasExcludedItem) {
1529
- attrElem.addClass('pvtFilteredAttribute');
1536
+ $("<td>").addClass('pvtVals pvtUiCell').appendTo(tr1).append(aggregator).append(rowOrderArrow).append(colOrderArrow).append($("<br>"));
1537
+ $("<td>").addClass('pvtAxisContainer pvtHorizList pvtCols pvtUiCell').appendTo(tr1);
1538
+ tr2 = $("<tr>").appendTo(uiTable);
1539
+ tr2.append($("<td>").addClass('pvtAxisContainer pvtRows pvtUiCell').attr("valign", "top"));
1540
+ pivotTable = $("<td>").attr("valign", "top").addClass('pvtRendererArea').appendTo(tr2);
1541
+ if (opts.unusedAttrsVertical === true || unusedAttrsVerticalAutoOverride) {
1542
+ uiTable.find('tr:nth-child(1)').prepend(rendererControl);
1543
+ uiTable.find('tr:nth-child(2)').prepend(unused);
1544
+ } else {
1545
+ uiTable.prepend($("<tr>").append(rendererControl).append(unused));
1530
1546
  }
1531
- return unused.append(attrElem).append(valueList);
1532
- };
1533
- for (i in shownInDragDrop) {
1534
- if (!hasProp.call(shownInDragDrop, i)) continue;
1535
- attr = shownInDragDrop[i];
1536
- fn1(attr);
1537
- }
1538
- tr1 = $("<tr>").appendTo(uiTable);
1539
- aggregator = $("<select>").addClass('pvtAggregator').bind("change", function() {
1540
- return refresh();
1541
- });
1542
- ref1 = opts.aggregators;
1543
- for (x in ref1) {
1544
- if (!hasProp.call(ref1, x)) continue;
1545
- aggregator.append($("<option>").val(x).html(x));
1546
- }
1547
- ordering = {
1548
- key_a_to_z: {
1549
- rowSymbol: "&varr;",
1550
- colSymbol: "&harr;",
1551
- next: "value_a_to_z"
1552
- },
1553
- value_a_to_z: {
1554
- rowSymbol: "&darr;",
1555
- colSymbol: "&rarr;",
1556
- next: "value_z_to_a"
1557
- },
1558
- value_z_to_a: {
1559
- rowSymbol: "&uarr;",
1560
- colSymbol: "&larr;",
1561
- next: "key_a_to_z"
1547
+ this.html(uiTable);
1548
+ ref2 = opts.cols;
1549
+ for (n = 0, len2 = ref2.length; n < len2; n++) {
1550
+ x = ref2[n];
1551
+ this.find(".pvtCols").append(this.find(".axis_" + ($.inArray(x, shownInDragDrop))));
1562
1552
  }
1563
- };
1564
- rowOrderArrow = $("<a>", {
1565
- role: "button"
1566
- }).addClass("pvtRowOrder").data("order", opts.rowOrder).html(ordering[opts.rowOrder].rowSymbol).bind("click", function() {
1567
- $(this).data("order", ordering[$(this).data("order")].next);
1568
- $(this).html(ordering[$(this).data("order")].rowSymbol);
1569
- return refresh();
1570
- });
1571
- colOrderArrow = $("<a>", {
1572
- role: "button"
1573
- }).addClass("pvtColOrder").data("order", opts.colOrder).html(ordering[opts.colOrder].colSymbol).bind("click", function() {
1574
- $(this).data("order", ordering[$(this).data("order")].next);
1575
- $(this).html(ordering[$(this).data("order")].colSymbol);
1576
- return refresh();
1577
- });
1578
- $("<td>").addClass('pvtVals pvtUiCell').appendTo(tr1).append(aggregator).append(rowOrderArrow).append(colOrderArrow).append($("<br>"));
1579
- $("<td>").addClass('pvtAxisContainer pvtHorizList pvtCols pvtUiCell').appendTo(tr1);
1580
- tr2 = $("<tr>").appendTo(uiTable);
1581
- tr2.append($("<td>").addClass('pvtAxisContainer pvtRows pvtUiCell').attr("valign", "top"));
1582
- pivotTable = $("<td>").attr("valign", "top").addClass('pvtRendererArea').appendTo(tr2);
1583
- if (opts.unusedAttrsVertical === true || unusedAttrsVerticalAutoOverride) {
1584
- uiTable.find('tr:nth-child(1)').prepend(rendererControl);
1585
- uiTable.find('tr:nth-child(2)').prepend(unused);
1586
- } else {
1587
- uiTable.prepend($("<tr>").append(rendererControl).append(unused));
1588
- }
1589
- this.html(uiTable);
1590
- ref2 = opts.cols;
1591
- for (n = 0, len2 = ref2.length; n < len2; n++) {
1592
- x = ref2[n];
1593
- this.find(".pvtCols").append(this.find(".axis_" + ($.inArray(x, shownInDragDrop))));
1594
- }
1595
- ref3 = opts.rows;
1596
- for (o = 0, len3 = ref3.length; o < len3; o++) {
1597
- x = ref3[o];
1598
- this.find(".pvtRows").append(this.find(".axis_" + ($.inArray(x, shownInDragDrop))));
1599
- }
1600
- if (opts.aggregatorName != null) {
1601
- this.find(".pvtAggregator").val(opts.aggregatorName);
1602
- }
1603
- if (opts.rendererName != null) {
1604
- this.find(".pvtRenderer").val(opts.rendererName);
1605
- }
1606
- if (!opts.showUI) {
1607
- this.find(".pvtUiCell").hide();
1608
- }
1609
- initialRender = true;
1610
- refreshDelayed = (function(_this) {
1611
- return function() {
1612
- var exclusions, inclusions, len4, newDropdown, numInputsToProcess, pivotUIOptions, pvtVals, ref4, ref5, subopts, t, u, unusedAttrsContainer, vals;
1613
- subopts = {
1614
- derivedAttributes: opts.derivedAttributes,
1615
- localeStrings: opts.localeStrings,
1616
- rendererOptions: opts.rendererOptions,
1617
- sorters: opts.sorters,
1618
- cols: [],
1619
- rows: [],
1620
- dataClass: opts.dataClass
1621
- };
1622
- numInputsToProcess = (ref4 = opts.aggregators[aggregator.val()]([])().numInputs) != null ? ref4 : 0;
1623
- vals = [];
1624
- _this.find(".pvtRows li span.pvtAttr").each(function() {
1625
- return subopts.rows.push($(this).data("attrName"));
1626
- });
1627
- _this.find(".pvtCols li span.pvtAttr").each(function() {
1628
- return subopts.cols.push($(this).data("attrName"));
1629
- });
1630
- _this.find(".pvtVals select.pvtAttrDropdown").each(function() {
1631
- if (numInputsToProcess === 0) {
1632
- return $(this).remove();
1633
- } else {
1634
- numInputsToProcess--;
1635
- if ($(this).val() !== "") {
1636
- return vals.push($(this).val());
1553
+ ref3 = opts.rows;
1554
+ for (o = 0, len3 = ref3.length; o < len3; o++) {
1555
+ x = ref3[o];
1556
+ this.find(".pvtRows").append(this.find(".axis_" + ($.inArray(x, shownInDragDrop))));
1557
+ }
1558
+ if (opts.aggregatorName != null) {
1559
+ this.find(".pvtAggregator").val(opts.aggregatorName);
1560
+ }
1561
+ if (opts.rendererName != null) {
1562
+ this.find(".pvtRenderer").val(opts.rendererName);
1563
+ }
1564
+ if (!opts.showUI) {
1565
+ this.find(".pvtUiCell").hide();
1566
+ }
1567
+ initialRender = true;
1568
+ refreshDelayed = (function(_this) {
1569
+ return function() {
1570
+ var exclusions, inclusions, len4, newDropdown, numInputsToProcess, pivotUIOptions, pvtVals, ref4, ref5, subopts, t, u, unusedAttrsContainer, vals;
1571
+ subopts = {
1572
+ derivedAttributes: opts.derivedAttributes,
1573
+ localeStrings: opts.localeStrings,
1574
+ rendererOptions: opts.rendererOptions,
1575
+ sorters: opts.sorters,
1576
+ cols: [],
1577
+ rows: [],
1578
+ dataClass: opts.dataClass
1579
+ };
1580
+ numInputsToProcess = (ref4 = opts.aggregators[aggregator.val()]([])().numInputs) != null ? ref4 : 0;
1581
+ vals = [];
1582
+ _this.find(".pvtRows li span.pvtAttr").each(function() {
1583
+ return subopts.rows.push($(this).data("attrName"));
1584
+ });
1585
+ _this.find(".pvtCols li span.pvtAttr").each(function() {
1586
+ return subopts.cols.push($(this).data("attrName"));
1587
+ });
1588
+ _this.find(".pvtVals select.pvtAttrDropdown").each(function() {
1589
+ if (numInputsToProcess === 0) {
1590
+ return $(this).remove();
1591
+ } else {
1592
+ numInputsToProcess--;
1593
+ if ($(this).val() !== "") {
1594
+ return vals.push($(this).val());
1595
+ }
1637
1596
  }
1638
- }
1639
- });
1640
- if (numInputsToProcess !== 0) {
1641
- pvtVals = _this.find(".pvtVals");
1642
- for (x = t = 0, ref5 = numInputsToProcess; 0 <= ref5 ? t < ref5 : t > ref5; x = 0 <= ref5 ? ++t : --t) {
1643
- newDropdown = $("<select>").addClass('pvtAttrDropdown').append($("<option>")).bind("change", function() {
1644
- return refresh();
1645
- });
1646
- for (u = 0, len4 = shownInAggregators.length; u < len4; u++) {
1647
- attr = shownInAggregators[u];
1648
- newDropdown.append($("<option>").val(attr).text(attr));
1597
+ });
1598
+ if (numInputsToProcess !== 0) {
1599
+ pvtVals = _this.find(".pvtVals");
1600
+ for (x = t = 0, ref5 = numInputsToProcess; 0 <= ref5 ? t < ref5 : t > ref5; x = 0 <= ref5 ? ++t : --t) {
1601
+ newDropdown = $("<select>").addClass('pvtAttrDropdown').append($("<option>")).bind("change", function() {
1602
+ return refresh();
1603
+ });
1604
+ for (u = 0, len4 = shownInAggregators.length; u < len4; u++) {
1605
+ attr = shownInAggregators[u];
1606
+ newDropdown.append($("<option>").val(attr).text(attr));
1607
+ }
1608
+ pvtVals.append(newDropdown);
1649
1609
  }
1650
- pvtVals.append(newDropdown);
1651
1610
  }
1652
- }
1653
- if (initialRender) {
1654
- vals = opts.vals;
1655
- i = 0;
1656
- _this.find(".pvtVals select.pvtAttrDropdown").each(function() {
1657
- $(this).val(vals[i]);
1658
- return i++;
1659
- });
1660
- initialRender = false;
1661
- }
1662
- subopts.aggregatorName = aggregator.val();
1663
- subopts.vals = vals;
1664
- subopts.aggregator = opts.aggregators[aggregator.val()](vals);
1665
- subopts.renderer = opts.renderers[renderer.val()];
1666
- subopts.rowOrder = rowOrderArrow.data("order");
1667
- subopts.colOrder = colOrderArrow.data("order");
1668
- exclusions = {};
1669
- _this.find('input.pvtFilter').not(':checked').each(function() {
1670
- var filter;
1671
- filter = $(this).data("filter");
1672
- if (exclusions[filter[0]] != null) {
1673
- return exclusions[filter[0]].push(filter[1]);
1674
- } else {
1675
- return exclusions[filter[0]] = [filter[1]];
1611
+ if (initialRender) {
1612
+ vals = opts.vals;
1613
+ i = 0;
1614
+ _this.find(".pvtVals select.pvtAttrDropdown").each(function() {
1615
+ $(this).val(vals[i]);
1616
+ return i++;
1617
+ });
1618
+ initialRender = false;
1676
1619
  }
1677
- });
1678
- inclusions = {};
1679
- _this.find('input.pvtFilter:checked').each(function() {
1680
- var filter;
1681
- filter = $(this).data("filter");
1682
- if (exclusions[filter[0]] != null) {
1683
- if (inclusions[filter[0]] != null) {
1684
- return inclusions[filter[0]].push(filter[1]);
1620
+ subopts.aggregatorName = aggregator.val();
1621
+ subopts.vals = vals;
1622
+ subopts.aggregator = opts.aggregators[aggregator.val()](vals);
1623
+ subopts.renderer = opts.renderers[renderer.val()];
1624
+ subopts.rowOrder = rowOrderArrow.data("order");
1625
+ subopts.colOrder = colOrderArrow.data("order");
1626
+ exclusions = {};
1627
+ _this.find('input.pvtFilter').not(':checked').each(function() {
1628
+ var filter;
1629
+ filter = $(this).data("filter");
1630
+ if (exclusions[filter[0]] != null) {
1631
+ return exclusions[filter[0]].push(filter[1]);
1685
1632
  } else {
1686
- return inclusions[filter[0]] = [filter[1]];
1633
+ return exclusions[filter[0]] = [filter[1]];
1687
1634
  }
1688
- }
1689
- });
1690
- subopts.filter = function(record) {
1691
- var excludedItems, k, ref6, ref7;
1692
- if (!opts.filter(record)) {
1693
- return false;
1694
- }
1695
- for (k in exclusions) {
1696
- excludedItems = exclusions[k];
1697
- if (ref6 = "" + ((ref7 = record[k]) != null ? ref7 : 'null'), indexOf.call(excludedItems, ref6) >= 0) {
1635
+ });
1636
+ inclusions = {};
1637
+ _this.find('input.pvtFilter:checked').each(function() {
1638
+ var filter;
1639
+ filter = $(this).data("filter");
1640
+ if (exclusions[filter[0]] != null) {
1641
+ if (inclusions[filter[0]] != null) {
1642
+ return inclusions[filter[0]].push(filter[1]);
1643
+ } else {
1644
+ return inclusions[filter[0]] = [filter[1]];
1645
+ }
1646
+ }
1647
+ });
1648
+ subopts.filter = function(record) {
1649
+ var excludedItems, k, ref6, ref7;
1650
+ if (!opts.filter(record)) {
1698
1651
  return false;
1699
1652
  }
1653
+ for (k in exclusions) {
1654
+ excludedItems = exclusions[k];
1655
+ if (ref6 = "" + ((ref7 = record[k]) != null ? ref7 : 'null'), indexOf.call(excludedItems, ref6) >= 0) {
1656
+ return false;
1657
+ }
1658
+ }
1659
+ return true;
1660
+ };
1661
+ pivotTable.pivot(materializedInput, subopts);
1662
+ pivotUIOptions = $.extend({}, opts, {
1663
+ cols: subopts.cols,
1664
+ rows: subopts.rows,
1665
+ colOrder: subopts.colOrder,
1666
+ rowOrder: subopts.rowOrder,
1667
+ vals: vals,
1668
+ exclusions: exclusions,
1669
+ inclusions: inclusions,
1670
+ inclusionsInfo: inclusions,
1671
+ aggregatorName: aggregator.val(),
1672
+ rendererName: renderer.val()
1673
+ });
1674
+ _this.data("pivotUIOptions", pivotUIOptions);
1675
+ if (opts.autoSortUnusedAttrs) {
1676
+ unusedAttrsContainer = _this.find("td.pvtUnused.pvtAxisContainer");
1677
+ $(unusedAttrsContainer).children("li").sort(function(a, b) {
1678
+ return naturalSort($(a).text(), $(b).text());
1679
+ }).appendTo(unusedAttrsContainer);
1680
+ }
1681
+ pivotTable.css("opacity", 1);
1682
+ if (opts.onRefresh != null) {
1683
+ return opts.onRefresh(pivotUIOptions);
1700
1684
  }
1701
- return true;
1702
1685
  };
1703
- pivotTable.pivot(materializedInput, subopts);
1704
- pivotUIOptions = $.extend({}, opts, {
1705
- cols: subopts.cols,
1706
- rows: subopts.rows,
1707
- colOrder: subopts.colOrder,
1708
- rowOrder: subopts.rowOrder,
1709
- vals: vals,
1710
- exclusions: exclusions,
1711
- inclusions: inclusions,
1712
- inclusionsInfo: inclusions,
1713
- aggregatorName: aggregator.val(),
1714
- rendererName: renderer.val()
1715
- });
1716
- _this.data("pivotUIOptions", pivotUIOptions);
1717
- if (opts.autoSortUnusedAttrs) {
1718
- unusedAttrsContainer = _this.find("td.pvtUnused.pvtAxisContainer");
1719
- $(unusedAttrsContainer).children("li").sort(function(a, b) {
1720
- return naturalSort($(a).text(), $(b).text());
1721
- }).appendTo(unusedAttrsContainer);
1722
- }
1723
- pivotTable.css("opacity", 1);
1724
- if (opts.onRefresh != null) {
1725
- return opts.onRefresh(pivotUIOptions);
1726
- }
1727
- };
1728
- })(this);
1729
- refresh = (function(_this) {
1730
- return function() {
1731
- pivotTable.css("opacity", 0.5);
1732
- return setTimeout(refreshDelayed, 10);
1733
- };
1734
- })(this);
1735
- refresh();
1736
- this.find(".pvtAxisContainer").sortable({
1737
- update: function(e, ui) {
1738
- if (ui.sender == null) {
1739
- return refresh();
1740
- }
1741
- },
1742
- connectWith: this.find(".pvtAxisContainer"),
1743
- items: 'li',
1744
- placeholder: 'pvtPlaceholder'
1745
- });
1746
- } catch (error) {
1747
- e = error;
1748
- if (typeof console !== "undefined" && console !== null) {
1749
- console.error(e.stack);
1686
+ })(this);
1687
+ refresh = (function(_this) {
1688
+ return function() {
1689
+ pivotTable.css("opacity", 0.5);
1690
+ return setTimeout(refreshDelayed, 10);
1691
+ };
1692
+ })(this);
1693
+ refresh();
1694
+ this.find(".pvtAxisContainer").sortable({
1695
+ update: function(e, ui) {
1696
+ if (ui.sender == null) {
1697
+ return refresh();
1698
+ }
1699
+ },
1700
+ connectWith: this.find(".pvtAxisContainer"),
1701
+ items: 'li',
1702
+ placeholder: 'pvtPlaceholder'
1703
+ });
1704
+ } catch (error) {
1705
+ e = error;
1706
+ if (typeof console !== "undefined" && console !== null) {
1707
+ console.error(e.stack);
1708
+ }
1709
+ // This function is not used internally or in webclient_angular/export_widget_service
1710
+ // TODO if it not removed in DR-39041, upgrade the error propagation
1711
+ this.html("An error occurred rendering the PivotTable UI.");
1750
1712
  }
1751
- this.html(opts.localeStrings.uiRenderError);
1713
+ return this;
1752
1714
  }
1753
- return this;
1754
1715
  };
1755
1716
 
1756
1717
  /*