file uploads
This commit is contained in:
@@ -1,33 +1,33 @@
|
||||
import Mustache from "mustache";
|
||||
import {stripHtml} from "../../helpers";
|
||||
import { stripHtml } from "../../helpers";
|
||||
|
||||
export function previewTitle(schemas, record, graph) {
|
||||
let schema = schemas.find((aSchema) => aSchema.name === record?.schema);
|
||||
if (!schema?.cardTitle) {
|
||||
return noTemplate(schema, record);
|
||||
}
|
||||
let schema = schemas.find((aSchema) => aSchema.name === record?.schema);
|
||||
if (!schema?.cardTitle) {
|
||||
return noTemplate(schema, record);
|
||||
}
|
||||
|
||||
let recordData = record.data;
|
||||
let render = Mustache.render(schema.cardTitle, recordData);
|
||||
if (!render || render === "") {
|
||||
return noTemplate(schema, record);
|
||||
}
|
||||
let recordData = record.data;
|
||||
let render = Mustache.render(schema.cardTitle, recordData);
|
||||
if (!render || render === "") {
|
||||
return noTemplate(schema, record);
|
||||
}
|
||||
|
||||
return stripHtml(render.slice(0, 300));
|
||||
return stripHtml(render.slice(0, 300));
|
||||
}
|
||||
|
||||
function noTemplate(schema, record) {
|
||||
if (schema?.type === "files") {
|
||||
return record._file.path;
|
||||
}
|
||||
if (schema?.type === "files") {
|
||||
return file.path;
|
||||
}
|
||||
|
||||
let title = stripHtml(
|
||||
record?.data[schema.fields.filter((f) => f.info.name === "text")[0]?.name]
|
||||
).slice(0, 300);
|
||||
let title = stripHtml(
|
||||
record?.data[schema.fields.filter((f) => f.info.name === "text")[0]?.name],
|
||||
).slice(0, 300);
|
||||
|
||||
if(title.trim() === ""){
|
||||
return "~Untitled~";
|
||||
}
|
||||
if (title.trim() === "") {
|
||||
return "~Untitled~";
|
||||
}
|
||||
|
||||
return title;
|
||||
return title;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user