mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-06-05 22:09:38 +02:00
feat: ✨ Major refactor componente DataTable
- Aggiunto supporto per le tabelle "checkable" (tabelle con le checkbox) - Migliorata la gestione generale della tabella, rendendola meno complicata da creare
This commit is contained in:
@@ -1,8 +1,36 @@
|
||||
import '@material/mwc-checkbox';
|
||||
|
||||
import {
|
||||
type Children,
|
||||
type Vnode
|
||||
} from 'mithril';
|
||||
|
||||
import Component from '../Component.jsx';
|
||||
import TableCell from './TableCell.jsx';
|
||||
|
||||
export default class TableRow extends Component {
|
||||
view(vnode) {
|
||||
this.attrs.addClassNames('mdc-data-table__row');
|
||||
return <tr {...this.attrs.all()}>{vnode.children}</tr>;
|
||||
|
||||
return (
|
||||
<tr {...this.attrs.all()}>
|
||||
{this.checkbox(vnode.children)}
|
||||
{vnode.children}
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
|
||||
checkbox(children: Array<Children>): Children {
|
||||
if (!this.attrs.has('checkable')) {
|
||||
return <></>;
|
||||
}
|
||||
|
||||
for (const child: Vnode of children) {
|
||||
if (child.attrs.type === 'checkbox') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return <TableCell type="checkbox"/>;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user