fix untitled

This commit is contained in:
2023-10-26 17:45:23 +03:00
parent 944ba96d53
commit 48e0fc1c15
3 changed files with 12 additions and 5 deletions
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
{
"main.js": {
"file": "assets/main.bdd46049.js",
"file": "assets/main.46b77f3f.js",
"src": "main.js",
"isEntry": true,
"css": [
+10 -3
View File
@@ -2,7 +2,7 @@ import Mustache from "mustache";
import {stripHtml} from "../../helpers";
export function previewTitle(schemas, record, graph) {
let schema = schemas.find((aschema) => aschema.name === record?.schema);
let schema = schemas.find((aSchema) => aSchema.name === record?.schema);
if (!schema?.titleTemplate) {
return noTemplate(schema, record);
@@ -12,7 +12,7 @@ export function previewTitle(schemas, record, graph) {
let template = Mustache.parse(schema.titleTemplate);
let referencePreviews = template
.filter(segment => segment[0] == "name") // keep only template tags
.filter(segment => segment[0] === "name") // keep only template tags
.map((segment) => segment[1]) // map to fieldNames
.filter(fieldName => { // keep only references
let schemaField = schema.fields.find(f => f.name === fieldName)
@@ -38,7 +38,14 @@ function noTemplate(schema, record) {
if (schema?.type === "files") {
return record._file.path;
}
return stripHtml(
let title = stripHtml(
record?.data[schema.fields.filter((f) => f.info.name === "text")[0]?.name]
).slice(0, 300);
if(title == ""){
return "Untitled";
}
return title;
}