refactor(views/table): move attribute detail widget to view

This commit is contained in:
Elian Doran
2025-07-14 17:27:38 +03:00
parent 504a842d37
commit d4a4f15416
3 changed files with 37 additions and 31 deletions

View File

@@ -14,6 +14,7 @@ import buildFooter from "./footer.js";
import getAttributeDefinitionInformation, { buildRowDefinitions, TableData } from "./rows.js";
import { AttributeDefinitionInformation, buildColumnDefinitions } from "./columns.js";
import { setupContextMenu } from "./context_menu.js";
import AttributeDetailWidget from "../../attribute_widgets/attribute_detail.js";
const TPL = /*html*/`
<div class="table-view">
@@ -105,6 +106,8 @@ export default class TableView extends ViewMode<StateInfo> {
private api?: Tabulator;
private newAttribute?: Attribute;
private persistentData: StateInfo["tableData"];
private attributeDetailWidget: AttributeDetailWidget;
constructor(args: ViewModeArgs) {
super(args, "table");
@@ -114,6 +117,11 @@ export default class TableView extends ViewMode<StateInfo> {
this.spacedUpdate = new SpacedUpdate(() => this.onSave(), 5_000);
this.persistentData = {};
args.$parent.append(this.$root);
this.attributeDetailWidget = new AttributeDetailWidget()
.contentSized()
.setParent(glob.getComponentByEl(args.$parent[0]));
args.$parent.append(this.attributeDetailWidget.render());
}
async renderList() {
@@ -226,6 +234,23 @@ export default class TableView extends ViewMode<StateInfo> {
console.log("Save attributes", this.newAttribute);
}
addNoteListItemEvent() {
const attr: Attribute = {
type: "label",
name: "label:myLabel",
value: "promoted,single,text"
};
this.attributeDetailWidget!.showAttributeDetail({
attribute: attr,
allAttributes: [ attr ],
isOwned: true,
x: 0,
y: 75,
focus: "name"
});
}
addNewRowCommand({ customOpts, parentNotePath: customNotePath }: CommandListenerData<"addNewRow">) {
const parentNotePath = customNotePath ?? this.args.parentNotePath;
if (parentNotePath) {