Fix: Add a boolean prop to prevent the node field from using title case
This commit is contained in:
parent
7bd113dfaf
commit
a371515956
1 changed files with 5 additions and 3 deletions
|
|
@ -58,11 +58,12 @@ export function normalCaseToSnakeCase(str: string): string {
|
||||||
.join("_");
|
.join("_");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function toTitleCase(str: string | undefined): string {
|
export function toTitleCase(str: string | undefined, isNodeField?: boolean): string {
|
||||||
if (!str) return "";
|
if (!str) return "";
|
||||||
let result = str
|
let result = str
|
||||||
.split("_")
|
.split("_")
|
||||||
.map((word, index) => {
|
.map((word, index) => {
|
||||||
|
if (isNodeField) return word
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
return checkUpperWords(
|
return checkUpperWords(
|
||||||
word[0].toUpperCase() + word.slice(1).toLowerCase()
|
word[0].toUpperCase() + word.slice(1).toLowerCase()
|
||||||
|
|
@ -75,6 +76,7 @@ export function toTitleCase(str: string | undefined): string {
|
||||||
return result
|
return result
|
||||||
.split("-")
|
.split("-")
|
||||||
.map((word, index) => {
|
.map((word, index) => {
|
||||||
|
if (isNodeField) return word
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
return checkUpperWords(
|
return checkUpperWords(
|
||||||
word[0].toUpperCase() + word.slice(1).toLowerCase()
|
word[0].toUpperCase() + word.slice(1).toLowerCase()
|
||||||
|
|
@ -642,6 +644,6 @@ export function getFieldTitle(
|
||||||
return template[templateField].display_name
|
return template[templateField].display_name
|
||||||
? template[templateField].display_name!
|
? template[templateField].display_name!
|
||||||
: template[templateField].name
|
: template[templateField].name
|
||||||
? toTitleCase(template[templateField].name!)
|
? toTitleCase(template[templateField].name!, true)
|
||||||
: toTitleCase(templateField);
|
: toTitleCase(templateField, true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue