fng-reports 0.12.0-beta.282 → 0.12.0-beta.283

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 2024-06-21 */
1
+ /*! forms-angular 2024-07-01 */
2
2
  'use strict';
3
3
 
4
4
  formsAngular.controller('AnalysisCtrl', ['$rootScope', '$window', '$q', '$filter', '$scope', '$http', '$location', 'CssFrameworkService', 'RoutingService', 'uiGridConstants',
@@ -38,7 +38,7 @@ formsAngular.controller('AnalysisCtrl', ['$rootScope', '$window', '$q', '$filter
38
38
  let elm = event.target;
39
39
  do {
40
40
  elm = elm.parentElement;
41
- inATag = (elm.tagName === 'A');
41
+ inATag = (elm && elm.tagName === 'A');
42
42
  } while (elm && !inATag && elm !== rowItem);
43
43
  if (!inATag) {
44
44
  url = RoutingService.buildUrl(url.replace(/\|.+?\|/g, function (match) {
@@ -1,3 +1,3 @@
1
- /*! forms-angular 2024-06-21 */
1
+ /*! forms-angular 2024-07-01 */
2
2
  "use strict";formsAngular.controller("AnalysisCtrl",["$rootScope","$window","$q","$filter","$scope","$http","$location","CssFrameworkService","RoutingService","uiGridConstants",function(e,r,s,i,c,p,l,n,a,u){var d=!0,t=new ngGridPdfExportPlugin({inhibitButton:!0}),o=new ngGridCsvExportPlugin({inhibitButton:!0});function f(r){try{return JSON.parse(r)}catch(e){throw new Error(`Invalid JSON ${r}
3
- `+e.message)}}if(angular.extend(c,a.parsePathFunc()(l.$$path)),c.reportSchema={},c.gridOptions={enableFiltering:!1,data:"report",columnDefs:c.reportSchema.columnDefs,showColumnMenu:!0,enableRowHeaderSelection:!1,reallyShowFooter:!1,showTotals:!0,enableColumnResizing:!0,footerRowHeight:65,multiSelect:!1,plugins:[t,o],onRegisterApi:function(r){c.gridApi=r,c.gridOptions.plugins.forEach(function(e){e.init(c,r.grid,null)}),r.selection.on.rowSelectionChanged(c,function(o,t){var n=c.reportSchema.drilldown;if(n)if("string"==typeof n){let e="A"===t.target.tagName,r=t.target;for(;r=r.parentElement,e="A"===r.tagName,r&&!e&&r!==o;);e||(n=a.buildUrl(n.replace(/\|.+?\|/g,function(e){var r,e=e.slice(1,-1),t=/\((.+)\)/.exec(e);return t?(r=c.reportSchema.params[t[1]])&&c.record?(c.param=c.record[t[1]],r.conversionExpression?c.$eval(r.conversionExpression):r.value):c.reportSchema.params[t[1]]?c.reportSchema.params[t[1]].value||"":(console.error("No value for "+t[1]),"ERR"):o.entity[e]})),window.location=n)}else console.error("Was expecting drilldown to be string but it was "+typeof n+" ("+n+")")})},appScopeProvider:{http:function(r,e,t){r.currentTarget.getAttributeNames().forEach(e=>{e.startsWith("data-")&&(t=t.replace(":"+e.slice(5),r.currentTarget.getAttribute(e)))});var o=r.currentTarget.getAttribute("data-disable-button"),o=(o&&(r.currentTarget.setAttribute("disabled","disabled"),"true"!==o)&&(r.currentTarget.innerText=o),{method:e,url:t});-1!==["POST","PUT","PATCH"].indexOf(e)&&(o.data={val:r.currentTarget.getAttribute("data-data")||{}}),p(o).then(function(e){200!==e.status&&c.showError(e.statusText,"Error")}),r.stopPropagation()}}},c.report=[],!c.reportSchemaName&&l.$$search.r)switch(l.$$search.r.slice(0,1)){case"[":c.reportSchema.pipeline=f(l.$$search.r);break;case"{":angular.extend(c.reportSchema,f(l.$$search.r));break;default:throw new Error("No report instructions specified")}function m(e){for(var r in c.paramSchema=[],c.record={},e){var t,o;e.hasOwnProperty(r)&&((t=e[r]).noInput||(o=c.paramSchema.push({name:r,id:"fp_"+r,label:t.label||i("titleCase")(r),type:t.type||"text",required:!0,add:t.add||void 0,size:t.size||("bs3"===n.frameWork?"large":"medium")}),"select"===t.type&&(c[r+"_Opts"]=t.enum,c.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[0])),c.record[r]=t.value)}c.$watch("record",function(e,r){r!==e&&c.refreshQuery()},!0)}c.getTotalVal=function(r,e){var t="",o=_.find(c.reportSchema.columnDefs,function(e){return e.field===r});if(o)switch(o.totalsRow){case void 0:break;case"$SUM":for(var n=0,a=0;a<c.report.length;a++)n+=c.report[a][r];t=n,e&&(t=i(e)(t));break;default:t=o.totalsRow}return t},c.$on("exportToPDF",function(){t.createPDF()}),c.$on("exportToCSV",function(){o.createCSV()}),c.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 g,h,S,v=document.querySelector("div.report-grow"),E=(v&&(g=v.offsetLeft,h=v.offsetTop+g,S=(S=document.querySelector("div.ui-grid-header"))?S.clientHeight:31,r=Math.floor((r.innerHeight-h-S-g)/30),angular.element(v).css("height",30*r+"px")),e.navScope);E.items=[{fn:t.createPDF,text:"Save as PDF"},{fn:o.createCSV,text:"Export as CSV"}],E.contextMenu="Report",E.contextMenuId="reportMenu",c.titleWithSubstitutions=c.reportSchema.title,c.inhibitRefresh||(c.refreshQuery=function(){function n(o){function l(e,r){let t;return e instanceof Date||"string"==typeof e&&e.match(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3} \d{4}/)&&(e=new Date(e.replace(" ","+"))),e instanceof Date?t=r?(c.param=e,c.$eval(r)):e.toISOString():e}return s(function(e){let i=[];o.replace(/\|.+?\|/g,function(e){var r=e.slice(1,-1),t=/(.*)\((.+)\)/.exec(r);let o;if(t)try{var n=c.reportSchema.params[t[2]],a=n.value;(o=2<t.length&&""!==t[1]?p.get(`/api/${t[1]}/${a}/list`).then(function(e){return e&&200===e.status&&e.data?e.data.list:""}):o)?i.push(o):i.push(Promise.resolve(l(a,n.conversionExpression)))}catch(e){console.error(e),i.push("Error in fng-reports: "+e.message)}else{t=c.reportSchema.params[r];t?i.push(Promise.resolve(l(t.value,t.conversionExpression))):(console.log("Cannot find param "+r),i.push(Promise.resolve("ERR")))}return e}),Promise.all(i).then(function(r){let t=0;e(o.replace(/\|.+?\|/g,function(){var e=r[t];return t+=1,e}))})})}var e="/api/report/"+c.modelName,r="?",t=!1,o=l.$$url.match(/\?.*/);if(c.reportSchemaName?e+="/"+c.reportSchemaName:o&&(d&&(c.paramSchema=JSON.parse(l.search().r).params,m(c.paramSchema)),e+=r+o[0].slice(1),r="&",t=!0),c.paramSchema){for(var a in c.record)if(c.record.hasOwnProperty(a)){var i=c.reportSchema.params[a];if(c.record[a]&&""!==c.record[a])c.param=c.record[a],i.conversionExpression&&(c.param=c.$eval(i.conversionExpression)),e+=r+a+"="+c.param,r="&";else if(i.required)return}}else!t&&o&&(e+=r+o[0].slice(1),r="&");return p.get(e).then(function(e){if(e&&e.data&&e.data.success){var r,t=e.data;if(c.report=t.report,c.reportSchema=t.schema,d){if(d=!1,t.schema.columnDefs&&0<t.schema.columnDefs.length)for(const o of t.schema.columnDefs)o.align&&(r="fng-"+o.align,o.cellClass=o.cellClass||"",-1===o.cellClass.indexOf(r))&&(o.cellClass=o.cellClass+" "+r),o.aggregationTypeStr&&(c.gridOptions.showColumnFooter=!0,o.aggregationType=u.aggregationTypes[o.aggregationTypeStr],o.aggregationHideLabel="sum"===o.aggregationTypeStr,o.footerCellFilter=o.cellFilter,o.footerCellClass=o.cellClass),c.gridOptions.columnDefs.push(o),o.width&&"string"==typeof o.width&&-1!==o.width.indexOf("px")&&(o.width=parseInt(o.width.slice(0,-2)));!c.paramSchema&&t.schema.params&&"1"!==l.$$search.noinput&&m(t.schema.params)}c.reportSchema.title=c.reportSchema.title||c.modelName,n(c.reportSchema.title).then(function(e){c.titleWithSubstitutions=e}),c.gridOptions.enableFiltering=!!c.reportSchema.filter,E&&E.items&&(E.items.length=2,c.reportSchema.menu)&&c.reportSchema.menu.forEach(function(e){n(JSON.stringify(e)).then(function(e){E.items.push(JSON.parse(e))})})}else c.showError(JSON.stringify(e.data.error),"Invalid Response Error"),c.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 "+c.modelName+" records is required)","Permission denied"):(r="The server could not process the request<br />Details:<br />"+e.data,"Error"),c.showError(r,t)})},c.refreshQuery()),c.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)},c.$on("$locationChangeStart",function(){delete E.contextMenu,delete E.items}),c.showError=function(r,e){if(c.alertTitle=e||"Error!","string"==typeof r)c.errorMessage=r;else if(r)if(r.message&&"string"==typeof r.message)c.errorMessage=r.message;else if(r.data&&r.data.message)c.errorMessage=r.data.message;else try{c.errorMessage=JSON.stringify(r)}catch(e){c.errorMessage=r}else c.errorMessage="An error occurred - that's all we got. Sorry.";c.errorHideTimer=window.setTimeout(function(){c.dismissError(),c.$digest()},3500+1e3*(c.alertTitle+c.errorMessage).length/50),c.errorVisible=!0,window.setTimeout(()=>{c.$digest()})},c.clearTimeout=function(){c.errorHideTimer&&(clearTimeout(c.errorHideTimer),delete c.errorHideTimer)},c.dismissError=function(){c.clearTimeout,c.errorVisible=!1,delete c.errorMessage,delete c.alertTitle},c.stickError=function(){clearTimeout(c.errorHideTimer)}}]);var COL_FIELD=/COL_FIELD/g;function ngGridCsvExportPlugin(e){var i=this;i.grid=null,i.scope=null,i.services=null,i.init=function(e,r,t){i.grid=r,i.scope=e,i.services=t},i.createCSV=function(){var e,r,t;e=i.scope.reportSchema.title+".csv",r="data:text/csv;charset=UTF-8,"+encodeURIComponent(i.prepareCSV()),(t=document.createElement("a")).download=e,t.href=r,e=new MouseEvent("click"),t.dispatchEvent(e)},i.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="",a={};return angular.forEach(i.grid.columns,function(e){var r;i.scope.extractFilter(e,a),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=i.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(i.scope.gridApi.core.getVisibleRows(),function(t){t.visible&&(angular.forEach(i.grid.columns,function(r){if(r.doCSVExport){let e=t.entity[r.field];"function"==typeof r.doCSVExport&&(e=r.doCSVExport(e)),n+='"'+o(e,a[r.field])+'",'}}),n=e(n))}),n}}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=[],n=[],e=[],a={},i={},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),n.push(e.field),i[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,l.grid.getTotalVal(e.field,e.filter).toString()),l.scope.extractFilter(e,a)}),angular.forEach(l.scope.gridApi.core.getVisibleRows(),function(t){var o=[];t.visible&&(n.forEach(function(e){var r=t.entity[e];a[e]&&(r=a[e].filter(r,a[e].filterParam)),"string"==typeof(r=i[e]?i[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(c,a.parsePathFunc()(l.$$path)),c.reportSchema={},c.gridOptions={enableFiltering:!1,data:"report",columnDefs:c.reportSchema.columnDefs,showColumnMenu:!0,enableRowHeaderSelection:!1,reallyShowFooter:!1,showTotals:!0,enableColumnResizing:!0,footerRowHeight:65,multiSelect:!1,plugins:[t,o],onRegisterApi:function(r){c.gridApi=r,c.gridOptions.plugins.forEach(function(e){e.init(c,r.grid,null)}),r.selection.on.rowSelectionChanged(c,function(o,t){var n=c.reportSchema.drilldown;if(n)if("string"==typeof n){let e="A"===t.target.tagName,r=t.target;for(;r=r.parentElement,e=r&&"A"===r.tagName,r&&!e&&r!==o;);e||(n=a.buildUrl(n.replace(/\|.+?\|/g,function(e){var r,e=e.slice(1,-1),t=/\((.+)\)/.exec(e);return t?(r=c.reportSchema.params[t[1]])&&c.record?(c.param=c.record[t[1]],r.conversionExpression?c.$eval(r.conversionExpression):r.value):c.reportSchema.params[t[1]]?c.reportSchema.params[t[1]].value||"":(console.error("No value for "+t[1]),"ERR"):o.entity[e]})),window.location=n)}else console.error("Was expecting drilldown to be string but it was "+typeof n+" ("+n+")")})},appScopeProvider:{http:function(r,e,t){r.currentTarget.getAttributeNames().forEach(e=>{e.startsWith("data-")&&(t=t.replace(":"+e.slice(5),r.currentTarget.getAttribute(e)))});var o=r.currentTarget.getAttribute("data-disable-button"),o=(o&&(r.currentTarget.setAttribute("disabled","disabled"),"true"!==o)&&(r.currentTarget.innerText=o),{method:e,url:t});-1!==["POST","PUT","PATCH"].indexOf(e)&&(o.data={val:r.currentTarget.getAttribute("data-data")||{}}),p(o).then(function(e){200!==e.status&&c.showError(e.statusText,"Error")}),r.stopPropagation()}}},c.report=[],!c.reportSchemaName&&l.$$search.r)switch(l.$$search.r.slice(0,1)){case"[":c.reportSchema.pipeline=f(l.$$search.r);break;case"{":angular.extend(c.reportSchema,f(l.$$search.r));break;default:throw new Error("No report instructions specified")}function m(e){for(var r in c.paramSchema=[],c.record={},e){var t,o;e.hasOwnProperty(r)&&((t=e[r]).noInput||(o=c.paramSchema.push({name:r,id:"fp_"+r,label:t.label||i("titleCase")(r),type:t.type||"text",required:!0,add:t.add||void 0,size:t.size||("bs3"===n.frameWork?"large":"medium")}),"select"===t.type&&(c[r+"_Opts"]=t.enum,c.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[0])),c.record[r]=t.value)}c.$watch("record",function(e,r){r!==e&&c.refreshQuery()},!0)}c.getTotalVal=function(r,e){var t="",o=_.find(c.reportSchema.columnDefs,function(e){return e.field===r});if(o)switch(o.totalsRow){case void 0:break;case"$SUM":for(var n=0,a=0;a<c.report.length;a++)n+=c.report[a][r];t=n,e&&(t=i(e)(t));break;default:t=o.totalsRow}return t},c.$on("exportToPDF",function(){t.createPDF()}),c.$on("exportToCSV",function(){o.createCSV()}),c.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 g,h,S,v=document.querySelector("div.report-grow"),E=(v&&(g=v.offsetLeft,h=v.offsetTop+g,S=(S=document.querySelector("div.ui-grid-header"))?S.clientHeight:31,r=Math.floor((r.innerHeight-h-S-g)/30),angular.element(v).css("height",30*r+"px")),e.navScope);E.items=[{fn:t.createPDF,text:"Save as PDF"},{fn:o.createCSV,text:"Export as CSV"}],E.contextMenu="Report",E.contextMenuId="reportMenu",c.titleWithSubstitutions=c.reportSchema.title,c.inhibitRefresh||(c.refreshQuery=function(){function n(o){function l(e,r){let t;return e instanceof Date||"string"==typeof e&&e.match(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3} \d{4}/)&&(e=new Date(e.replace(" ","+"))),e instanceof Date?t=r?(c.param=e,c.$eval(r)):e.toISOString():e}return s(function(e){let i=[];o.replace(/\|.+?\|/g,function(e){var r=e.slice(1,-1),t=/(.*)\((.+)\)/.exec(r);let o;if(t)try{var n=c.reportSchema.params[t[2]],a=n.value;(o=2<t.length&&""!==t[1]?p.get(`/api/${t[1]}/${a}/list`).then(function(e){return e&&200===e.status&&e.data?e.data.list:""}):o)?i.push(o):i.push(Promise.resolve(l(a,n.conversionExpression)))}catch(e){console.error(e),i.push("Error in fng-reports: "+e.message)}else{t=c.reportSchema.params[r];t?i.push(Promise.resolve(l(t.value,t.conversionExpression))):(console.log("Cannot find param "+r),i.push(Promise.resolve("ERR")))}return e}),Promise.all(i).then(function(r){let t=0;e(o.replace(/\|.+?\|/g,function(){var e=r[t];return t+=1,e}))})})}var e="/api/report/"+c.modelName,r="?",t=!1,o=l.$$url.match(/\?.*/);if(c.reportSchemaName?e+="/"+c.reportSchemaName:o&&(d&&(c.paramSchema=JSON.parse(l.search().r).params,m(c.paramSchema)),e+=r+o[0].slice(1),r="&",t=!0),c.paramSchema){for(var a in c.record)if(c.record.hasOwnProperty(a)){var i=c.reportSchema.params[a];if(c.record[a]&&""!==c.record[a])c.param=c.record[a],i.conversionExpression&&(c.param=c.$eval(i.conversionExpression)),e+=r+a+"="+c.param,r="&";else if(i.required)return}}else!t&&o&&(e+=r+o[0].slice(1),r="&");return p.get(e).then(function(e){if(e&&e.data&&e.data.success){var r,t=e.data;if(c.report=t.report,c.reportSchema=t.schema,d){if(d=!1,t.schema.columnDefs&&0<t.schema.columnDefs.length)for(const o of t.schema.columnDefs)o.align&&(r="fng-"+o.align,o.cellClass=o.cellClass||"",-1===o.cellClass.indexOf(r))&&(o.cellClass=o.cellClass+" "+r),o.aggregationTypeStr&&(c.gridOptions.showColumnFooter=!0,o.aggregationType=u.aggregationTypes[o.aggregationTypeStr],o.aggregationHideLabel="sum"===o.aggregationTypeStr,o.footerCellFilter=o.cellFilter,o.footerCellClass=o.cellClass),c.gridOptions.columnDefs.push(o),o.width&&"string"==typeof o.width&&-1!==o.width.indexOf("px")&&(o.width=parseInt(o.width.slice(0,-2)));!c.paramSchema&&t.schema.params&&"1"!==l.$$search.noinput&&m(t.schema.params)}c.reportSchema.title=c.reportSchema.title||c.modelName,n(c.reportSchema.title).then(function(e){c.titleWithSubstitutions=e}),c.gridOptions.enableFiltering=!!c.reportSchema.filter,E&&E.items&&(E.items.length=2,c.reportSchema.menu)&&c.reportSchema.menu.forEach(function(e){n(JSON.stringify(e)).then(function(e){E.items.push(JSON.parse(e))})})}else c.showError(JSON.stringify(e.data.error),"Invalid Response Error"),c.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 "+c.modelName+" records is required)","Permission denied"):(r="The server could not process the request<br />Details:<br />"+e.data,"Error"),c.showError(r,t)})},c.refreshQuery()),c.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)},c.$on("$locationChangeStart",function(){delete E.contextMenu,delete E.items}),c.showError=function(r,e){if(c.alertTitle=e||"Error!","string"==typeof r)c.errorMessage=r;else if(r)if(r.message&&"string"==typeof r.message)c.errorMessage=r.message;else if(r.data&&r.data.message)c.errorMessage=r.data.message;else try{c.errorMessage=JSON.stringify(r)}catch(e){c.errorMessage=r}else c.errorMessage="An error occurred - that's all we got. Sorry.";c.errorHideTimer=window.setTimeout(function(){c.dismissError(),c.$digest()},3500+1e3*(c.alertTitle+c.errorMessage).length/50),c.errorVisible=!0,window.setTimeout(()=>{c.$digest()})},c.clearTimeout=function(){c.errorHideTimer&&(clearTimeout(c.errorHideTimer),delete c.errorHideTimer)},c.dismissError=function(){c.clearTimeout,c.errorVisible=!1,delete c.errorMessage,delete c.alertTitle},c.stickError=function(){clearTimeout(c.errorHideTimer)}}]);var COL_FIELD=/COL_FIELD/g;function ngGridCsvExportPlugin(e){var i=this;i.grid=null,i.scope=null,i.services=null,i.init=function(e,r,t){i.grid=r,i.scope=e,i.services=t},i.createCSV=function(){var e,r,t;e=i.scope.reportSchema.title+".csv",r="data:text/csv;charset=UTF-8,"+encodeURIComponent(i.prepareCSV()),(t=document.createElement("a")).download=e,t.href=r,e=new MouseEvent("click"),t.dispatchEvent(e)},i.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="",a={};return angular.forEach(i.grid.columns,function(e){var r;i.scope.extractFilter(e,a),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=i.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(i.scope.gridApi.core.getVisibleRows(),function(t){t.visible&&(angular.forEach(i.grid.columns,function(r){if(r.doCSVExport){let e=t.entity[r.field];"function"==typeof r.doCSVExport&&(e=r.doCSVExport(e)),n+='"'+o(e,a[r.field])+'",'}}),n=e(n))}),n}}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=[],n=[],e=[],a={},i={},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),n.push(e.field),i[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,l.grid.getTotalVal(e.field,e.filter).toString()),l.scope.extractFilter(e,a)}),angular.forEach(l.scope.gridApi.core.getVisibleRows(),function(t){var o=[];t.visible&&(n.forEach(function(e){var r=t.entity[e];a[e]&&(r=a[e].filter(r,a[e].filterParam)),"string"==typeof(r=i[e]?i[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.282",
3
+ "version": "0.12.0-beta.283",
4
4
  "description": "Reporting plugin for forms-angular",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,7 +33,7 @@
33
33
  "angular-messages": "1.8.3",
34
34
  "angular-mocks": "1.8.3",
35
35
  "angular-sanitize": "1.8.3",
36
- "forms-angular": "0.12.0-beta.282",
36
+ "forms-angular": "0.12.0-beta.283",
37
37
  "grunt": "^1.6.1",
38
38
  "grunt-autoprefixer": "3.0.4",
39
39
  "grunt-concurrent": "3.0.0",
@@ -37,7 +37,7 @@ formsAngular.controller('AnalysisCtrl', ['$rootScope', '$window', '$q', '$filter
37
37
  let elm = event.target;
38
38
  do {
39
39
  elm = elm.parentElement;
40
- inATag = (elm.tagName === 'A');
40
+ inATag = (elm && elm.tagName === 'A');
41
41
  } while (elm && !inATag && elm !== rowItem);
42
42
  if (!inATag) {
43
43
  url = RoutingService.buildUrl(url.replace(/\|.+?\|/g, function (match) {