mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 23:29:02 +02:00
feat(views/table): basic formatter for relations
This commit is contained in:
parent
a2e197facd
commit
b293643398
@ -2,7 +2,7 @@ import FNote from "../../../entities/fnote.js";
|
|||||||
import type { LabelType } from "../../../services/promoted_attribute_definition_parser.js";
|
import type { LabelType } from "../../../services/promoted_attribute_definition_parser.js";
|
||||||
import type { ColumnDefinition } from "tabulator-tables";
|
import type { ColumnDefinition } from "tabulator-tables";
|
||||||
import link from "../../../services/link.js";
|
import link from "../../../services/link.js";
|
||||||
import RelationEditor from "./relation_editor.js";
|
import { RelationEditor, RelationFormatter } from "./relation_editor.js";
|
||||||
|
|
||||||
export type TableData = {
|
export type TableData = {
|
||||||
iconClass: string;
|
iconClass: string;
|
||||||
@ -46,7 +46,8 @@ const labelTypeMappings: Record<ColumnType, Partial<ColumnDefinition>> = {
|
|||||||
editor: "input"
|
editor: "input"
|
||||||
},
|
},
|
||||||
relation: {
|
relation: {
|
||||||
editor: RelationEditor
|
editor: RelationEditor,
|
||||||
|
formatter: RelationFormatter
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { CellComponent } from "tabulator-tables";
|
import { CellComponent } from "tabulator-tables";
|
||||||
import note_autocomplete from "../../../services/note_autocomplete";
|
import note_autocomplete from "../../../services/note_autocomplete";
|
||||||
|
|
||||||
export default function RelationEditor(cell: CellComponent, onRendered, success, cancel, editorParams){
|
export function RelationEditor(cell: CellComponent, onRendered, success, cancel, editorParams){
|
||||||
//cell - the cell component for the editable cell
|
//cell - the cell component for the editable cell
|
||||||
//onRendered - function to call when the editor has been rendered
|
//onRendered - function to call when the editor has been rendered
|
||||||
//success - function to call to pass thesuccessfully updated value to Tabulator
|
//success - function to call to pass thesuccessfully updated value to Tabulator
|
||||||
@ -38,3 +38,12 @@ export default function RelationEditor(cell: CellComponent, onRendered, success,
|
|||||||
//return the editor element
|
//return the editor element
|
||||||
return editor;
|
return editor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function RelationFormatter(cell: CellComponent, formatterParams, onRendered) {
|
||||||
|
const noteId = cell.getValue();
|
||||||
|
if (!noteId) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return `<a href="#root/${noteId}">Title goes here</a>`;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user