fng-reports 0.12.0-beta.167 → 0.12.0-beta.168

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 2021-08-21 */
1
+ /*! forms-angular 2021-10-26 */
2
2
  'use strict';
3
3
 
4
4
  formsAngular.controller('AnalysisCtrl', ['$rootScope', '$window', '$filter', '$scope', '$http', '$location', 'cssFrameworkService', 'routingService',
@@ -1,3 +1,3 @@
1
- /*! forms-angular 2021-08-21 */
1
+ /*! forms-angular 2021-10-26 */
2
2
 
3
3
  "use strict";formsAngular.controller("AnalysisCtrl",["$rootScope","$window","$filter","$scope","$http","$location","cssFrameworkService","routingService",function(e,t,a,c,s,p,u,r){var d=!0,o=new ngGridPdfExportPlugin({inhibitButton:!0}),n=new ngGridCsvExportPlugin({inhibitButton:!0});if(angular.extend(c,r.parsePathFunc()(p.$$path)),c.reportSchema={columnDefs:[]},c.gridOptions={data:"report",columnDefs:c.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(t){c.gridApi=t,c.gridOptions.plugins.forEach(function(e){e.init(c,t.grid,null)}),t.selection.on.rowSelectionChanged(c,function(o){var e=c.reportSchema.drilldown;e&&(e=r.buildUrl(e.replace(/\|.+?\|/g,function(e){var t=e.slice(1,-1),r=/\((.+)\)/.exec(t);if(r){e=c.reportSchema.params[r[1]];return e?(c.param=c.record[r[1]],e.conversionExpression?c.$eval(e.conversionExpression):e.value):c.reportSchema.params[r[1]].value}return o.entity[t]})),window.location=e)})}},c.report=[],!c.reportSchemaName&&p.$$search.r)switch(p.$$search.r.slice(0,1)){case"[":c.reportSchema.pipeline=JSON.parse(p.$$search.r);break;case"{":angular.extend(c.reportSchema,JSON.parse(p.$$search.r));break;default:throw new Error("No report instructions specified")}c.getTotalVal=function(t,e){var r="",o=_.find(c.reportSchema.columnDefs,function(e){return e.field===t});if(o)switch(o.totalsRow){case void 0:break;case"$SUM":for(var n=0,i=0;i<c.report.length;i++)n+=c.report[i][t];r=n,e&&(r=a(e)(r));break;default:r=o.totalsRow}return r},c.$on("exportToPDF",function(){o.createPDF()}),c.$on("exportToCSV",function(){n.createCSV()}),c.extractFilter=function(e,t){var r,o,n;e.cellFilter&&(-1===(o=e.cellFilter.indexOf(":"))?n=e.cellFilter:(n=e.cellFilter.slice(0,o).trim(),"'"!==(r=e.cellFilter.slice(o+1,999).trim())[0]&&'"'!==r[0]||(r=r.slice(1,-1))),n=angular.element(document.body).injector().get("$filter")(n.trim()),t[e.field]={filter:n,filterParam:r})};var i,l,f,m=document.querySelector("div.report-grow");m&&(f=m.offsetLeft,i=m.offsetTop+f,l=(l=document.querySelector("div.ui-grid-header"))?l.clientHeight:31,f=Math.floor((t.innerHeight-i-l-f)/30),angular.element(m).css("height",30*f+"px"));var h=e.navScope;h.items=[{fn:o.createPDF,text:"Save as PDF"},{fn:n.createCSV,text:"Export as CSV"}],h.contextMenu="Report",c.titleWithSubstitutions=c.reportSchema.title,c.inhibitRefresh||(c.refreshQuery=function(){function i(e){return e.replace(/\|.+?\|/g,function(e){e=e.slice(1,-1),e=/\((.+)\)/.exec(e);return e?c.reportSchema.params[e[1]].value:""})}var e="/api/report/"+c.modelName,t="?",r=!1,o=p.$$url.match(/\?.*/);if(c.reportSchemaName?e+="/"+c.reportSchemaName:o&&(e+=t+o[0].slice(1),t="&",r=!0),c.paramSchema){for(var n in c.record)if(c.record.hasOwnProperty(n)){var l=c.reportSchema.params[n];if(c.record[n]&&""!==c.record[n])c.param=c.record[n],l.conversionExpression&&(c.param=c.$eval(l.conversionExpression)),e+=t+n+"="+c.param,t="&";else if(l.required)return}}else!r&&o&&(e+=t+o[0].slice(1),t="&");return s.get(e).then(function(e){var t,r,o=e.data;if(o.success){if(c.report=o.report,c.reportSchema=o.schema,c.reportSchema.title=c.reportSchema.title||c.modelName,c.titleWithSubstitutions=i(c.reportSchema.title),c.gridOptions.enableFiltering=!!c.reportSchema.filter,h&&h.items&&(h.items.length=2,c.reportSchema.menu&&c.reportSchema.menu.forEach(function(e){h.items.push(JSON.parse(i(JSON.stringify(e))))})),d&&(d=!1,c.$watch("reportSchema.columnDefs",function(e){var t=!1;if(e){for(var r,o=0;o<e.length;o++)e[o].totalsRow&&(t=!0),e[o].align&&(r="fng-"+e[o].align,e[o].cellClass=e[o].cellClass||"",-1===e[o].cellClass.indexOf(r)&&(e[o].cellClass=e[o].cellClass+" "+r));e.forEach(function(e){e.width&&"string"==typeof e.width&&-1!==e.width.indexOf("px")&&(e.width=parseInt(e.width.slice(0,-2)))}),c.gridOptions.columnDefs=e}c.gridOptions.showTotals=t,c.gridOptions.reallyShowFooter=t,c.gridOptions.footerRowHeight=55+(t?10:0)},!0),!c.paramSchema&&o.schema.params)){for(var n in c.paramSchema=[],c.record={},o.schema.params)o.schema.params.hasOwnProperty(n)&&((t=o.schema.params[n]).noInput||(r=c.paramSchema.push({name:n,id:"fp_"+n,label:t.label||a("titleCase")(n),type:t.type||"text",required:!0,add:t.add||void 0,size:t.size||("bs3"===u.frameWork?"large":"medium")}),"select"===t.type&&(c[n+"_Opts"]=t.enum,c.paramSchema[r-1].options=n+"_Opts")),(r=/^(\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(r[1])),c.record[n]=t.value);c.$watch("record",function(e,t){t!==e&&c.refreshQuery()},!0)}}else console.log(JSON.stringify(o)),c.reportSchema.title="Error - see console log"},function(e){console.log(JSON.stringify(e)),p.url("/404")})},c.refreshQuery()),c.showsContent=function(e){return/{{[\s]*COL_FIELD[\s]*}}/.test(e.replace(/(<([^>]+)>)/gi,""))},c.$on("$locationChangeStart",function(){delete h.contextMenu,delete h.items})}]);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,t,r){i.grid=t,i.scope=e,i.services=r},i.createCSV=function(){var e,t,r;e=i.scope.reportSchema.title+".csv",t="data:text/csv;charset=UTF-8,"+encodeURIComponent(i.prepareCSV()),(r=document.createElement("a")).download=e,r.href=t,t=new MouseEvent("click"),r.dispatchEvent(t)},i.prepareCSV=function(){function r(e,t){return null==e?"":t?t.filter(e,t.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 o="",n={};return angular.forEach(i.grid.columns,function(e){i.scope.extractFilter(e,n),e.visible&&(!e.colDef.cellTemplate||i.scope.showsContent(e.colDef.cellTemplate))&&(void 0===e.width||"*"===e.width||0<e.width)?(o+='"'+r(e.displayName)+'",',e.doCSVExport=!0):e.doCSVExport=!1}),o=e(o),angular.forEach(i.scope.gridApi.core.getVisibleRows(),function(t){t.visible&&(angular.forEach(i.grid.columns,function(e){e.doCSVExport&&(o+='"'+r(t.entity[e.field],n[e.field])+'",')}),o=e(o))}),o}}function ngGridPdfExportPlugin(o){var l=this;l.grid=null,l.scope=null,l.services=null,l.options=o,l.init=function(e,t,r){l.grid=t,l.scope=e,l.services=r,o.inhibitButton||(r=t.$root.find(".ngFooterPanel"),null!=(t=t.$root.find(".ngFooterPanel .pdf-data-link-span"))&&t.remove(),r.append('<button class="pdf-data-link-span">PDF Export</button>'),r.on("click",function(){l.createPDF()}))},l.createPDF=function(){var r=[],n=[],o=[],e=[],i={};angular.forEach(l.grid.columns,function(e,t){!e.visible||e.colDef.cellTemplate&&!l.scope.showsContent(e.colDef.cellTemplate)||(r.push(e.displayName),n.push(e.field)),e.colDef.totalsRow&&(o[e.field]=l.grid.getTotalVal(e.field,e.filter).toString()),l.scope.extractFilter(e,i)}),angular.forEach(l.scope.gridApi.core.getVisibleRows(),function(r){var o=[];r.visible&&(n.forEach(function(e){var t=r.entity[e];"string"==typeof(t=i[e]?i[e].filter(t,i[e].filterParam):t)&&(t=(t=(t=(t=(t=t.replace(/\u2019/g,"'")).replace(/\u2018/g,"'")).replace(/\u201c/g,'"')).replace(/\u201d/g,'"')).replace(/[^\x00-\xFF]/g,"")),o.push(t)}),e.push(o))});var t=new jspdf.jsPDF("landscape","mm","a4");t.autoTable({head:[r],body:e}),window.open(t.output("bloburl"))}}formsAngular.directive("ngTotalCell",["$compile","$domUtilityService",function(n,r){return{scope:!1,compile:function(){return{pre:function(e,t){var r=e.col.cellTemplate.match(/{{COL_FIELD \|(.+)}}/),r=r?e.col.cellTemplate.replace("COL_FIELD |"+r[1],'getTotalVal("'+e.col.field+'","'+r[1]+'")'):e.col.cellTemplate.replace(COL_FIELD,'getTotalVal("'+e.col.field+'")'),o=e.col.enableCellEdit?(o=(o=e.col.cellEditTemplate).replace(DISPLAY_CELL_TEMPLATE,r)).replace(EDITABLE_CELL_TEMPLATE,e.col.editableCellTemplate.replace(COL_FIELD,"row.entity."+e.col.field)):r,o=n(o)(e);e.enableCellSelection&&-1===o[0].className.indexOf("ngSelectionCell")&&(o[0].setAttribute("tabindex",0),o.addClass("ngCellElement")),t.append(o)},post:function(e,t){e.enableCellSelection&&e.domAccessProvider.selectionHandlers(e,t),e.$on("ngGridEventDigestCell",function(){r.digest(e)})}}}}}]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fng-reports",
3
- "version": "0.12.0-beta.167",
3
+ "version": "0.12.0-beta.168",
4
4
  "description": "Reporting plugin for forms-angular",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,16 +12,19 @@
12
12
  "angular",
13
13
  "reporting"
14
14
  ],
15
+ "scripts": {
16
+ "test": "grunt build"
17
+ },
15
18
  "author": "Mark Chapman <support@forms-angular.org>",
16
19
  "license": "MIT",
17
20
  "bugs": {
18
21
  "url": "https://github.com/forms-angular/fng-reports/issues"
19
22
  },
20
23
  "dependencies": {
21
- "angular-ui-grid": "4.10.2",
24
+ "angular-ui-grid": "4.11.0",
22
25
  "jquery": "^3.6.0",
23
- "jspdf": "2.3.1",
24
- "jspdf-autotable": "^3.5.14"
26
+ "jspdf": "2.4.0",
27
+ "jspdf-autotable": "^3.5.23"
25
28
  },
26
29
  "devDependencies": {
27
30
  "angular": "^1.8.2",
@@ -29,14 +32,14 @@
29
32
  "angular-messages": "1.8.2",
30
33
  "angular-mocks": "1.8.2",
31
34
  "angular-sanitize": "1.8.2",
32
- "forms-angular": "0.12.0-beta.159",
35
+ "forms-angular": "0.12.0-beta.168",
33
36
  "grunt": "^1.4.1",
34
37
  "grunt-autoprefixer": "3.0.4",
35
38
  "grunt-concurrent": "3.0.0",
36
39
  "grunt-contrib-clean": "2.0.0",
37
- "grunt-contrib-concat": "1.0.1",
40
+ "grunt-contrib-concat": "2.0.0",
38
41
  "grunt-contrib-copy": "1.0.0",
39
- "grunt-contrib-jshint": "3.0.0",
42
+ "grunt-contrib-jshint": "3.1.1",
40
43
  "grunt-contrib-uglify": "5.0.1",
41
44
  "grunt-contrib-watch": "^1.1.0",
42
45
  "grunt-karma": "4.0.2",
@@ -44,8 +47,8 @@
44
47
  "grunt-ng-annotate": "4.0.0",
45
48
  "grunt-rev": "0.1.0",
46
49
  "grunt-usemin": "github:mchapman/grunt-usemin",
47
- "jasmine-core": "3.7.1",
48
- "karma": "^6.3.4",
50
+ "jasmine-core": "3.10.1",
51
+ "karma": "^6.3.6",
49
52
  "karma-chrome-launcher": "3.1.0",
50
53
  "karma-jasmine": "4.0.1",
51
54
  "karma-junit-reporter": "2.0.1",