Skip to content

Commit

Permalink
fix(obc): updates element properties and relations tree templates
Browse files Browse the repository at this point in the history
  • Loading branch information
HoyosJuan committed May 31, 2024
1 parent 30fc00a commit 0536cbc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -373,22 +373,26 @@ const computeTableData = async (
return rows;
};

const table = document.createElement("bim-table");
table.columns = [{ name: "Name", width: "12rem" }];
table.headersHidden = true;
table.addEventListener("cellcreated", ({ detail }) => {
const { cell } = detail;
if (cell.column === "Name" && !("Value" in cell.rowData)) {
cell.style.gridColumn = "1 / -1";
}
});
let table: BUI.Table;

/**
* Heloooooooooo
*/
export const elementPropertiesTemplate = (state: ElementPropertiesUIState) => {
const { components, fragmentIdMap } = state;

if (!table) {
table = document.createElement("bim-table");
table.columns = [{ name: "Name", width: "12rem" }];
table.headersHidden = true;
table.addEventListener("cellcreated", ({ detail }) => {
const { cell } = detail;
if (cell.column === "Name" && !("Value" in cell.rowData)) {
cell.style.gridColumn = "1 / -1";
}
});
}

computeTableData(components, fragmentIdMap).then(
(data) => (table.data = data),
);
Expand Down
34 changes: 19 additions & 15 deletions packages/obc/src/components/tables/RelationsTree/src/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,7 @@ const computeRowData = async (
return rows;
};

const table = document.createElement("bim-table");
table.hiddenColumns = ["modelID", "expressID", "relations"];
table.columns = ["Entity", "Name"];
table.headersHidden = true;

table.addEventListener("cellcreated", ({ detail }) => {
const { cell } = detail;
if (cell.column === "Entity" && !("Name" in cell.rowData)) {
cell.style.gridColumn = "1 / -1";
}
});
let table: BUI.Table;

const getRowFragmentIdMap = (components: OBC.Components, row: BUI.TableRow) => {
const fragments = components.get(OBC.FragmentsManager);
Expand Down Expand Up @@ -141,10 +131,19 @@ export const relationsTreeTemplate = (state: RelationsTreeUIState) => {
expressID,
} = state;

const _inverseAttributes: OBC.InverseAttribute[] = inverseAttributes ?? [
"IsDecomposedBy",
"ContainsElements",
];
if (!table) {
table = document.createElement("bim-table");
table.hiddenColumns = ["modelID", "expressID", "relations"];
table.columns = ["Entity", "Name"];
table.headersHidden = true;

table.addEventListener("cellcreated", ({ detail }) => {
const { cell } = detail;
if (cell.column === "Entity" && !("Name" in cell.rowData)) {
cell.style.gridColumn = "1 / -1";
}
});
}

table.addEventListener("rowcreated", (e) => {
e.stopImmediatePropagation();
Expand Down Expand Up @@ -181,6 +180,11 @@ export const relationsTreeTemplate = (state: RelationsTreeUIState) => {
};
});

const _inverseAttributes: OBC.InverseAttribute[] = inverseAttributes ?? [
"IsDecomposedBy",
"ContainsElements",
];

computeRowData(components, models, _inverseAttributes, expressID).then(
(data) => (table.data = data),
);
Expand Down

0 comments on commit 0536cbc

Please sign in to comment.