Skip to content

Commit

Permalink
Merge pull request #266 from digi-serve/jh/fixFormIOFormatData
Browse files Browse the repository at this point in the history
Fix our formio formatting to display the proper data
  • Loading branch information
Hiro-Nakamura authored Nov 21, 2024
2 parents de08a13 + 4445e79 commit d9a29f9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions ABObjectCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -982,19 +982,26 @@ module.exports = class ABObjectCore extends ABMLClass {
// ['{colId1}', ..., '{colIdN}']
var colIds = labelData.match(/\{[^}]+\}/g);

// Using rawString to catch actual values we are pulling out.
// the label data might have additional characters "-" and such that will
// remain, and doing a .trim() on that wont catch that the label data
// is actually empty.
let rawString = "";
if (colIds && colIds.forEach) {
colIds.forEach((colId) => {
var colIdNoBracket = colId.replace("{", "").replace("}", "");

var field = this.fieldByID(colIdNoBracket);
if (field == null) return;

labelData = labelData.replace(colId, field.format(rowData) || "");
let valField = field.format(rowData) || "";
labelData = labelData.replace(colId, valField);
rawString = `${rawString}${valField}`;
});
}

// if label is empty, then show .id
if (!labelData.trim()) {
if (!rawString.trim()) {
let labelSettings = this.labelSettings || {};
if (labelSettings && labelSettings.isNoLabelDisplay) {
labelData = L(labelSettings.noLabelText || "[No Label]");
Expand Down
2 changes: 1 addition & 1 deletion dataFields/ABFieldConnectCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ module.exports = class ABFieldConnectCore extends ABField {
.join(", ");
// string
else if (val) {
if (val.text == null) return linkedObject.displayData(rowData) || "";
if (val.text == null) return linkedObject.displayData(val) || "";
else if (val.text) return val.text || "";
}
// empty string
Expand Down

0 comments on commit d9a29f9

Please sign in to comment.