|
1 |
| -/*! forms-angular 2024-07-26 */ |
| 1 | +/*! forms-angular 2024-10-25 */ |
2 | 2 | 'use strict';
|
3 | 3 |
|
4 | 4 | formsAngular.controller('AnalysisCtrl', ['$rootScope', '$window', '$q', '$filter', '$scope', '$http', '$location', 'CssFrameworkService', 'RoutingService', 'uiGridConstants',
|
@@ -410,6 +410,21 @@ ${e.message}`);
|
410 | 410 | colDef.width = parseInt(colDef.width.slice(0, -2));
|
411 | 411 | }
|
412 | 412 | }
|
| 413 | + } else { |
| 414 | + // Need to generate columnDefs from the data, including every field (by default the grid gets upset by records with missing data) |
| 415 | + var allFields = new Set(); |
| 416 | + data.report.forEach(function(row) { |
| 417 | + for (var field in row) { |
| 418 | + allFields.add(field); |
| 419 | + } |
| 420 | + }); |
| 421 | + data.schema.columnDefs = Array.from(allFields).map(function(field) { |
| 422 | + { |
| 423 | + const colDef = { name: field }; |
| 424 | + $scope.gridOptions.columnDefs.push(colDef); |
| 425 | + return colDef; |
| 426 | + } |
| 427 | + }); |
413 | 428 | }
|
414 | 429 |
|
415 | 430 | if (!$scope.paramSchema && data.schema.params && $location.$$search.noinput !== '1') {
|
@@ -634,7 +649,11 @@ function ngGridCsvExportPlugin(opts) {
|
634 | 649 | col.doCSVExport = true;
|
635 | 650 | } else {
|
636 | 651 | const templateResp = self.scope.showsContent(col.colDef.cellTemplate, col.field);
|
637 |
| - if (templateResp === 'HTML') { |
| 652 | + // Third party apps can override showContent and return a function |
| 653 | + if (typeof templateResp === 'function') { |
| 654 | + csvData += '"' + csvStringify(col.displayName) + '",'; |
| 655 | + col.doCSVExport = templateResp; |
| 656 | + } else if (templateResp === 'HTML') { |
638 | 657 | csvData += '"' + csvStringify(col.displayName) + '",';
|
639 | 658 | col.doCSVExport = function (value) {
|
640 | 659 | value = value.replace(/<p>/g, '\n\n');
|
@@ -665,7 +684,7 @@ function ngGridCsvExportPlugin(opts) {
|
665 | 684 | if (col.doCSVExport) {
|
666 | 685 | let value = row.entity[col.field];
|
667 | 686 | if (typeof col.doCSVExport === 'function') {
|
668 |
| - value = col.doCSVExport(value); |
| 687 | + value = col.doCSVExport(value, row.entity, col); |
669 | 688 | }
|
670 | 689 | csvData += '"' + csvStringify(value, filters[col.field]) + '",';
|
671 | 690 | }
|
@@ -734,6 +753,12 @@ function ngGridPdfExportPlugin(options) {
|
734 | 753 | headerNames.push(col.field);
|
735 | 754 | } else {
|
736 | 755 | const templateResp = self.scope.showsContent(col.colDef.cellTemplate, col.field);
|
| 756 | + // Third party apps can override showContent and return a function |
| 757 | + if (typeof templateResp === 'function') { |
| 758 | + headers.push(col.displayName); |
| 759 | + headerNames.push(col.field); |
| 760 | + transformers[col.field] = templateResp; |
| 761 | + } else |
737 | 762 | if (templateResp === 'HTML') {
|
738 | 763 | headers.push(col.displayName);
|
739 | 764 | headerNames.push(col.field);
|
@@ -769,7 +794,7 @@ function ngGridPdfExportPlugin(options) {
|
769 | 794 | val = filters[h].filter(val, filters[h].filterParam);
|
770 | 795 | }
|
771 | 796 | if (transformers[h]) {
|
772 |
| - val = transformers[h](val); |
| 797 | + val = transformers[h](val, row.entity, h); |
773 | 798 | }
|
774 | 799 | if (typeof val === 'string') {
|
775 | 800 | // chars > 255 cause BOM characters - see https://reallycare.freshdesk.com/a/tickets/2370
|
|
0 commit comments