2022-02-27 02:06:33 +00:00
|
|
|
"use strict";
|
|
|
|
|
2022-03-06 02:39:52 +00:00
|
|
|
import Emel from 'emel';
|
|
|
|
import { NightInk } from 'nightink';
|
|
|
|
|
|
|
|
import AbstractUIItem from './AbstractUIItem.mjs';
|
|
|
|
|
|
|
|
class UITable extends AbstractUIItem {
|
|
|
|
constructor(el, def) {
|
|
|
|
super(el, def);
|
|
|
|
|
|
|
|
this.emel = new Emel().emel;
|
|
|
|
|
|
|
|
this.el.replaceChildren(this.emel(`table>(thead>tr>${Object.keys(def.content).map(header => `th{${header}}`).join("+")})+tbody`));
|
|
|
|
}
|
|
|
|
|
|
|
|
clear() {
|
|
|
|
super.clear();
|
|
|
|
// TODO: Empty the table, but avoiding removing the header, structure etc
|
|
|
|
}
|
|
|
|
|
|
|
|
append(peer, table) {
|
|
|
|
super.append(peer, table);
|
|
|
|
|
|
|
|
let new_row = document.createElement("tr");
|
|
|
|
for(let [ _, template ] of Object.entries(this.def.content)) {
|
|
|
|
let table_cell = document.createElement("td");
|
|
|
|
table_cell.appendChild(document.createTextNode())
|
|
|
|
}
|
2022-02-27 02:06:33 +00:00
|
|
|
|
2022-03-06 02:39:52 +00:00
|
|
|
// TODO Append the new table item in the right place
|
|
|
|
// Perhaps we could use .dataset & iterate until we find the right one to insert directly before?
|
2022-02-27 02:06:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default UITable;
|