fix(core): update

This commit is contained in:
2022-12-06 13:11:06 +01:00
parent c3bdec176b
commit 7baab5d7ea
7 changed files with 4568 additions and 14832 deletions

View File

@ -17,6 +17,13 @@ declare global {
}
}
export interface IDataAction<T = any> {
name: string;
icon: string;
useTableBehaviour?: 'upload' | 'cancelUpload' | 'none';
actionFunc: (itemArg: T) => Promise<any>;
}
@customElement('dees-table')
export class DeesTable<T> extends DeesElement {
public static demo = () => html`
@ -61,8 +68,15 @@ export class DeesTable<T> extends DeesElement {
description: 'Office-Supplies - STAPLES BREMEN',
},
]}
>This is a slotted Text</dees-table
>
.dataActions="${[{
name: 'upload',
icon: 'upload',
useTableBehaviour: 'upload',
actionFunc: async (itemArg: any) => {
},
}] as IDataAction[]}"
>This is a slotted Text</dees-table>
</div>
`;
@ -81,6 +95,11 @@ export class DeesTable<T> extends DeesElement {
})
public data: T[] = [];
@property({
type: Array,
})
public dataActions: IDataAction[] = [];
@property({
type: Object,
})
@ -114,7 +133,7 @@ export class DeesTable<T> extends DeesElement {
background: ${cssManager.bdTheme('#fafafa', '#333333')};
border-radius: 3px;
border-top: 1px solid ${cssManager.bdTheme('#fff', '#444')};
box-shadow: 0px 0px 5px rgba(0,0,0,0.3);
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.3);
}
.headingSeparation {
margin-top: 7px;
@ -178,6 +197,20 @@ export class DeesTable<T> extends DeesElement {
border-right: none;
}
.action {
margin: -8px 0px;
padding: 8px;
}
.action:first-child {
margin-left: -8px;
width: min-content;
}
.action:hover {
background: #111;
}
.tableStatistics {
padding: 4px 16px;
font-size: 12px;
@ -213,6 +246,15 @@ export class DeesTable<T> extends DeesElement {
</th>
`
)}
${(() => {
if (this.dataActions) {
return html`
<th>
<div class="innerCellContainer">Actions</div>
</th>
`;
}
})()}
</tr>
${this.data.map(
(itemArg) => html`
@ -220,6 +262,21 @@ export class DeesTable<T> extends DeesElement {
@click=${() => {
this.selectedDataRow = itemArg;
}}
@dragenter=${async (eventArg) => {
console.log('hey');
eventArg.preventDefault();
eventArg.stopPropagation();
}}
@dragover=${async (eventArg) => {
console.log('hey');
eventArg.preventDefault();
eventArg.stopPropagation();
}}
@drop=${async (eventArg) => {
console.log('hey');
eventArg.preventDefault();
eventArg.stopPropagation();
}}
class="${itemArg === this.selectedDataRow ? 'selected' : ''}"
>
${headings.map(
@ -229,6 +286,23 @@ export class DeesTable<T> extends DeesElement {
</td>
`
)}
${(() => {
if (this.dataActions) {
return html`
<td>
<div class="innerCellContainer">
${(() => {
const actions: TemplateResult[] = [];
for (const action of this.dataActions) {
actions.push(html`<div class="action">${action.name}</div>`)
}
return actions;
})()}
</div>
</td>
`;
}
})()}
</tr>
`
)}
@ -238,7 +312,9 @@ export class DeesTable<T> extends DeesElement {
: html` <div class="noDataSet">No data set!</div> `}
<div class="tableStatistics">
${this.data.length} data rows (total) |
${this.selectedDataRow ? html`Row ${this.data.indexOf(this.selectedDataRow) + 1} selected` : html`No row selected`}
${this.selectedDataRow
? html`Row ${this.data.indexOf(this.selectedDataRow) + 1} selected`
: html`No row selected`}
</div>
</div>
`;