mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 15:19:01 +02:00
chore(views/table): bring back editing title
This commit is contained in:
parent
a31ac17792
commit
9a6a8580de
@ -56,7 +56,8 @@ export function buildColumnDefinitions(info: PromotedAttributeInformation[]) {
|
||||
},
|
||||
{
|
||||
field: "title",
|
||||
title: "Title"
|
||||
title: "Title",
|
||||
editor: "input"
|
||||
},
|
||||
{
|
||||
field: "position",
|
||||
@ -68,6 +69,7 @@ export function buildColumnDefinitions(info: PromotedAttributeInformation[]) {
|
||||
columnDefs.push({
|
||||
field: `labels.${name}`,
|
||||
title: title ?? name,
|
||||
editable: true
|
||||
// cellDataType: mapDataType(type),
|
||||
});
|
||||
}
|
||||
|
@ -8,8 +8,8 @@ import branches from "../../../services/branches.js";
|
||||
import type { CommandListenerData, EventData } from "../../../components/app_context.js";
|
||||
import type { Attribute } from "../../../services/attribute_parser.js";
|
||||
import note_create from "../../../services/note_create.js";
|
||||
import {Tabulator, SortModule, FormatModule, InteractionModule} from 'tabulator-tables';
|
||||
import "tabulator-tables/dist/css/tabulator_bootstrap5.min.css";
|
||||
import {Tabulator, SortModule, FormatModule, InteractionModule, EditModule} from 'tabulator-tables';
|
||||
import "tabulator-tables/dist/css/tabulator_midnight.min.css";
|
||||
|
||||
const TPL = /*html*/`
|
||||
<div class="table-view">
|
||||
@ -81,7 +81,7 @@ export default class TableView extends ViewMode<StateInfo> {
|
||||
const viewStorage = await this.viewStorage.restore();
|
||||
const initialState = viewStorage?.gridState;
|
||||
|
||||
const modules = [SortModule, FormatModule, InteractionModule];
|
||||
const modules = [SortModule, FormatModule, InteractionModule, EditModule];
|
||||
for (const module of modules) {
|
||||
Tabulator.registerModule(module);
|
||||
}
|
||||
@ -98,6 +98,7 @@ export default class TableView extends ViewMode<StateInfo> {
|
||||
columns: buildColumnDefinitions(info),
|
||||
data: await buildRowDefinitions(this.parentNote, notes, info)
|
||||
});
|
||||
this.setupEditing();
|
||||
}
|
||||
|
||||
private onSave() {
|
||||
@ -110,31 +111,36 @@ export default class TableView extends ViewMode<StateInfo> {
|
||||
});
|
||||
}
|
||||
|
||||
private setupEditing(): GridOptions<TableData> {
|
||||
return {
|
||||
onCellValueChanged(event) {
|
||||
if (event.type !== "cellValueChanged") {
|
||||
return;
|
||||
}
|
||||
private setupEditing() {
|
||||
this.api!.on("cellEdited", (cell) => {
|
||||
const noteId = cell.getRow().getData().noteId;
|
||||
const field = cell.getField();
|
||||
const newValue = cell.getValue();
|
||||
|
||||
const noteId = event.data.noteId;
|
||||
const name = event.colDef.field;
|
||||
if (!name) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { newValue } = event;
|
||||
if (name === "title") {
|
||||
// TODO: Deduplicate with note_title.
|
||||
console.log("Cell edited", field, newValue);
|
||||
if (field === "title") {
|
||||
server.put(`notes/${noteId}/title`, { title: newValue });
|
||||
}
|
||||
});
|
||||
|
||||
if (name.startsWith("labels.")) {
|
||||
const labelName = name.split(".", 2)[1];
|
||||
setLabel(noteId, labelName, newValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
// return {
|
||||
// onCellValueChanged(event) {
|
||||
// if (event.type !== "cellValueChanged") {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// const noteId = event.data.noteId;
|
||||
// const name = event.colDef.field;
|
||||
// if (!name) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (name.startsWith("labels.")) {
|
||||
// const labelName = name.split(".", 2)[1];
|
||||
// setLabel(noteId, labelName, newValue);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
private setupDragging() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user