fng-reports 0.12.0-beta.215 → 0.12.0-beta.217
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 +28 -1
- package/dist/fng-reports.min.js +3 -3
- package/package.json +2 -2
- package/src/fng-reports.js +27 -0
package/dist/fng-reports.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! forms-angular 2023-
|
|
1
|
+
/*! forms-angular 2023-06-24 */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
formsAngular.controller('AnalysisCtrl', ['$rootScope', '$window', '$filter', '$scope', '$http', '$location', 'cssFrameworkService', 'routingService',
|
|
@@ -64,6 +64,33 @@ formsAngular.controller('AnalysisCtrl', ['$rootScope', '$window', '$filter', '$s
|
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
66
|
},
|
|
67
|
+
appScopeProvider: {
|
|
68
|
+
/*
|
|
69
|
+
* This allows us to make an arbitrary http request from a cell template. Example:
|
|
70
|
+
* <div class="ui-grid-cell-contents">
|
|
71
|
+
* <button class="btn btn-small" data-ng-click="grid.appScope.http($event, 'GET', '/apix/queue/cancel/:id')" data-id="{{COL_FIELD}}" data-disable-button="true">
|
|
72
|
+
* <span class="glyphicon glyphicon-remove"></span> Cancel
|
|
73
|
+
* </button>
|
|
74
|
+
* </div>
|
|
75
|
+
* The value of any attribute beginning with data will replace the corresponding :attribute in the url,
|
|
76
|
+
* so in this case the :id in the url will be replaced by the value of the data-id attribute.
|
|
77
|
+
*/
|
|
78
|
+
http: function ($event, method, url) {
|
|
79
|
+
$event.currentTarget.getAttributeNames().forEach(a => {
|
|
80
|
+
if (a.startsWith('data-')) {
|
|
81
|
+
url = url.replace(`:${a.slice(5)}`, $event.currentTarget.getAttribute(a));
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
if ($event.currentTarget.getAttribute('data-disable-button') === 'true') {
|
|
85
|
+
$event.currentTarget.setAttribute('disabled', 'disabled');
|
|
86
|
+
}
|
|
87
|
+
$http({
|
|
88
|
+
method: method,
|
|
89
|
+
url: url,
|
|
90
|
+
});
|
|
91
|
+
$event.stopPropagation();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
67
94
|
};
|
|
68
95
|
$scope.report = [];
|
|
69
96
|
|
package/dist/fng-reports.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! forms-angular 2023-
|
|
2
|
-
"use strict";formsAngular.controller("AnalysisCtrl",["$rootScope","$window","$filter","$scope","$http","$location","cssFrameworkService","routingService",function(e,r,l,
|
|
3
|
-
`+e.message)}}if(angular.extend(a,t.parsePathFunc()(c.$$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,n],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&&c.$$search.r)switch(c.$$search.r.slice(0,1)){case"[":a.reportSchema.pipeline=d(c.$$search.r);break;case"{":angular.extend(a.reportSchema,d(c.$$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"===i.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 i=0,n=0;n<a.report.length;n++)i+=a.report[n][r];t=i,e&&(t=l(e)(t));break;default:t=o.totalsRow}return t},a.$on("exportToPDF",function(){o.createPDF()}),a.$on("exportToCSV",function(){n.createCSV()}),a.extractFilter=function(e,r){var t,o,i;e.cellFilter&&(-1===(i=e.cellFilter.indexOf(":"))?t=e.cellFilter:(t=e.cellFilter.slice(0,i).trim(),"'"!==(o=e.cellFilter.slice(i+1,999).trim())[0]&&'"'!==o[0]||(o=o.slice(1,-1))),i=angular.element(document.body).injector().get("$filter")(t.trim()),r[e.field]={filter:i,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:n.createCSV,text:"Export as CSV"}],S.contextMenu="Report",S.contextMenuId="reportMenu",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,i=c.$$url.match(/\?.*/);if(a.reportSchemaName?e+="/"+a.reportSchemaName:i&&(p&&(a.paramSchema=JSON.parse(c.search().r).params,u(a.paramSchema)),e+=r+i[0].slice(1),r="&",o=!0),a.paramSchema){for(var n in a.record)if(a.record.hasOwnProperty(n)){var l=a.reportSchema.params[n];if(a.record[n]&&""!==a.record[n])a.param=a.record[n],l.conversionExpression&&(a.param=a.$eval(l.conversionExpression)),e+=r+n+"="+a.param,r="&";else if(l.required)return}}else!o&&i&&(e+=r+i[0].slice(1),r="&");return s.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(e){let r,t;t=403===e.status?(r="You do not have permission to run this report (permission to GET all "+a.modelName+" records is required)","Permission denied"):(r="The server could not process the request","Error"),a.showError(r,t)})},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 i="",n={};return angular.forEach(l.grid.columns,function(e){var r;l.scope.extractFilter(e,n),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))?(i+='"'+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?(i+='"'+o(e.displayName)+'",',e.doCSVExport=!0):e.doCSVExport=!1:(i+='"'+o(e.displayName)+'",',e.doCSVExport=!0))}),i=e(i),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)),i+='"'+o(e,n[r.field])+'",'}}),i=e(i))}),i}}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=[],i=[],e=[],n={},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),i.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),i.push(e.field)):(o.push(e.displayName),i.push(e.field))),e.colDef.totalsRow&&(e.field,a.grid.getTotalVal(e.field,e.filter).toString()),a.scope.extractFilter(e,n)}),angular.forEach(a.scope.gridApi.core.getVisibleRows(),function(t){var o=[];t.visible&&(i.forEach(function(e){var r=t.entity[e];n[e]&&(r=n[e].filter(r,n[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(i,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=i(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)})}}}}}]);
|
|
1
|
+
/*! forms-angular 2023-06-24 */
|
|
2
|
+
"use strict";formsAngular.controller("AnalysisCtrl",["$rootScope","$window","$filter","$scope","$http","$location","cssFrameworkService","routingService",function(e,r,a,l,s,c,i,t){var p=!0,o=new ngGridPdfExportPlugin({inhibitButton:!0}),n=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(l,t.parsePathFunc()(c.$$path)),l.reportSchema={columnDefs:[]},l.gridOptions={data:"report",columnDefs:l.reportSchema.columnDefs,showColumnMenu:!0,enableRowHeaderSelection:!1,enableFiltering:!1,showGridFooter:!1,reallyShowFooter:!1,showTotals:!0,enableColumnResizing:!0,footerRowHeight:65,multiSelect:!1,plugins:[o,n],onRegisterApi:function(r){l.gridApi=r,l.gridOptions.plugins.forEach(function(e){e.init(l,r.grid,null)}),r.selection.on.rowSelectionChanged(l,function(o){var e=l.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=l.reportSchema.params[t[1]])?(l.param=l.record[t[1]],r.conversionExpression?l.$eval(r.conversionExpression):r.value):l.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+")"))})},appScopeProvider:{http:function(r,e,t){r.currentTarget.getAttributeNames().forEach(e=>{e.startsWith("data-")&&(t=t.replace(":"+e.slice(5),r.currentTarget.getAttribute(e)))}),"true"===r.currentTarget.getAttribute("data-disable-button")&&r.currentTarget.setAttribute("disabled","disabled"),s({method:e,url:t}),r.stopPropagation()}}},l.report=[],!l.reportSchemaName&&c.$$search.r)switch(c.$$search.r.slice(0,1)){case"[":l.reportSchema.pipeline=d(c.$$search.r);break;case"{":angular.extend(l.reportSchema,d(c.$$search.r));break;default:throw new Error("No report instructions specified")}function u(e){for(var r in l.paramSchema=[],l.record={},e){var t,o;e.hasOwnProperty(r)&&((t=e[r]).noInput||(o=l.paramSchema.push({name:r,id:"fp_"+r,label:t.label||a("titleCase")(r),type:t.type||"text",required:!0,add:t.add||void 0,size:t.size||("bs3"===i.frameWork?"large":"medium")}),"select"===t.type&&(l[r+"_Opts"]=t.enum,l.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])),l.record[r]=t.value)}l.$watch("record",function(e,r){r!==e&&l.refreshQuery()},!0)}l.getTotalVal=function(r,e){var t="",o=_.find(l.reportSchema.columnDefs,function(e){return e.field===r});if(o)switch(o.totalsRow){case void 0:break;case"$SUM":for(var i=0,n=0;n<l.report.length;n++)i+=l.report[n][r];t=i,e&&(t=a(e)(t));break;default:t=o.totalsRow}return t},l.$on("exportToPDF",function(){o.createPDF()}),l.$on("exportToCSV",function(){n.createCSV()}),l.extractFilter=function(e,r){var t,o,i;e.cellFilter&&(-1===(i=e.cellFilter.indexOf(":"))?t=e.cellFilter:(t=e.cellFilter.slice(0,i).trim(),"'"!==(o=e.cellFilter.slice(i+1,999).trim())[0]&&'"'!==o[0]||(o=o.slice(1,-1))),i=angular.element(document.body).injector().get("$filter")(t.trim()),r[e.field]={filter:i,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:n.createCSV,text:"Export as CSV"}],S.contextMenu="Report",S.contextMenuId="reportMenu",l.titleWithSubstitutions=l.reportSchema.title,l.inhibitRefresh||(l.refreshQuery=function(){function t(e){return e.replace(/\|.+?\|/g,function(e){e=e.slice(1,-1),e=/\((.+)\)/.exec(e);return e?l.reportSchema.params[e[1]].value:""})}var e="/api/report/"+l.modelName,r="?",o=!1,i=c.$$url.match(/\?.*/);if(l.reportSchemaName?e+="/"+l.reportSchemaName:i&&(p&&(l.paramSchema=JSON.parse(c.search().r).params,u(l.paramSchema)),e+=r+i[0].slice(1),r="&",o=!0),l.paramSchema){for(var n in l.record)if(l.record.hasOwnProperty(n)){var a=l.reportSchema.params[n];if(l.record[n]&&""!==l.record[n])l.param=l.record[n],a.conversionExpression&&(l.param=l.$eval(a.conversionExpression)),e+=r+n+"="+l.param,r="&";else if(a.required)return}}else!o&&i&&(e+=r+i[0].slice(1),r="&");return s.get(e).then(function(e){var r;e&&e.data&&e.data.success?(r=e.data,l.report=r.report,l.reportSchema=r.schema,l.reportSchema.title=l.reportSchema.title||l.modelName,l.titleWithSubstitutions=t(l.reportSchema.title),l.gridOptions.enableFiltering=!!l.reportSchema.filter,S&&S.items&&(S.items.length=2,l.reportSchema.menu)&&l.reportSchema.menu.forEach(function(e){S.items.push(JSON.parse(t(JSON.stringify(e))))}),p&&(p=!1,l.$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)))}),l.gridOptions.columnDefs=e}l.gridOptions.showTotals=r,l.gridOptions.reallyShowFooter=r,l.gridOptions.footerRowHeight=55+(r?10:0)},!0),!l.paramSchema)&&r.schema.params&&u(r.schema.params)):(l.showError(JSON.stringify(e.data.error),"Invalid Response Error"),l.reportSchema.title="Error - see console log")},function(e){let r,t;t=403===e.status?(r="You do not have permission to run this report (permission to GET all "+l.modelName+" records is required)","Permission denied"):(r="The server could not process the request","Error"),l.showError(r,t)})},l.refreshQuery()),l.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)},l.$on("$locationChangeStart",function(){delete S.contextMenu,delete S.items}),l.showError=function(r,e){if(l.alertTitle=e||"Error!","string"==typeof r)l.errorMessage=r;else if(r)if(r.message&&"string"==typeof r.message)l.errorMessage=r.message;else if(r.data&&r.data.message)l.errorMessage=r.data.message;else try{l.errorMessage=JSON.stringify(r)}catch(e){l.errorMessage=r}else l.errorMessage="An error occurred - that's all we got. Sorry.";l.errorHideTimer=window.setTimeout(function(){l.dismissError(),l.$digest()},3500+1e3*(l.alertTitle+l.errorMessage).length/50),l.errorVisible=!0,window.setTimeout(()=>{l.$digest()})},l.clearTimeout=function(){l.errorHideTimer&&(clearTimeout(l.errorHideTimer),delete l.errorHideTimer)},l.dismissError=function(){l.clearTimeout,l.errorVisible=!1,delete l.errorMessage,delete l.alertTitle},l.stickError=function(){clearTimeout(l.errorHideTimer)}}]);var COL_FIELD=/COL_FIELD/g;function ngGridCsvExportPlugin(e){var a=this;a.grid=null,a.scope=null,a.services=null,a.init=function(e,r,t){a.grid=r,a.scope=e,a.services=t},a.createCSV=function(){var e,r,t;e=a.scope.reportSchema.title+".csv",r="data:text/csv;charset=UTF-8,"+encodeURIComponent(a.prepareCSV()),(t=document.createElement("a")).download=e,t.href=r,e=new MouseEvent("click"),t.dispatchEvent(e)},a.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 i="",n={};return angular.forEach(a.grid.columns,function(e){var r;a.scope.extractFilter(e,n),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=a.scope.showsContent(e.colDef.cellTemplate,e.field))?(i+='"'+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?(i+='"'+o(e.displayName)+'",',e.doCSVExport=!0):e.doCSVExport=!1:(i+='"'+o(e.displayName)+'",',e.doCSVExport=!0))}),i=e(i),angular.forEach(a.scope.gridApi.core.getVisibleRows(),function(t){t.visible&&(angular.forEach(a.grid.columns,function(r){if(r.doCSVExport){let e=t.entity[r.field];"function"==typeof r.doCSVExport&&(e=r.doCSVExport(e)),i+='"'+o(e,n[r.field])+'",'}}),i=e(i))}),i}}function ngGridPdfExportPlugin(o){var l=this;l.grid=null,l.scope=null,l.services=null,l.options=o,l.init=function(e,r,t){l.grid=r,l.scope=e,l.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(){l.createPDF()}))},l.createPDF=function(){var o=[],i=[],e=[],n={},a={},r=(angular.forEach(l.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=l.scope.showsContent(e.colDef.cellTemplate,e.field))?(o.push(e.displayName),i.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),i.push(e.field)):(o.push(e.displayName),i.push(e.field))),e.colDef.totalsRow&&(e.field,l.grid.getTotalVal(e.field,e.filter).toString()),l.scope.extractFilter(e,n)}),angular.forEach(l.scope.gridApi.core.getVisibleRows(),function(t){var o=[];t.visible&&(i.forEach(function(e){var r=t.entity[e];n[e]&&(r=n[e].filter(r,n[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(i,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=i(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.217",
|
|
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.217",
|
|
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
|
@@ -63,6 +63,33 @@ formsAngular.controller('AnalysisCtrl', ['$rootScope', '$window', '$filter', '$s
|
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
65
|
},
|
|
66
|
+
appScopeProvider: {
|
|
67
|
+
/*
|
|
68
|
+
* This allows us to make an arbitrary http request from a cell template. Example:
|
|
69
|
+
* <div class="ui-grid-cell-contents">
|
|
70
|
+
* <button class="btn btn-small" data-ng-click="grid.appScope.http($event, 'GET', '/apix/queue/cancel/:id')" data-id="{{COL_FIELD}}" data-disable-button="true">
|
|
71
|
+
* <span class="glyphicon glyphicon-remove"></span> Cancel
|
|
72
|
+
* </button>
|
|
73
|
+
* </div>
|
|
74
|
+
* The value of any attribute beginning with data will replace the corresponding :attribute in the url,
|
|
75
|
+
* so in this case the :id in the url will be replaced by the value of the data-id attribute.
|
|
76
|
+
*/
|
|
77
|
+
http: function ($event, method, url) {
|
|
78
|
+
$event.currentTarget.getAttributeNames().forEach(a => {
|
|
79
|
+
if (a.startsWith('data-')) {
|
|
80
|
+
url = url.replace(`:${a.slice(5)}`, $event.currentTarget.getAttribute(a));
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
if ($event.currentTarget.getAttribute('data-disable-button') === 'true') {
|
|
84
|
+
$event.currentTarget.setAttribute('disabled', 'disabled');
|
|
85
|
+
}
|
|
86
|
+
$http({
|
|
87
|
+
method: method,
|
|
88
|
+
url: url,
|
|
89
|
+
});
|
|
90
|
+
$event.stopPropagation();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
66
93
|
};
|
|
67
94
|
$scope.report = [];
|
|
68
95
|
|