fng-reports 0.12.0-beta.197 → 0.12.0-beta.198
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/dist/fng-reports.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! forms-angular
|
|
1
|
+
/*! forms-angular 2023-02-09 */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
formsAngular.controller('AnalysisCtrl', ['$rootScope', '$window', '$filter', '$scope', '$http', '$location', 'cssFrameworkService', 'routingService',
|
|
@@ -504,29 +504,33 @@ function ngGridCsvExportPlugin(opts) {
|
|
|
504
504
|
angular.forEach(self.grid.columns, function (col) {
|
|
505
505
|
self.scope.extractFilter(col, filters);
|
|
506
506
|
if (col.visible && (col.width === undefined || col.width === '*' || col.width > 0)) {
|
|
507
|
-
if (
|
|
508
|
-
|
|
509
|
-
col.doCSVExport = true;
|
|
507
|
+
if (col.field.indexOf('.') !== -1) {
|
|
508
|
+
console.error(`Cannot export nested fields such as ${col.field}. Use $project to simplify.`);
|
|
510
509
|
} else {
|
|
510
|
+
if (!col.colDef.cellTemplate) {
|
|
511
|
+
csvData += '"' + csvStringify(col.displayName) + '",';
|
|
512
|
+
col.doCSVExport = true;
|
|
513
|
+
} else {
|
|
511
514
|
const templateResp = self.scope.showsContent(col.colDef.cellTemplate, col.field);
|
|
512
515
|
if (templateResp === 'HTML') {
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
516
|
+
csvData += '"' + csvStringify(col.displayName) + '",';
|
|
517
|
+
col.doCSVExport = function (value) {
|
|
518
|
+
value = value.replace(/<p>/g, '\n\n');
|
|
519
|
+
value = value.replace(/<\/p>/g, '');
|
|
520
|
+
value = value.replace(/<\s?br\s?\/?>/g, '\n');
|
|
521
|
+
value = value.replace(/<[^>]+>/g, '');
|
|
522
|
+
value = value.replaceAll(' ', ' ').trim();
|
|
523
|
+
value = value.replaceAll('\n\n \n\n', '\n\n');
|
|
524
|
+
value = value.replaceAll('\n\n\n', '\n\n');
|
|
525
|
+
return value;
|
|
526
|
+
};
|
|
524
527
|
} else if (templateResp) {
|
|
525
|
-
|
|
526
|
-
|
|
528
|
+
csvData += '"' + csvStringify(col.displayName) + '",';
|
|
529
|
+
col.doCSVExport = true;
|
|
527
530
|
} else {
|
|
528
|
-
|
|
531
|
+
col.doCSVExport = false;
|
|
529
532
|
}
|
|
533
|
+
}
|
|
530
534
|
}
|
|
531
535
|
}
|
|
532
536
|
});
|
|
@@ -600,27 +604,31 @@ function ngGridPdfExportPlugin(options) {
|
|
|
600
604
|
|
|
601
605
|
angular.forEach(self.grid.columns, function (col, index) {
|
|
602
606
|
if (col.visible) {
|
|
603
|
-
if (
|
|
604
|
-
|
|
605
|
-
headerNames.push(col.field);
|
|
607
|
+
if (col.field.indexOf('.') !== -1) {
|
|
608
|
+
console.error(`Cannot export nested fields such as ${col.field}. Use $project to simplify.`);
|
|
606
609
|
} else {
|
|
607
|
-
|
|
608
|
-
if (templateResp === 'HTML') {
|
|
609
|
-
headers.push(col.displayName);
|
|
610
|
-
headerNames.push(col.field);
|
|
611
|
-
transformers[col.field] = function (value) {
|
|
612
|
-
value = value.replace(/<p>/g, '\n\n');
|
|
613
|
-
value = value.replace(/<\/p>/g, '');
|
|
614
|
-
value = value.replace(/<\s?br\s?\/?>/g, '\n');
|
|
615
|
-
value = value.replace(/<[^>]+>/g, '');
|
|
616
|
-
value = value.replaceAll(' ', ' ').trim();
|
|
617
|
-
value = value.replaceAll('\n\n \n\n', '\n\n');
|
|
618
|
-
value = value.replaceAll('\n\n\n', '\n\n');
|
|
619
|
-
return value;
|
|
620
|
-
};
|
|
621
|
-
} else if (templateResp) {
|
|
610
|
+
if (!col.colDef.cellTemplate) {
|
|
622
611
|
headers.push(col.displayName);
|
|
623
612
|
headerNames.push(col.field);
|
|
613
|
+
} else {
|
|
614
|
+
const templateResp = self.scope.showsContent(col.colDef.cellTemplate, col.field);
|
|
615
|
+
if (templateResp === 'HTML') {
|
|
616
|
+
headers.push(col.displayName);
|
|
617
|
+
headerNames.push(col.field);
|
|
618
|
+
transformers[col.field] = function (value) {
|
|
619
|
+
value = value.replace(/<p>/g, '\n\n');
|
|
620
|
+
value = value.replace(/<\/p>/g, '');
|
|
621
|
+
value = value.replace(/<\s?br\s?\/?>/g, '\n');
|
|
622
|
+
value = value.replace(/<[^>]+>/g, '');
|
|
623
|
+
value = value.replaceAll(' ', ' ').trim();
|
|
624
|
+
value = value.replaceAll('\n\n \n\n', '\n\n');
|
|
625
|
+
value = value.replaceAll('\n\n\n', '\n\n');
|
|
626
|
+
return value;
|
|
627
|
+
};
|
|
628
|
+
} else if (templateResp) {
|
|
629
|
+
headers.push(col.displayName);
|
|
630
|
+
headerNames.push(col.field);
|
|
631
|
+
}
|
|
624
632
|
}
|
|
625
633
|
}
|
|
626
634
|
}
|
package/dist/fng-reports.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! forms-angular
|
|
1
|
+
/*! forms-angular 2023-02-09 */
|
|
2
2
|
"use strict";formsAngular.controller("AnalysisCtrl",["$rootScope","$window","$filter","$scope","$http","$location","cssFrameworkService","routingService",function(e,r,l,a,c,s,n,t){var p=!0,o=new ngGridPdfExportPlugin({inhibitButton:!0}),i=new ngGridCsvExportPlugin({inhibitButton:!0});function d(r){try{return JSON.parse(r)}catch(e){throw new Error(`Invalid JSON ${r}
|
|
3
|
-
`+e.message)}}if(angular.extend(a,t.parsePathFunc()(s.$$path)),a.reportSchema={columnDefs:[]},a.gridOptions={data:"report",columnDefs:a.reportSchema.columnDefs,showColumnMenu:!0,enableRowHeaderSelection:!1,enableFiltering:!1,showGridFooter:!1,reallyShowFooter:!1,showTotals:!0,enableColumnResizing:!0,footerRowHeight:65,multiSelect:!1,plugins:[o,i],onRegisterApi:function(r){a.gridApi=r,a.gridOptions.plugins.forEach(function(e){e.init(a,r.grid,null)}),r.selection.on.rowSelectionChanged(a,function(o){var e=a.reportSchema.drilldown;e&&("string"==typeof e?(e=t.buildUrl(e.replace(/\|.+?\|/g,function(e){var r,e=e.slice(1,-1),t=/\((.+)\)/.exec(e);return t?(r=a.reportSchema.params[t[1]])?(a.param=a.record[t[1]],r.conversionExpression?a.$eval(r.conversionExpression):r.value):a.reportSchema.params[t[1]].value:o.entity[e]})),window.location=e):console.error("Was expecting drilldown to be string but it was "+typeof e+" ("+e+")"))})}},a.report=[],!a.reportSchemaName&&s.$$search.r)switch(s.$$search.r.slice(0,1)){case"[":a.reportSchema.pipeline=d(s.$$search.r);break;case"{":angular.extend(a.reportSchema,d(s.$$search.r));break;default:throw new Error("No report instructions specified")}function u(e){for(var r in a.paramSchema=[],a.record={},e){var t,o;e.hasOwnProperty(r)&&((t=e[r]).noInput||(o=a.paramSchema.push({name:r,id:"fp_"+r,label:t.label||l("titleCase")(r),type:t.type||"text",required:!0,add:t.add||void 0,size:t.size||("bs3"===n.frameWork?"large":"medium")}),"select"===t.type&&(a[r+"_Opts"]=t.enum,a.paramSchema[o-1].options=r+"_Opts")),(o=/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3})(Z|[+ -]\d{4})$/.exec(t.value))&&(t.value=new Date(o[1])),a.record[r]=t.value)}a.$watch("record",function(e,r){r!==e&&a.refreshQuery()},!0)}a.getTotalVal=function(r,e){var t="",o=_.find(a.reportSchema.columnDefs,function(e){return e.field===r});if(o)switch(o.totalsRow){case void 0:break;case"$SUM":for(var n=0,i=0;i<a.report.length;i++)n+=a.report[i][r];t=n,e&&(t=l(e)(t));break;default:t=o.totalsRow}return t},a.$on("exportToPDF",function(){o.createPDF()}),a.$on("exportToCSV",function(){i.createCSV()}),a.extractFilter=function(e,r){var t,o,n;e.cellFilter&&(-1===(n=e.cellFilter.indexOf(":"))?t=e.cellFilter:(t=e.cellFilter.slice(0,n).trim(),"'"!==(o=e.cellFilter.slice(n+1,999).trim())[0]&&'"'!==o[0]||(o=o.slice(1,-1))),n=angular.element(document.body).injector().get("$filter")(t.trim()),r[e.field]={filter:n,filterParam:o})};var f,m,g,h=document.querySelector("div.report-grow"),S=(h&&(f=h.offsetLeft,m=h.offsetTop+f,g=(g=document.querySelector("div.ui-grid-header"))?g.clientHeight:31,r=Math.floor((r.innerHeight-m-g-f)/30),angular.element(h).css("height",30*r+"px")),e.navScope);S.items=[{fn:o.createPDF,text:"Save as PDF"},{fn:i.createCSV,text:"Export as CSV"}],S.contextMenu="Report",a.titleWithSubstitutions=a.reportSchema.title,a.inhibitRefresh||(a.refreshQuery=function(){function t(e){return e.replace(/\|.+?\|/g,function(e){e=e.slice(1,-1),e=/\((.+)\)/.exec(e);return e?a.reportSchema.params[e[1]].value:""})}var e="/api/report/"+a.modelName,r="?",o=!1,n=s.$$url.match(/\?.*/);if(a.reportSchemaName?e+="/"+a.reportSchemaName:n&&(p&&(a.paramSchema=JSON.parse(s.search().r).params,u(a.paramSchema)),e+=r+n[0].slice(1),r="&",o=!0),a.paramSchema){for(var i in a.record)if(a.record.hasOwnProperty(i)){var l=a.reportSchema.params[i];if(a.record[i]&&""!==a.record[i])a.param=a.record[i],l.conversionExpression&&(a.param=a.$eval(l.conversionExpression)),e+=r+i+"="+a.param,r="&";else if(l.required)return}}else!o&&n&&(e+=r+n[0].slice(1),r="&");return c.get(e).then(function(e){var r;e&&e.data&&e.data.success?(r=e.data,a.report=r.report,a.reportSchema=r.schema,a.reportSchema.title=a.reportSchema.title||a.modelName,a.titleWithSubstitutions=t(a.reportSchema.title),a.gridOptions.enableFiltering=!!a.reportSchema.filter,S&&S.items&&(S.items.length=2,a.reportSchema.menu&&a.reportSchema.menu.forEach(function(e){S.items.push(JSON.parse(t(JSON.stringify(e))))})),p&&(p=!1,a.$watch("reportSchema.columnDefs",function(e){var r=!1;if(e){for(var t,o=0;o<e.length;o++)e[o].totalsRow&&(r=!0),e[o].align&&(t="fng-"+e[o].align,e[o].cellClass=e[o].cellClass||"",-1===e[o].cellClass.indexOf(t)&&(e[o].cellClass=e[o].cellClass+" "+t));e.forEach(function(e){e.width&&"string"==typeof e.width&&-1!==e.width.indexOf("px")&&(e.width=parseInt(e.width.slice(0,-2)))}),a.gridOptions.columnDefs=e}a.gridOptions.showTotals=r,a.gridOptions.reallyShowFooter=r,a.gridOptions.footerRowHeight=55+(r?10:0)},!0),!a.paramSchema&&r.schema.params&&u(r.schema.params))):(a.showError(JSON.stringify(e.data.error),"Invalid Response Error"),a.reportSchema.title="Error - see console log")},function(){a.showError("The server could not process the request","Error")})},a.refreshQuery()),a.showsContent=function(e,r){return!!/{{[\s]*COL_FIELD[\s]*}}/.test(e.replace(/(<([^>]+)>)/gi,""))||(-1!==e.indexOf('ng-bind-html="row.entity.'+r)?"HTML":void 0)},a.$on("$locationChangeStart",function(){delete S.contextMenu,delete S.items}),a.showError=function(r,e){if(a.alertTitle=e||"Error!","string"==typeof r)a.errorMessage=r;else if(r)if(r.message&&"string"==typeof r.message)a.errorMessage=r.message;else if(r.data&&r.data.message)a.errorMessage=r.data.message;else try{a.errorMessage=JSON.stringify(r)}catch(e){a.errorMessage=r}else a.errorMessage="An error occurred - that's all we got. Sorry.";a.errorHideTimer=window.setTimeout(function(){a.dismissError(),a.$digest()},3500+1e3*(a.alertTitle+a.errorMessage).length/50),a.errorVisible=!0,window.setTimeout(()=>{a.$digest()})},a.clearTimeout=function(){a.errorHideTimer&&(clearTimeout(a.errorHideTimer),delete a.errorHideTimer)},a.dismissError=function(){a.clearTimeout,a.errorVisible=!1,delete a.errorMessage,delete a.alertTitle},a.stickError=function(){clearTimeout(a.errorHideTimer)}}]);var COL_FIELD=/COL_FIELD/g;function ngGridCsvExportPlugin(e){var l=this;l.grid=null,l.scope=null,l.services=null,l.init=function(e,r,t){l.grid=r,l.scope=e,l.services=t},l.createCSV=function(){var e,r,t;e=l.scope.reportSchema.title+".csv",r="data:text/csv;charset=UTF-8,"+encodeURIComponent(l.prepareCSV()),(t=document.createElement("a")).download=e,t.href=r,e=new MouseEvent("click"),t.dispatchEvent(e)},l.prepareCSV=function(){function o(e,r){return null==e?"":r?r.filter(e,r.filterParam):"number"==typeof e?""+e:"boolean"==typeof e?e?"TRUE":"FALSE":("string"==typeof e?e:JSON.stringify(e)).replace(/"/g,'""')}function e(e){return e.substr(0,e.length-1)+"\n"}var n="",i={};return angular.forEach(l.grid.columns,function(e){var r;l.scope.extractFilter(e,i),e.visible&&(void 0===e.width||"*"===e.width||0<e.width)&&(e.colDef.cellTemplate?"HTML"===(r=l.scope.showsContent(e.colDef.cellTemplate,e.field))?(n+='"'+o(e.displayName)+'",',e.doCSVExport=function(e){return e=(e=(e=(e=(e=(e=(e=e.replace(/<p>/g,"\n\n")).replace(/<\/p>/g,"")).replace(/<\s?br\s?\/?>/g,"\n")).replace(/<[^>]+>/g,"")).replaceAll(" "," ").trim()).replaceAll("\n\n \n\n","\n\n")).replaceAll("\n\n\n","\n\n")}):r?(n+='"'+o(e.displayName)+'",',e.doCSVExport=!0):e.doCSVExport=!1:(n+='"'+o(e.displayName)+'",',e.doCSVExport=!0))}),n=e(n),angular.forEach(l.scope.gridApi.core.getVisibleRows(),function(t){t.visible&&(angular.forEach(l.grid.columns,function(r){if(r.doCSVExport){let e=t.entity[r.field];"function"==typeof r.doCSVExport&&(e=r.doCSVExport(e)),n+='"'+o(e,i[r.field])+'",'}}),n=e(n))}),n}}function ngGridPdfExportPlugin(o){var c=this;c.grid=null,c.scope=null,c.services=null,c.options=o,c.init=function(e,r,t){c.grid=r,c.scope=e,c.services=t,o.inhibitButton||(e=r.$root.find(".ngFooterPanel"),null!=(t=r.$root.find(".ngFooterPanel .pdf-data-link-span"))&&t.remove(),e.append('<button class="pdf-data-link-span">PDF Export</button>'),e.on("click",function(){c.createPDF()}))},c.createPDF=function(){var o=[],n=[],i=[],e=[],l={},a={},r=(angular.forEach(c.grid.columns,function(e,r){var t;e.visible&&(e.colDef.cellTemplate?"HTML"===(t=c.scope.showsContent(e.colDef.cellTemplate,e.field))?(o.push(e.displayName),n.push(e.field),a[e.field]=function(e){return e=(e=(e=(e=(e=(e=(e=e.replace(/<p>/g,"\n\n")).replace(/<\/p>/g,"")).replace(/<\s?br\s?\/?>/g,"\n")).replace(/<[^>]+>/g,"")).replaceAll(" "," ").trim()).replaceAll("\n\n \n\n","\n\n")).replaceAll("\n\n\n","\n\n")}):t&&(o.push(e.displayName),n.push(e.field)):(o.push(e.displayName),n.push(e.field))),e.colDef.totalsRow&&(i[e.field]=c.grid.getTotalVal(e.field,e.filter).toString()),c.scope.extractFilter(e,l)}),angular.forEach(c.scope.gridApi.core.getVisibleRows(),function(t){var o=[];t.visible&&(n.forEach(function(e){var r=t.entity[e];l[e]&&(r=l[e].filter(r,l[e].filterParam)),"string"==typeof(r=a[e]?a[e](r):r)&&(r=(r=(r=(r=(r=r.replace(/\u2019/g,"'")).replace(/\u2018/g,"'")).replace(/\u201c/g,'"')).replace(/\u201d/g,'"')).replace(/[^\x00-\xFF]/g,"")),o.push(r)}),e.push(o))}),new jspdf.jsPDF("landscape","mm","a4"));r.autoTable({head:[o],body:e}),window.open(r.output("bloburl"))}}formsAngular.directive("ngTotalCell",["$compile","$domUtilityService",function(n,t){return{scope:!1,compile:function(){return{pre:function(e,r){var t=e.col.cellTemplate.match(/{{COL_FIELD \|(.+)}}/),t=t?e.col.cellTemplate.replace("COL_FIELD |"+t[1],'getTotalVal("'+e.col.field+'","'+t[1]+'")'):e.col.cellTemplate.replace(COL_FIELD,'getTotalVal("'+e.col.field+'")'),o=e.col.enableCellEdit?(o=(o=e.col.cellEditTemplate).replace(DISPLAY_CELL_TEMPLATE,t)).replace(EDITABLE_CELL_TEMPLATE,e.col.editableCellTemplate.replace(COL_FIELD,"row.entity."+e.col.field)):t,t=n(o)(e);e.enableCellSelection&&-1===t[0].className.indexOf("ngSelectionCell")&&(t[0].setAttribute("tabindex",0),t.addClass("ngCellElement")),r.append(t)},post:function(e,r){e.enableCellSelection&&e.domAccessProvider.selectionHandlers(e,r),e.$on("ngGridEventDigestCell",function(){t.digest(e)})}}}}}]);
|
|
3
|
+
`+e.message)}}if(angular.extend(a,t.parsePathFunc()(s.$$path)),a.reportSchema={columnDefs:[]},a.gridOptions={data:"report",columnDefs:a.reportSchema.columnDefs,showColumnMenu:!0,enableRowHeaderSelection:!1,enableFiltering:!1,showGridFooter:!1,reallyShowFooter:!1,showTotals:!0,enableColumnResizing:!0,footerRowHeight:65,multiSelect:!1,plugins:[o,i],onRegisterApi:function(r){a.gridApi=r,a.gridOptions.plugins.forEach(function(e){e.init(a,r.grid,null)}),r.selection.on.rowSelectionChanged(a,function(o){var e=a.reportSchema.drilldown;e&&("string"==typeof e?(e=t.buildUrl(e.replace(/\|.+?\|/g,function(e){var r,e=e.slice(1,-1),t=/\((.+)\)/.exec(e);return t?(r=a.reportSchema.params[t[1]])?(a.param=a.record[t[1]],r.conversionExpression?a.$eval(r.conversionExpression):r.value):a.reportSchema.params[t[1]].value:o.entity[e]})),window.location=e):console.error("Was expecting drilldown to be string but it was "+typeof e+" ("+e+")"))})}},a.report=[],!a.reportSchemaName&&s.$$search.r)switch(s.$$search.r.slice(0,1)){case"[":a.reportSchema.pipeline=d(s.$$search.r);break;case"{":angular.extend(a.reportSchema,d(s.$$search.r));break;default:throw new Error("No report instructions specified")}function u(e){for(var r in a.paramSchema=[],a.record={},e){var t,o;e.hasOwnProperty(r)&&((t=e[r]).noInput||(o=a.paramSchema.push({name:r,id:"fp_"+r,label:t.label||l("titleCase")(r),type:t.type||"text",required:!0,add:t.add||void 0,size:t.size||("bs3"===n.frameWork?"large":"medium")}),"select"===t.type&&(a[r+"_Opts"]=t.enum,a.paramSchema[o-1].options=r+"_Opts")),(o=/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3})(Z|[+ -]\d{4})$/.exec(t.value))&&(t.value=new Date(o[1])),a.record[r]=t.value)}a.$watch("record",function(e,r){r!==e&&a.refreshQuery()},!0)}a.getTotalVal=function(r,e){var t="",o=_.find(a.reportSchema.columnDefs,function(e){return e.field===r});if(o)switch(o.totalsRow){case void 0:break;case"$SUM":for(var n=0,i=0;i<a.report.length;i++)n+=a.report[i][r];t=n,e&&(t=l(e)(t));break;default:t=o.totalsRow}return t},a.$on("exportToPDF",function(){o.createPDF()}),a.$on("exportToCSV",function(){i.createCSV()}),a.extractFilter=function(e,r){var t,o,n;e.cellFilter&&(-1===(n=e.cellFilter.indexOf(":"))?t=e.cellFilter:(t=e.cellFilter.slice(0,n).trim(),"'"!==(o=e.cellFilter.slice(n+1,999).trim())[0]&&'"'!==o[0]||(o=o.slice(1,-1))),n=angular.element(document.body).injector().get("$filter")(t.trim()),r[e.field]={filter:n,filterParam:o})};var f,m,h,g=document.querySelector("div.report-grow"),S=(g&&(f=g.offsetLeft,m=g.offsetTop+f,h=(h=document.querySelector("div.ui-grid-header"))?h.clientHeight:31,r=Math.floor((r.innerHeight-m-h-f)/30),angular.element(g).css("height",30*r+"px")),e.navScope);S.items=[{fn:o.createPDF,text:"Save as PDF"},{fn:i.createCSV,text:"Export as CSV"}],S.contextMenu="Report",a.titleWithSubstitutions=a.reportSchema.title,a.inhibitRefresh||(a.refreshQuery=function(){function t(e){return e.replace(/\|.+?\|/g,function(e){e=e.slice(1,-1),e=/\((.+)\)/.exec(e);return e?a.reportSchema.params[e[1]].value:""})}var e="/api/report/"+a.modelName,r="?",o=!1,n=s.$$url.match(/\?.*/);if(a.reportSchemaName?e+="/"+a.reportSchemaName:n&&(p&&(a.paramSchema=JSON.parse(s.search().r).params,u(a.paramSchema)),e+=r+n[0].slice(1),r="&",o=!0),a.paramSchema){for(var i in a.record)if(a.record.hasOwnProperty(i)){var l=a.reportSchema.params[i];if(a.record[i]&&""!==a.record[i])a.param=a.record[i],l.conversionExpression&&(a.param=a.$eval(l.conversionExpression)),e+=r+i+"="+a.param,r="&";else if(l.required)return}}else!o&&n&&(e+=r+n[0].slice(1),r="&");return c.get(e).then(function(e){var r;e&&e.data&&e.data.success?(r=e.data,a.report=r.report,a.reportSchema=r.schema,a.reportSchema.title=a.reportSchema.title||a.modelName,a.titleWithSubstitutions=t(a.reportSchema.title),a.gridOptions.enableFiltering=!!a.reportSchema.filter,S&&S.items&&(S.items.length=2,a.reportSchema.menu)&&a.reportSchema.menu.forEach(function(e){S.items.push(JSON.parse(t(JSON.stringify(e))))}),p&&(p=!1,a.$watch("reportSchema.columnDefs",function(e){var r=!1;if(e){for(var t,o=0;o<e.length;o++)e[o].totalsRow&&(r=!0),e[o].align&&(t="fng-"+e[o].align,e[o].cellClass=e[o].cellClass||"",-1===e[o].cellClass.indexOf(t))&&(e[o].cellClass=e[o].cellClass+" "+t);e.forEach(function(e){e.width&&"string"==typeof e.width&&-1!==e.width.indexOf("px")&&(e.width=parseInt(e.width.slice(0,-2)))}),a.gridOptions.columnDefs=e}a.gridOptions.showTotals=r,a.gridOptions.reallyShowFooter=r,a.gridOptions.footerRowHeight=55+(r?10:0)},!0),!a.paramSchema)&&r.schema.params&&u(r.schema.params)):(a.showError(JSON.stringify(e.data.error),"Invalid Response Error"),a.reportSchema.title="Error - see console log")},function(){a.showError("The server could not process the request","Error")})},a.refreshQuery()),a.showsContent=function(e,r){return!!/{{[\s]*COL_FIELD[\s]*}}/.test(e.replace(/(<([^>]+)>)/gi,""))||(-1!==e.indexOf('ng-bind-html="row.entity.'+r)?"HTML":void 0)},a.$on("$locationChangeStart",function(){delete S.contextMenu,delete S.items}),a.showError=function(r,e){if(a.alertTitle=e||"Error!","string"==typeof r)a.errorMessage=r;else if(r)if(r.message&&"string"==typeof r.message)a.errorMessage=r.message;else if(r.data&&r.data.message)a.errorMessage=r.data.message;else try{a.errorMessage=JSON.stringify(r)}catch(e){a.errorMessage=r}else a.errorMessage="An error occurred - that's all we got. Sorry.";a.errorHideTimer=window.setTimeout(function(){a.dismissError(),a.$digest()},3500+1e3*(a.alertTitle+a.errorMessage).length/50),a.errorVisible=!0,window.setTimeout(()=>{a.$digest()})},a.clearTimeout=function(){a.errorHideTimer&&(clearTimeout(a.errorHideTimer),delete a.errorHideTimer)},a.dismissError=function(){a.clearTimeout,a.errorVisible=!1,delete a.errorMessage,delete a.alertTitle},a.stickError=function(){clearTimeout(a.errorHideTimer)}}]);var COL_FIELD=/COL_FIELD/g;function ngGridCsvExportPlugin(e){var l=this;l.grid=null,l.scope=null,l.services=null,l.init=function(e,r,t){l.grid=r,l.scope=e,l.services=t},l.createCSV=function(){var e,r,t;e=l.scope.reportSchema.title+".csv",r="data:text/csv;charset=UTF-8,"+encodeURIComponent(l.prepareCSV()),(t=document.createElement("a")).download=e,t.href=r,e=new MouseEvent("click"),t.dispatchEvent(e)},l.prepareCSV=function(){function o(e,r){return null==e?"":r?r.filter(e,r.filterParam):"number"==typeof e?""+e:"boolean"==typeof e?e?"TRUE":"FALSE":("string"==typeof e?e:JSON.stringify(e)).replace(/"/g,'""')}function e(e){return e.substr(0,e.length-1)+"\n"}var n="",i={};return angular.forEach(l.grid.columns,function(e){var r;l.scope.extractFilter(e,i),e.visible&&(void 0===e.width||"*"===e.width||0<e.width)&&(-1!==e.field.indexOf(".")?console.error(`Cannot export nested fields such as ${e.field}. Use $project to simplify.`):e.colDef.cellTemplate?"HTML"===(r=l.scope.showsContent(e.colDef.cellTemplate,e.field))?(n+='"'+o(e.displayName)+'",',e.doCSVExport=function(e){return e=(e=(e=(e=(e=(e=(e=e.replace(/<p>/g,"\n\n")).replace(/<\/p>/g,"")).replace(/<\s?br\s?\/?>/g,"\n")).replace(/<[^>]+>/g,"")).replaceAll(" "," ").trim()).replaceAll("\n\n \n\n","\n\n")).replaceAll("\n\n\n","\n\n")}):r?(n+='"'+o(e.displayName)+'",',e.doCSVExport=!0):e.doCSVExport=!1:(n+='"'+o(e.displayName)+'",',e.doCSVExport=!0))}),n=e(n),angular.forEach(l.scope.gridApi.core.getVisibleRows(),function(t){t.visible&&(angular.forEach(l.grid.columns,function(r){if(r.doCSVExport){let e=t.entity[r.field];"function"==typeof r.doCSVExport&&(e=r.doCSVExport(e)),n+='"'+o(e,i[r.field])+'",'}}),n=e(n))}),n}}function ngGridPdfExportPlugin(o){var a=this;a.grid=null,a.scope=null,a.services=null,a.options=o,a.init=function(e,r,t){a.grid=r,a.scope=e,a.services=t,o.inhibitButton||(e=r.$root.find(".ngFooterPanel"),null!=(t=r.$root.find(".ngFooterPanel .pdf-data-link-span"))&&t.remove(),e.append('<button class="pdf-data-link-span">PDF Export</button>'),e.on("click",function(){a.createPDF()}))},a.createPDF=function(){var o=[],n=[],e=[],i={},l={},r=(angular.forEach(a.grid.columns,function(e,r){var t;e.visible&&(-1!==e.field.indexOf(".")?console.error(`Cannot export nested fields such as ${e.field}. Use $project to simplify.`):e.colDef.cellTemplate?"HTML"===(t=a.scope.showsContent(e.colDef.cellTemplate,e.field))?(o.push(e.displayName),n.push(e.field),l[e.field]=function(e){return e=(e=(e=(e=(e=(e=(e=e.replace(/<p>/g,"\n\n")).replace(/<\/p>/g,"")).replace(/<\s?br\s?\/?>/g,"\n")).replace(/<[^>]+>/g,"")).replaceAll(" "," ").trim()).replaceAll("\n\n \n\n","\n\n")).replaceAll("\n\n\n","\n\n")}):t&&(o.push(e.displayName),n.push(e.field)):(o.push(e.displayName),n.push(e.field))),e.colDef.totalsRow&&(e.field,a.grid.getTotalVal(e.field,e.filter).toString()),a.scope.extractFilter(e,i)}),angular.forEach(a.scope.gridApi.core.getVisibleRows(),function(t){var o=[];t.visible&&(n.forEach(function(e){var r=t.entity[e];i[e]&&(r=i[e].filter(r,i[e].filterParam)),"string"==typeof(r=l[e]?l[e](r):r)&&(r=(r=(r=(r=(r=r.replace(/\u2019/g,"'")).replace(/\u2018/g,"'")).replace(/\u201c/g,'"')).replace(/\u201d/g,'"')).replace(/[^\x00-\xFF]/g,"")),o.push(r)}),e.push(o))}),new jspdf.jsPDF("landscape","mm","a4"));r.autoTable({head:[o],body:e}),window.open(r.output("bloburl"))}}formsAngular.directive("ngTotalCell",["$compile","$domUtilityService",function(n,t){return{scope:!1,compile:function(){return{pre:function(e,r){var t=e.col.cellTemplate.match(/{{COL_FIELD \|(.+)}}/),t=t?e.col.cellTemplate.replace("COL_FIELD |"+t[1],'getTotalVal("'+e.col.field+'","'+t[1]+'")'):e.col.cellTemplate.replace(COL_FIELD,'getTotalVal("'+e.col.field+'")'),o=e.col.enableCellEdit?(o=(o=e.col.cellEditTemplate).replace(DISPLAY_CELL_TEMPLATE,t)).replace(EDITABLE_CELL_TEMPLATE,e.col.editableCellTemplate.replace(COL_FIELD,"row.entity."+e.col.field)):t,t=n(o)(e);e.enableCellSelection&&-1===t[0].className.indexOf("ngSelectionCell")&&(t[0].setAttribute("tabindex",0),t.addClass("ngCellElement")),r.append(t)},post:function(e,r){e.enableCellSelection&&e.domAccessProvider.selectionHandlers(e,r),e.$on("ngGridEventDigestCell",function(){t.digest(e)})}}}}}]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fng-reports",
|
|
3
|
-
"version": "0.12.0-beta.
|
|
3
|
+
"version": "0.12.0-beta.198",
|
|
4
4
|
"description": "Reporting plugin for forms-angular",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"angular-messages": "1.8.3",
|
|
33
33
|
"angular-mocks": "1.8.3",
|
|
34
34
|
"angular-sanitize": "1.8.3",
|
|
35
|
-
"forms-angular": "0.12.0-beta.
|
|
35
|
+
"forms-angular": "0.12.0-beta.198",
|
|
36
36
|
"grunt": "^1.5.3",
|
|
37
37
|
"grunt-autoprefixer": "3.0.4",
|
|
38
38
|
"grunt-concurrent": "3.0.0",
|
package/src/fng-reports.js
CHANGED
|
@@ -170,7 +170,7 @@ ${e.message}`);
|
|
|
170
170
|
}
|
|
171
171
|
var dateTest = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3})(Z|[+ -]\d{4})$/.exec(thisPart.value);
|
|
172
172
|
if (dateTest) {
|
|
173
|
-
thisPart.value = new Date(
|
|
173
|
+
thisPart.value = new Date(dateTest[1]);
|
|
174
174
|
}
|
|
175
175
|
$scope.record[param] = thisPart.value;
|
|
176
176
|
}
|
|
@@ -56,29 +56,33 @@ function ngGridCsvExportPlugin(opts) {
|
|
|
56
56
|
angular.forEach(self.grid.columns, function (col) {
|
|
57
57
|
self.scope.extractFilter(col, filters);
|
|
58
58
|
if (col.visible && (col.width === undefined || col.width === '*' || col.width > 0)) {
|
|
59
|
-
if (
|
|
60
|
-
|
|
61
|
-
col.doCSVExport = true;
|
|
59
|
+
if (col.field.indexOf('.') !== -1) {
|
|
60
|
+
console.error(`Cannot export nested fields such as ${col.field}. Use $project to simplify.`);
|
|
62
61
|
} else {
|
|
62
|
+
if (!col.colDef.cellTemplate) {
|
|
63
|
+
csvData += '"' + csvStringify(col.displayName) + '",';
|
|
64
|
+
col.doCSVExport = true;
|
|
65
|
+
} else {
|
|
63
66
|
const templateResp = self.scope.showsContent(col.colDef.cellTemplate, col.field);
|
|
64
67
|
if (templateResp === 'HTML') {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
csvData += '"' + csvStringify(col.displayName) + '",';
|
|
69
|
+
col.doCSVExport = function (value) {
|
|
70
|
+
value = value.replace(/<p>/g, '\n\n');
|
|
71
|
+
value = value.replace(/<\/p>/g, '');
|
|
72
|
+
value = value.replace(/<\s?br\s?\/?>/g, '\n');
|
|
73
|
+
value = value.replace(/<[^>]+>/g, '');
|
|
74
|
+
value = value.replaceAll(' ', ' ').trim();
|
|
75
|
+
value = value.replaceAll('\n\n \n\n', '\n\n');
|
|
76
|
+
value = value.replaceAll('\n\n\n', '\n\n');
|
|
77
|
+
return value;
|
|
78
|
+
};
|
|
76
79
|
} else if (templateResp) {
|
|
77
|
-
|
|
78
|
-
|
|
80
|
+
csvData += '"' + csvStringify(col.displayName) + '",';
|
|
81
|
+
col.doCSVExport = true;
|
|
79
82
|
} else {
|
|
80
|
-
|
|
83
|
+
col.doCSVExport = false;
|
|
81
84
|
}
|
|
85
|
+
}
|
|
82
86
|
}
|
|
83
87
|
}
|
|
84
88
|
});
|
|
@@ -46,27 +46,31 @@ function ngGridPdfExportPlugin(options) {
|
|
|
46
46
|
|
|
47
47
|
angular.forEach(self.grid.columns, function (col, index) {
|
|
48
48
|
if (col.visible) {
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
headerNames.push(col.field);
|
|
49
|
+
if (col.field.indexOf('.') !== -1) {
|
|
50
|
+
console.error(`Cannot export nested fields such as ${col.field}. Use $project to simplify.`);
|
|
52
51
|
} else {
|
|
53
|
-
|
|
54
|
-
if (templateResp === 'HTML') {
|
|
55
|
-
headers.push(col.displayName);
|
|
56
|
-
headerNames.push(col.field);
|
|
57
|
-
transformers[col.field] = function (value) {
|
|
58
|
-
value = value.replace(/<p>/g, '\n\n');
|
|
59
|
-
value = value.replace(/<\/p>/g, '');
|
|
60
|
-
value = value.replace(/<\s?br\s?\/?>/g, '\n');
|
|
61
|
-
value = value.replace(/<[^>]+>/g, '');
|
|
62
|
-
value = value.replaceAll(' ', ' ').trim();
|
|
63
|
-
value = value.replaceAll('\n\n \n\n', '\n\n');
|
|
64
|
-
value = value.replaceAll('\n\n\n', '\n\n');
|
|
65
|
-
return value;
|
|
66
|
-
};
|
|
67
|
-
} else if (templateResp) {
|
|
52
|
+
if (!col.colDef.cellTemplate) {
|
|
68
53
|
headers.push(col.displayName);
|
|
69
54
|
headerNames.push(col.field);
|
|
55
|
+
} else {
|
|
56
|
+
const templateResp = self.scope.showsContent(col.colDef.cellTemplate, col.field);
|
|
57
|
+
if (templateResp === 'HTML') {
|
|
58
|
+
headers.push(col.displayName);
|
|
59
|
+
headerNames.push(col.field);
|
|
60
|
+
transformers[col.field] = function (value) {
|
|
61
|
+
value = value.replace(/<p>/g, '\n\n');
|
|
62
|
+
value = value.replace(/<\/p>/g, '');
|
|
63
|
+
value = value.replace(/<\s?br\s?\/?>/g, '\n');
|
|
64
|
+
value = value.replace(/<[^>]+>/g, '');
|
|
65
|
+
value = value.replaceAll(' ', ' ').trim();
|
|
66
|
+
value = value.replaceAll('\n\n \n\n', '\n\n');
|
|
67
|
+
value = value.replaceAll('\n\n\n', '\n\n');
|
|
68
|
+
return value;
|
|
69
|
+
};
|
|
70
|
+
} else if (templateResp) {
|
|
71
|
+
headers.push(col.displayName);
|
|
72
|
+
headerNames.push(col.field);
|
|
73
|
+
}
|
|
70
74
|
}
|
|
71
75
|
}
|
|
72
76
|
}
|