fix untitled
This commit is contained in:
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"main.js": {
|
||||
"file": "assets/main.bdd46049.js",
|
||||
"file": "assets/main.46b77f3f.js",
|
||||
"src": "main.js",
|
||||
"isEntry": true,
|
||||
"css": [
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user