fng-reports 0.12.0-beta.225 → 0.12.0-beta.227

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-06-27 */
1
+ /*! forms-angular 2023-09-01 */
2
2
  'use strict';
3
3
 
4
4
  formsAngular.controller('AnalysisCtrl', ['$rootScope', '$window', '$filter', '$scope', '$http', '$location', 'CssFrameworkService', 'RoutingService',
@@ -65,29 +65,37 @@ formsAngular.controller('AnalysisCtrl', ['$rootScope', '$window', '$filter', '$s
65
65
  });
66
66
  },
67
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
68
  http: function ($event, method, url) {
69
+ /*
70
+ * This allows us to make an arbitrary http request from a cell template. Example:
71
+ * <div class="ui-grid-cell-contents">
72
+ * <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">
73
+ * <span class="glyphicon glyphicon-remove"></span> Cancel
74
+ * </button>
75
+ * </div>
76
+ * The value of any attribute beginning with data will replace the corresponding :attribute in the url,
77
+ * so in this case the :id in the url will be replaced by the value of the data-id attribute.
78
+ */
79
79
  $event.currentTarget.getAttributeNames().forEach(a => {
80
80
  if (a.startsWith('data-')) {
81
81
  url = url.replace(`:${a.slice(5)}`, $event.currentTarget.getAttribute(a));
82
82
  }
83
83
  });
84
- if ($event.currentTarget.getAttribute('data-disable-button') === 'true') {
84
+ let disabledText = $event.currentTarget.getAttribute('data-disable-button');
85
+ if (disabledText) {
85
86
  $event.currentTarget.setAttribute('disabled', 'disabled');
87
+ if (disabledText !== 'true') {
88
+ $event.currentTarget.innerText = disabledText;
89
+ }
86
90
  }
87
- $http({
91
+ var configObj = {
88
92
  method: method,
89
93
  url: url,
90
- });
94
+ };
95
+ if (['POST', 'PUT', 'PATCH'].indexOf(method) !== -1) {
96
+ configObj.data = {val: $event.currentTarget.getAttribute('data-data') || {}};
97
+ }
98
+ $http(configObj);
91
99
  $event.stopPropagation();
92
100
  }
93
101
  }
@@ -1,3 +1,3 @@
1
- /*! forms-angular 2023-06-27 */
1
+ /*! forms-angular 2023-09-01 */
2
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("&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(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("&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,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)})}}}}}]);
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)))});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")||{}}),s(o),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("&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(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("&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,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.225",
3
+ "version": "0.12.0-beta.227",
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": "file:../forms-angular/forms-angular-0.12.0-beta.225.tgz",
35
+ "forms-angular": "file:../forms-angular/forms-angular-0.12.0-beta.227.tgz",
36
36
  "grunt": "^1.5.3",
37
37
  "grunt-autoprefixer": "3.0.4",
38
38
  "grunt-concurrent": "3.0.0",
@@ -64,29 +64,37 @@ formsAngular.controller('AnalysisCtrl', ['$rootScope', '$window', '$filter', '$s
64
64
  });
65
65
  },
66
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
67
  http: function ($event, method, url) {
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
78
  $event.currentTarget.getAttributeNames().forEach(a => {
79
79
  if (a.startsWith('data-')) {
80
80
  url = url.replace(`:${a.slice(5)}`, $event.currentTarget.getAttribute(a));
81
81
  }
82
82
  });
83
- if ($event.currentTarget.getAttribute('data-disable-button') === 'true') {
83
+ let disabledText = $event.currentTarget.getAttribute('data-disable-button');
84
+ if (disabledText) {
84
85
  $event.currentTarget.setAttribute('disabled', 'disabled');
86
+ if (disabledText !== 'true') {
87
+ $event.currentTarget.innerText = disabledText;
88
+ }
85
89
  }
86
- $http({
90
+ var configObj = {
87
91
  method: method,
88
92
  url: url,
89
- });
93
+ };
94
+ if (['POST', 'PUT', 'PATCH'].indexOf(method) !== -1) {
95
+ configObj.data = {val: $event.currentTarget.getAttribute('data-data') || {}};
96
+ }
97
+ $http(configObj);
90
98
  $event.stopPropagation();
91
99
  }
92
100
  }