fng-reports 0.12.0-beta.201 → 0.12.0-beta.203

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.
@@ -1,4 +1,4 @@
1
- /*! forms-angular 2023-02-09 */
1
+ /*! forms-angular 2023-03-02 */
2
2
  'use strict';
3
3
 
4
4
  formsAngular.controller('AnalysisCtrl', ['$rootScope', '$window', '$filter', '$scope', '$http', '$location', 'cssFrameworkService', 'routingService',
@@ -323,8 +323,16 @@ ${e.message}`);
323
323
  $scope.showError(JSON.stringify(response.data.error), 'Invalid Response Error');
324
324
  $scope.reportSchema.title = 'Error - see console log';
325
325
  }
326
- }, function () {
327
- $scope.showError('The server could not process the request', 'Error');
326
+ }, function (error) {
327
+ let body, title;
328
+ if (error.status === 403) {
329
+ body = 'You do not have permission to run this report (permission to GET all ' + $scope.modelName + ' records is required)';
330
+ title = 'Permission denied';
331
+ } else {
332
+ body = 'The server could not process the request';
333
+ title = 'Error';
334
+ }
335
+ $scope.showError(body, title);
328
336
  });
329
337
  };
330
338
 
@@ -1,3 +1,3 @@
1
- /*! forms-angular 2023-02-09 */
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,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("&nbsp;"," ").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("&nbsp;"," ").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)})}}}}}]);
1
+ /*! forms-angular 2023-03-02 */
2
+ "use strict";formsAngular.controller("AnalysisCtrl",["$rootScope","$window","$filter","$scope","$http","$location","cssFrameworkService","routingService",function(e,r,l,a,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(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",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("&nbsp;"," ").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("&nbsp;"," ").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)})}}}}}]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fng-reports",
3
- "version": "0.12.0-beta.201",
3
+ "version": "0.12.0-beta.203",
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.201",
35
+ "forms-angular": "0.12.0-beta.203",
36
36
  "grunt": "^1.5.3",
37
37
  "grunt-autoprefixer": "3.0.4",
38
38
  "grunt-concurrent": "3.0.0",
@@ -322,8 +322,16 @@ ${e.message}`);
322
322
  $scope.showError(JSON.stringify(response.data.error), 'Invalid Response Error');
323
323
  $scope.reportSchema.title = 'Error - see console log';
324
324
  }
325
- }, function () {
326
- $scope.showError('The server could not process the request', 'Error');
325
+ }, function (error) {
326
+ let body, title;
327
+ if (error.status === 403) {
328
+ body = 'You do not have permission to run this report (permission to GET all ' + $scope.modelName + ' records is required)';
329
+ title = 'Permission denied';
330
+ } else {
331
+ body = 'The server could not process the request';
332
+ title = 'Error';
333
+ }
334
+ $scope.showError(body, title);
327
335
  });
328
336
  };
329
337