Skip to content

Commit

Permalink
browser: treeview: add 'dblclick' event handler
Browse files Browse the repository at this point in the history
Change-Id: I82646ef5133595788d5c02bea6b0f68fbb25c448
Signed-off-by: Henry Castro <[email protected]>
  • Loading branch information
hcvcastro committed Jan 10, 2025
1 parent 0c3ef91 commit e86ace6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 61 deletions.
4 changes: 4 additions & 0 deletions browser/src/control/Control.ServerAuditDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class ServerAuditDialog {
if (status) {
entries.push({
row: 0,
state: false,
columns: [
entry.status === 'ok' ? okIcon : errorIcon,
{ text: status[0] },
Expand All @@ -145,6 +146,9 @@ class ServerAuditDialog {
}
: { text: '' },
],
children: [
{ row: 2, columns: [ { text: 'a2' } ] }
],
} as TreeEntryJSON);
}
} else {
Expand Down
84 changes: 23 additions & 61 deletions browser/src/control/jsdialog/Widget.TreeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class TreeViewControl {

if (data.enabled !== false) {
this._container.addEventListener('click', this.onClick.bind(this));
this._container.addEventListener('dblclick', this.onDoubleClick.bind(this));
}
}

Expand Down Expand Up @@ -552,34 +553,13 @@ class TreeViewControl {
}
}

/*var doubleClickFunction = this.createClickFunction(
tr,
selectionElement,
false,
true,
builder,
treeViewData,
entry,
);
this.setupEntryMouseEvents(
tr,
entry,
treeViewData,
builder,
selectionElement,
expander,
clickFunction,
doubleClickFunction,
);
this.setupEntryKeyEvent(
/*this.setupEntryKeyEvent(
tr,
entry,
selectionElement,
expander,
clickFunction,
); */
);*/

this.setupEntryContextMenuEvent(tr, entry, treeViewData, builder);
}
Expand All @@ -602,44 +582,6 @@ class TreeViewControl {
});
}

setupEntryMouseEvents(
tr: HTMLElement,
entry: TreeEntryJSON,
treeViewData: TreeWidgetJSON,
builder: any,
selectionElement: HTMLInputElement,
expander: HTMLElement,
clickFunction: any,
doubleClickFunction: any,
) {
tr.addEventListener('click', clickFunction as any);

if (!this._singleClickActivate) {
if (window.ThisIsTheiOSApp) {
// TODO: remove this hack
tr.addEventListener('click', () => {
if (L.DomUtil.hasClass(tr, 'disabled')) return;

if (
entry.row == lastClickHelperRow &&
treeViewData.id == lastClickHelperId
)
doubleClickFunction(undefined);
else {
lastClickHelperRow = entry.row;
lastClickHelperId = treeViewData.id;
setTimeout(() => {
lastClickHelperRow = -1;
}, 300);
}
});
// TODO: remove this hack
} else {
$(tr).dblclick(doubleClickFunction as any);
}
}
}

setupEntryKeyEvent(
tr: HTMLElement,
entry: TreeEntryJSON,
Expand Down Expand Up @@ -1212,6 +1154,26 @@ class TreeViewControl {
this.toggleEntry(expander, this._data, expander._row, this._builder);
}
}

onDoubleClick(e: any) {
let target = e.target;
let row = TreeViewControl.getElement(target, 'row');
if (row && !L.DomUtil.hasClass(row, 'disabled')) {
this.onRowDoubleClick(row);
}
}

onRowDoubleClick(row: any) {
if (!this._singleClickActivate) {
this._builder.callback(
'treeview',
'activate',
this._data,
row._row,
this._builder,
);
}
}
}

JSDialog.treeView = function (
Expand Down

0 comments on commit e86ace6

Please sign in to comment.