Skip to content

Commit

Permalink
Fixed NathanaelA#201, absoluteY now gets reset whenever a frNewPage h…
Browse files Browse the repository at this point in the history
…appens.
  • Loading branch information
Frustrated-Programmer committed Aug 23, 2020
1 parent ca7aff6 commit c6c4baa
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion lib/fluentReportsBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,19 @@ const BlobStream = require("./third-party/blob-stream");
*/
class ReportRunnable
{
get newPageSubtraction(){
return this._newPageSubtractionFunc();
}
set newPageSubtraction(val){
this._newPageSubtractionFunc(val);
}
constructor(options) {
if(typeof options.newPageSubtraction === "function"){
this._newPageSubtractionFunc = options.newPageSubtraction;
}
else{
this._newPageSubtractionFunc = ()=>{return 0;}
}
if(options.headerFooter) {
this._settings = options.headerFooter;
} else {
Expand Down Expand Up @@ -454,7 +466,14 @@ class ReportRunnable
}

_runSetting(setting, info, callback) {

if(setting && setting.settings) {
if(setting.settings.absoluteY){
setting.settings.absoluteY -= this._newPageSubtraction;
}
if(setting.settings.top){
setting.settings.top -= this._newPageSubtraction;
}
}
// Skip anything set to skip: true
if (setting.skip === true) { return callback(); }

Expand Down Expand Up @@ -486,11 +505,13 @@ class ReportRunnable
case 'newPage':
if(typeof setting.active === "boolean" && setting.active === true) {
info.report.newPage(!!setting.saveOptions, callback);
this.newPageSubtraction += (setting.settings && setting.settings.absoluteY && setting.settings.absoluteY + 20) || 20;
}
else if(setting.active != null && typeof setting.active === "object" && setting.active.type === "function") {
this._handleFunction(setting.active, info,(error, output) => {
if (output) {
info.report.newPage(!!setting.saveOptions, callback);
this.newPageSubtraction += (setting.settings && setting.settings.absoluteY && setting.settings.absoluteY + 20) || 20;
}
else {
callback();
Expand Down Expand Up @@ -558,6 +579,15 @@ class ReportBuilder {
* @param {Object?} reportData
* @returns {Report|ReportBuilder}
*/
_updateNewPageSubtraction(val){
console.log("Update:",val)
if(!val) {
return this._newPageSubtraction
}
else{
this._newPageSubtraction+=val;
}
}
constructor(ReportDesignLayout, reportData) {

this._primaryReportGroup = null;
Expand Down Expand Up @@ -585,6 +615,7 @@ class ReportBuilder {
}
}

this._newPageSubtraction = 0;
this._formatterFunctions = {};
if(reportDesignLayout.formatterFunctions){
for (let key in reportDesignLayout.formatterFunctions) {
Expand Down Expand Up @@ -778,6 +809,7 @@ class ReportBuilder {
}
report[type]( new ReportRunnable({
formatterFunctions: this._formatterFunctions,
newPageSubtraction:this._updateNewPageSubtraction,
headerFooter: {children: headerFooter}
}) );

Expand All @@ -801,6 +833,7 @@ class ReportBuilder {
}
report[type]( new ReportRunnable({
formatterFunctions: this._formatterFunctions,
newPageSubtraction:this._updateNewPageSubtraction,
headerFooter
}) , options);

Expand All @@ -813,6 +846,7 @@ class ReportBuilder {
} else {
report[type](new ReportRunnable({
formatterFunctions: this._formatterFunctions,
newPageSubtraction:this._updateNewPageSubtraction,
headerFooter: {children: [headerFooter]}
}));
}
Expand Down

0 comments on commit c6c4baa

Please sign in to comment.