fix(views/table): events/commands not well sent

This commit is contained in:
Elian Doran
2025-07-15 15:49:32 +03:00
parent b91a3e13b0
commit 8131a4b3d2
3 changed files with 23 additions and 11 deletions

View File

@@ -25,7 +25,7 @@ export default class TableColumnEditing extends Component {
this.parentNote = parentNote;
}
addNewTableColumnEvent({ referenceColumn, direction }: EventData<"addNewTableColumn">) {
addNewTableColumnCommand({ referenceColumn, direction }: EventData<"addNewTableColumn">) {
const attr: Attribute = {
type: "label",
name: "label:myLabel",
@@ -52,15 +52,11 @@ export default class TableColumnEditing extends Component {
});
}
async reloadAttributesEvent() {
console.log("Reload attributes");
}
async updateAttributeListEvent({ attributes }: CommandListenerData<"updateAttributeList">) {
async updateAttributeListCommand({ attributes }: CommandListenerData<"updateAttributeList">) {
this.newAttribute = attributes[0];
}
async saveAttributesEvent() {
async saveAttributesCommand() {
if (!this.newAttribute) {
return;
}

View File

@@ -103,6 +103,7 @@ export default class TableView extends ViewMode<StateInfo> {
private api?: Tabulator;
private persistentData: StateInfo["tableData"];
private colEditing?: TableColumnEditing;
private rowEditing?: TableRowEditing;
constructor(args: ViewModeArgs) {
super(args, "table");
@@ -167,9 +168,7 @@ export default class TableView extends ViewMode<StateInfo> {
this.api = new Tabulator(el, opts);
this.colEditing = new TableColumnEditing(this.args.$parent, this.args.parentNote, this.api);
this.child(this.colEditing);
this.child(new TableRowEditing(this.api, this.args.parentNotePath!));
this.rowEditing = new TableRowEditing(this.api, this.args.parentNotePath!);
if (movableRows) {
configureReorderingRows(this.api);
@@ -222,6 +221,23 @@ export default class TableView extends ViewMode<StateInfo> {
this.colEditing?.resetNewAttributePosition();
}
addNewRowCommand(e) {
this.rowEditing?.addNewRowCommand(e);
}
addNewTableColumnCommand(e) {
this.colEditing?.addNewTableColumnCommand(e);
}
updateAttributeListCommand(e) {
this.colEditing?.updateAttributeListCommand(e);
}
saveAttributesCommand() {
this.colEditing?.saveAttributesCommand();
}
async #manageRowsUpdate() {
if (!this.api) {
return;

View File

@@ -42,7 +42,7 @@ export default class TableRowEditing extends Component {
});
}
addNewRowEvent({ customOpts, parentNotePath: customNotePath }: CommandListenerData<"addNewRow">) {
addNewRowCommand({ customOpts, parentNotePath: customNotePath }: CommandListenerData<"addNewRow">) {
const parentNotePath = customNotePath ?? this.parentNotePath;
if (parentNotePath) {
const opts: CreateNoteOpts = {