Compare commits

...

10 Commits

Author SHA1 Message Date
9a34b03540 1.0.206 2023-09-15 20:51:04 +02:00
8bb63df7e3 fix(core): update 2023-09-15 20:51:03 +02:00
65cd73845a 1.0.205 2023-09-15 20:11:52 +02:00
8534bc254b fix(core): update 2023-09-15 20:11:51 +02:00
2a2fd324a0 1.0.204 2023-09-15 19:07:35 +02:00
58e3de2559 fix(core): update 2023-09-15 19:07:34 +02:00
c30736870d 1.0.203 2023-09-15 19:03:19 +02:00
cfd48de885 fix(core): update 2023-09-15 19:03:18 +02:00
462df2b648 1.0.202 2023-09-15 17:27:36 +02:00
f64da93cf9 fix(core): update 2023-09-15 17:27:35 +02:00
4 changed files with 119 additions and 26 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@design.estate/dees-catalog", "name": "@design.estate/dees-catalog",
"version": "1.0.201", "version": "1.0.206",
"private": false, "private": false,
"description": "website for lossless.com", "description": "website for lossless.com",
"main": "dist_ts_web/index.js", "main": "dist_ts_web/index.js",

View File

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@design.estate/dees-catalog', name: '@design.estate/dees-catalog',
version: '1.0.201', version: '1.0.206',
description: 'website for lossless.com' description: 'website for lossless.com'
} }

View File

@ -23,6 +23,7 @@ export const demoFunc = () => html`
<dees-table <dees-table
heading1="Current Account Statement" heading1="Current Account Statement"
heading2="Bunq - Payment Account 2 - April 2021" heading2="Bunq - Payment Account 2 - April 2021"
.editableFields="${['description']}"
.data=${[ .data=${[
{ {
date: '2021-04-01', date: '2021-04-01',
@ -106,6 +107,15 @@ export const demoFunc = () => html`
return null; return null;
}, },
}, },
{
name: 'preview',
type: ['doubleClick', 'contextmenu'],
iconName: 'eye',
actionFunc: async (itemArg) => {
alert(itemArg.amount);
return null;
},
}
] as (ITableAction<ITableDemoData>)[] as any}" ] as (ITableAction<ITableDemoData>)[] as any}"
.displayFunction=${(itemArg) => { .displayFunction=${(itemArg) => {
return { return {

View File

@ -37,7 +37,15 @@ export interface ITableAction<T = any> {
/** /**
* the type of the action * the type of the action
*/ */
type: ('inRow' | 'contextmenu' | 'footer' | 'header' | 'preview' | 'keyCombination')[]; type: (
| 'inRow'
| 'contextmenu'
| 'doubleClick'
| 'footer'
| 'header'
| 'preview'
| 'keyCombination'
)[];
/** /**
* allows to check if the action is relevant for the given item * allows to check if the action is relevant for the given item
* @param itemArg * @param itemArg
@ -96,6 +104,11 @@ export class DeesTable<T> extends DeesElement {
}) })
public selectedDataRow: T; public selectedDataRow: T;
@property({
type: Array,
})
public editableFields: string[] = [];
public files: File[] = []; public files: File[] = [];
public fileWeakMap = new WeakMap(); public fileWeakMap = new WeakMap();
@ -185,8 +198,8 @@ export class DeesTable<T> extends DeesElement {
tr:hover { tr:hover {
cursor: pointer; cursor: pointer;
} }
tr:hover .innerCellContainer { tr:hover td {
background: ${cssManager.bdTheme('#22222210', '#ffffff20')}; background: ${cssManager.bdTheme('#22222210', '#ffffff10')};
} }
tr:first-child:hover { tr:first-child:hover {
cursor: auto; cursor: auto;
@ -194,19 +207,30 @@ export class DeesTable<T> extends DeesElement {
tr:first-child:hover .innerCellContainer { tr:first-child:hover .innerCellContainer {
background: none; background: none;
} }
tr.selected .innerCellContainer { tr.selected td {
background: ${cssManager.bdTheme('#22222220', '#ffffff40')}; background: ${cssManager.bdTheme('#22222220', '#ffffff20')};
} }
tr.hasAttachment td {
background: ${cssManager.bdTheme('#0098847c', '#0098847c')};
}
th { th {
text-transform: uppercase; text-transform: uppercase;
} }
th, th,
td { td {
padding: 3px 0px; position: relative;
padding: 0px;
border-right: 1px dashed ${cssManager.bdTheme('#999', '#808080')}; border-right: 1px dashed ${cssManager.bdTheme('#999', '#808080')};
} }
.innerCellContainer { .innerCellContainer {
min-height: 36px;
position: relative;
height: 100%;
width: 100%;
padding: 6px 8px; padding: 6px 8px;
line-height: 24px;
} }
th:first-child .innerCellContainer, th:first-child .innerCellContainer,
td:first-child .innerCellContainer { td:first-child .innerCellContainer {
@ -220,11 +244,29 @@ export class DeesTable<T> extends DeesElement {
td:last-child { td:last-child {
border-right: none; border-right: none;
} }
td input {
width: 100%;
height: 100%;
outline: none;
border: 2px solid #fa6101;
top: 0px;
bottom: 0px;
right: 0px;
left: 0px;
position: absolute;
background: #fa610140;
color: inherit;
font-family: inherit;
font-size: inherit;
font-weight: inherit;
padding: 0px 6px
}
.action { .action {
margin: -8px 0px; margin: -6px 0px;
padding: 8px; padding: 10px;
line-height: 16px; line-height: 36px;
height: 36px;
display: inline-block; display: inline-block;
} }
@ -234,7 +276,7 @@ export class DeesTable<T> extends DeesElement {
} }
.action:hover { .action:hover {
background: ${cssManager.bdTheme('#CCC', '#111')}; background: ${cssManager.bdTheme('#CCC', '#00000030')};
} }
.footer { .footer {
@ -355,14 +397,14 @@ export class DeesTable<T> extends DeesElement {
console.log('dragenter'); console.log('dragenter');
console.log(realTarget); console.log(realTarget);
setTimeout(() => { setTimeout(() => {
realTarget.style.background = 'green'; realTarget.classList.add('hasAttachment');
}, 0); }, 0);
}} }}
@dragleave=${async (eventArg: DragEvent) => { @dragleave=${async (eventArg: DragEvent) => {
eventArg.preventDefault(); eventArg.preventDefault();
eventArg.stopPropagation(); eventArg.stopPropagation();
const realTarget = getTr(eventArg.target as HTMLElement); const realTarget = getTr(eventArg.target as HTMLElement);
realTarget.style.background = 'none'; realTarget.classList.remove('hasAttachment');
}} }}
@dragover=${async (eventArg: DragEvent) => { @dragover=${async (eventArg: DragEvent) => {
eventArg.preventDefault(); eventArg.preventDefault();
@ -383,23 +425,39 @@ export class DeesTable<T> extends DeesElement {
} }
}} }}
@contextmenu=${async (eventArg: MouseEvent) => { @contextmenu=${async (eventArg: MouseEvent) => {
DeesContextmenu.openContextMenuWithOptions(eventArg, this.getActionsForType('contextmenu').map(action => { DeesContextmenu.openContextMenuWithOptions(
const menuItem: plugins.tsclass.website.IMenuItem = { eventArg,
name: action.name, this.getActionsForType('contextmenu').map((action) => {
iconName: action.iconName as any, const menuItem: plugins.tsclass.website.IMenuItem = {
action: async () => { name: action.name,
await action.actionFunc(itemArg); iconName: action.iconName as any,
return null; action: async () => {
} await action.actionFunc(itemArg);
} return null;
return menuItem; },
})); };
return menuItem;
})
);
}} }}
class="${itemArg === this.selectedDataRow ? 'selected' : ''}" class="${itemArg === this.selectedDataRow ? 'selected' : ''}"
> >
${headings.map( ${headings.map(
(headingArg) => html` (headingArg) => html`
<td> <td
@dblclick=${(e: Event) => {
if (this.editableFields.includes(headingArg)) {
this.handleCellEditing(e, itemArg, headingArg);
} else {
const wantedAction = this.dataActions.find((actionArg) =>
actionArg.type.includes('doubleClick')
);
if (wantedAction) {
wantedAction.actionFunc(itemArg);
}
}
}}
>
<div class="innerCellContainer">${transformedItem[headingArg]}</div> <div class="innerCellContainer">${transformedItem[headingArg]}</div>
</td> </td>
` `
@ -476,4 +534,29 @@ export class DeesTable<T> extends DeesElement {
} }
return actions; return actions;
} }
handleCellEditing(event: Event, item: T, key: string) {
const target = event.target as HTMLElement;
// Create an input element
const input = document.createElement('input');
input.type = 'text';
input.value = (item[key] as unknown as string) || '';
// When the input loses focus or the Enter key is pressed, update the data
input.addEventListener('blur', () => {
item[key] = input.value as any; // Convert string to T (you might need better type casting depending on your data structure)
target.innerHTML = input.value; // Update the cell's display
});
input.addEventListener('keydown', (e: KeyboardEvent) => {
if (e.key === 'Enter') {
input.blur(); // This will trigger the blur event handler above
}
});
// Replace the cell's content with the input
target.innerHTML = '';
target.appendChild(input);
input.focus();
}
} }