Skip to content

Commit

Permalink
Merge pull request #184 from digi-serve/widget/pdfImporter
Browse files Browse the repository at this point in the history
+Apply submit rule to the PDF importer widget
  • Loading branch information
wongpratan authored Aug 16, 2023
2 parents c77fd48 + 925dafc commit f544670
Showing 1 changed file with 30 additions and 12 deletions.
42 changes: 30 additions & 12 deletions views/ABViewPDFImporterCore.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
const ABViewWidget = require("../../platform/views/ABViewWidget");

const ABSubmitRule = require("../../rules/ABViewRuleListFormSubmitRules");

const ABViewPDFImporterPropertyComponentDefaults = {
dataviewID: null,
fieldID: null,

// [{
// action: {string},
// when: [
// {
// fieldId: {UUID},
// comparer: {string},
// value: {string}
// }
// ],
// value: {string}
// }]
submitRules: [],
};

const ABViewDefaults = {
Expand Down Expand Up @@ -44,18 +59,6 @@ module.exports = class ABViewPDFImporterCore extends ABViewWidget {
this.settings.fieldID =
this.settings.fieldID ??
ABViewPDFImporterPropertyComponentDefaults.fieldID;

// Convert to boolean
// this.settings.removeMissed = JSON.parse(
// this.settings.removeMissed ||
// ABViewPDFImporterPropertyComponentDefaults.removeMissed
// );

// "0" -> 0
// this.settings.height = parseInt(
// this.settings.height ||
// ABViewPDFImporterPropertyComponentDefaults.height
// );
}

/**
Expand All @@ -81,4 +84,19 @@ module.exports = class ABViewPDFImporterCore extends ABViewWidget {
componentList() {
return [];
}

doSubmitRules(rowDatas) {
const object = this.datacollection.datasource;

const SubmitRules = new ABSubmitRule();
SubmitRules.formLoad(this);
SubmitRules.fromSettings(this.settings.submitRules);
SubmitRules.objectLoad(object);

if (rowDatas && !Array.isArray(rowDatas)) rowDatas = [rowDatas];

rowDatas?.forEach((rowData) => {
SubmitRules.process({ data: rowData, form: this });
});
}
};

0 comments on commit f544670

Please sign in to comment.