[#2197] added escape character support for the select field options

This commit is contained in:
Gani Georgiev
2023-09-12 10:18:36 +03:00
parent e1528aedac
commit eb2aa1cfc6
34 changed files with 55 additions and 42 deletions
+10 -2
View File
@@ -649,9 +649,15 @@ export default class CommonHelper {
* @return {Array}
*/
static splitNonEmpty(str, separator = ",") {
const items = (str || "").split(separator);
const result = [];
const items = (str || "")
.replaceAll("\\" + separator, "{_PB_ESCAPED_}")
.split(separator)
.map((item) => {
return item.replaceAll("{_PB_ESCAPED_}", separator);
});
for (let item of items) {
item = item.trim();
if (!CommonHelper.isEmpty(item)) {
@@ -672,10 +678,12 @@ export default class CommonHelper {
static joinNonEmpty(items, separator = ", ") {
const result = [];
const trimmedSeparator = separator.length > 1 ? separator.trim() : separator;
for (let item of items) {
item = typeof item === "string" ? item.trim() : "";
if (!CommonHelper.isEmpty(item)) {
result.push(item);
result.push(item.replaceAll(trimmedSeparator, "\\" + trimmedSeparator));
}
}