Skip to content

Commit daab1bd

Browse files
committed
XFA - Return html element for the different possible value
- it aims to fix #13536.
1 parent 950dcc7 commit daab1bd

File tree

1 file changed

+66
-20
lines changed

1 file changed

+66
-20
lines changed

src/core/xfa/template.js

+66-20
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,14 @@ class BooleanElement extends Option01 {
615615
}
616616

617617
[$toHTML](availableSpace) {
618-
return HTMLResult.success(this[$content] === 1);
618+
return HTMLResult.success({
619+
name: "span",
620+
attributes: {
621+
class: ["xfaRich"],
622+
style: {},
623+
},
624+
value: this[$content] === 1,
625+
});
619626
}
620627
}
621628

@@ -1257,11 +1264,19 @@ class DateElement extends ContentObject {
12571264
}
12581265

12591266
[$finalize]() {
1260-
this[$content] = new Date(this[$content].trim());
1267+
const date = this[$content].trim();
1268+
this[$content] = date ? new Date(date) : null;
12611269
}
12621270

12631271
[$toHTML](availableSpace) {
1264-
return HTMLResult.success(this[$content].toString());
1272+
return HTMLResult.success({
1273+
name: "span",
1274+
attributes: {
1275+
class: ["xfaRich"],
1276+
style: {},
1277+
},
1278+
value: this[$content] ? this[$content].toString() : "",
1279+
});
12651280
}
12661281
}
12671282

@@ -1275,11 +1290,19 @@ class DateTime extends ContentObject {
12751290
}
12761291

12771292
[$finalize]() {
1278-
this[$content] = new Date(this[$content].trim());
1293+
const date = this[$content].trim();
1294+
this[$content] = date ? new Date(date) : null;
12791295
}
12801296

12811297
[$toHTML](availableSpace) {
1282-
return HTMLResult.success(this[$content].toString());
1298+
return HTMLResult.success({
1299+
name: "span",
1300+
attributes: {
1301+
class: ["xfaRich"],
1302+
style: {},
1303+
},
1304+
value: this[$content] ? this[$content].toString() : "",
1305+
});
12831306
}
12841307
}
12851308

@@ -1351,9 +1374,14 @@ class Decimal extends ContentObject {
13511374
}
13521375

13531376
[$toHTML](availableSpace) {
1354-
return HTMLResult.success(
1355-
this[$content] !== null ? this[$content].toString() : ""
1356-
);
1377+
return HTMLResult.success({
1378+
name: "span",
1379+
attributes: {
1380+
class: ["xfaRich"],
1381+
style: {},
1382+
},
1383+
value: this[$content] !== null ? this[$content].toString() : "",
1384+
});
13571385
}
13581386
}
13591387

@@ -2365,12 +2393,12 @@ class Field extends XFAObject {
23652393
if (this.ui.imageEdit) {
23662394
ui.children.push(this.value[$toHTML]().html);
23672395
} else if (!this.ui.button) {
2368-
const value = this.value[$toHTML]().html;
2396+
const value = this.value[$toHTML]().html.value;
23692397
if (value) {
23702398
if (ui.children[0].name === "textarea") {
2371-
ui.children[0].attributes.textContent = value.value;
2399+
ui.children[0].attributes.textContent = value;
23722400
} else {
2373-
ui.children[0].attributes.value = value.value;
2401+
ui.children[0].attributes.value = value;
23742402
}
23752403
}
23762404
}
@@ -2522,9 +2550,14 @@ class Float extends ContentObject {
25222550
}
25232551

25242552
[$toHTML](availableSpace) {
2525-
return HTMLResult.success(
2526-
this[$content] !== null ? this[$content].toString() : ""
2527-
);
2553+
return HTMLResult.success({
2554+
name: "span",
2555+
attributes: {
2556+
class: ["xfaRich"],
2557+
style: {},
2558+
},
2559+
value: this[$content] !== null ? this[$content].toString() : "",
2560+
});
25282561
}
25292562
}
25302563

@@ -2812,9 +2845,14 @@ class Integer extends ContentObject {
28122845
}
28132846

28142847
[$toHTML](availableSpace) {
2815-
return HTMLResult.success(
2816-
this[$content] !== null ? this[$content].toString() : ""
2817-
);
2848+
return HTMLResult.success({
2849+
name: "span",
2850+
attributes: {
2851+
class: ["xfaRich"],
2852+
style: {},
2853+
},
2854+
value: this[$content] !== null ? this[$content].toString() : "",
2855+
});
28182856
}
28192857
}
28202858

@@ -4782,12 +4820,20 @@ class Time extends StringObject {
47824820
}
47834821

47844822
[$finalize]() {
4785-
// TODO
4786-
this[$content] = new Date(this[$content]);
4823+
// TODO.
4824+
const date = this[$content].trim();
4825+
this[$content] = date ? new Date(date) : null;
47874826
}
47884827

47894828
[$toHTML](availableSpace) {
4790-
return HTMLResult.success(this[$content].toString());
4829+
return HTMLResult.success({
4830+
name: "span",
4831+
attributes: {
4832+
class: ["xfaRich"],
4833+
style: {},
4834+
},
4835+
value: this[$content] ? this[$content].toString() : "",
4836+
});
47914837
}
47924838
}
47934839

0 commit comments

Comments
 (0)