Skip to content

Commit

Permalink
browser: treeview: remove unused parameter, part 2
Browse files Browse the repository at this point in the history
Change-Id: Ie6f56e81b0242416d2b36faccc43f3cb0278a73c
Signed-off-by: Henry Castro <[email protected]>
  • Loading branch information
hcvcastro committed Jan 16, 2025
1 parent 3e58b99 commit e8048bb
Showing 1 changed file with 49 additions and 70 deletions.
119 changes: 49 additions & 70 deletions browser/src/control/jsdialog/Widget.TreeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,10 @@ class TreeViewControl {
return false;
}

createCheckbox(
parent: HTMLElement,
treeViewData: TreeWidgetJSON,
builder: any,
entry: TreeEntryJSON,
) {
createCheckbox(parent: HTMLElement, entry: TreeEntryJSON) {
const checkbox = L.DomUtil.create(
'input',
builder.options.cssClass + ' ui-treeview-checkbox',
this._builder.options.cssClass + ' ui-treeview-checkbox',
parent,
);
checkbox.type = 'checkbox';
Expand All @@ -194,15 +189,10 @@ class TreeViewControl {
return checkbox;
}

createRadioButton(
parent: HTMLElement,
treeViewData: TreeWidgetJSON,
builder: any,
entry: TreeEntryJSON,
) {
createRadioButton(parent: HTMLElement, entry: TreeEntryJSON) {
const radioButton = L.DomUtil.create(
'input',
builder.options.cssClass + ' ui-treeview-checkbox',
this._builder.options.cssClass + ' ui-treeview-checkbox',
parent,
);
radioButton.type = 'radio';
Expand All @@ -217,19 +207,9 @@ class TreeViewControl {
let selectionElement: any;
const checkboxtype = this._data.checkboxtype;
if (checkboxtype == 'radio') {
selectionElement = this.createRadioButton(
parent,
this._data,
this._builder,
entry,
);
selectionElement = this.createRadioButton(parent, entry);
} else {
selectionElement = this.createCheckbox(
parent,
this._data,
this._builder,
entry,
);
selectionElement = this.createCheckbox(parent, entry);
}
selectionElement._state = entry.state;
selectionElement._row = entry.row;
Expand Down Expand Up @@ -265,14 +245,10 @@ class TreeViewControl {
return iconId;
}

createImageColumn(
parentContainer: HTMLElement,
builder: any,
imageUrl: string,
) {
createImageColumn(parentContainer: HTMLElement, imageUrl: string) {
const colorPreviewButton = L.DomUtil.create(
'img',
builder.options.cssClass + ' ui-treeview-checkbox',
this._builder.options.cssClass + ' ui-treeview-checkbox',
parentContainer,
);
colorPreviewButton.src = imageUrl;
Expand Down Expand Up @@ -386,43 +362,32 @@ class TreeViewControl {
parent: HTMLElement,
entry: TreeEntryJSON,
index: any,
builder: any,
) {
const icon = L.DomUtil.create('img', 'ui-treeview-icon', parent);

if (this._isNavigator) icon.draggable = false;

const iconId = this.getCellIconId(entry.columns[index]);
L.DomUtil.addClass(icon, iconId + 'img');
const iconName = builder._createIconURL(iconId, true);
L.LOUtil.setImage(icon, iconName, builder.map);
const iconName = this._builder._createIconURL(iconId, true);
L.LOUtil.setImage(icon, iconName, this._builder.map);
icon.tabIndex = -1;
icon.alt = ''; //In this case, it is advisable to use an empty alt tag for the icons, as the information of the function is available in text form
}

createTextCell(
parent: HTMLElement,
entry: TreeEntryJSON,
index: any,
builder: any,
) {
createTextCell(parent: HTMLElement, entry: TreeEntryJSON, index: any) {
const cell = L.DomUtil.create(
'span',
builder.options.cssClass + ' ui-treeview-cell-text',
this._builder.options.cssClass + ' ui-treeview-cell-text',
parent,
);
cell.innerText = entry.columns[index].text || entry.text;
}

createLinkCell(
parent: HTMLElement,
entry: TreeEntryJSON,
index: any,
builder: any,
) {
createLinkCell(parent: HTMLElement, entry: TreeEntryJSON, index: any) {
const cell = L.DomUtil.create(
'span',
builder.options.cssClass + ' ui-treeview-cell-text',
this._builder.options.cssClass + ' ui-treeview-cell-text',
parent,
);
const link = L.DomUtil.create('a', '', cell);
Expand Down Expand Up @@ -483,24 +448,24 @@ class TreeViewControl {
: entry.columns[index].expandedimage;
if (img) {
L.DomUtil.addClass(td, 'ui-treeview-icon-column');
this.createImageColumn(text, this._builder, img);
this.createImageColumn(text, img);
} else if (
entry.columns[index].collapsed ||
entry.columns[index].expanded
) {
L.DomUtil.addClass(td, 'ui-treeview-icon-column');
L.DomUtil.addClass(span, 'ui-treeview-expandable-with-icon');
this.createExpandableIconCell(text, entry, index, this._builder);
this.createExpandableIconCell(text, entry, index);
} else if (
entry.columns[index].link &&
!this.isSeparator(entry.columns[index])
) {
this.createLinkCell(text, entry, index, this._builder);
this.createLinkCell(text, entry, index);
} else if (
entry.columns[index].text &&
!this.isSeparator(entry.columns[index])
) {
this.createTextCell(text, entry, index, this._builder);
this.createTextCell(text, entry, index);
}

// row sub-elements
Expand All @@ -513,21 +478,35 @@ class TreeViewControl {
}
}

toggleEntry(
span: HTMLElement,
treeViewData: TreeWidgetJSON,
row: any,
builder: any,
) {
toggleEntry(span: HTMLElement, row: any) {
if (L.DomUtil.hasClass(span, 'collapsed'))
builder.callback('treeview', 'expand', treeViewData, row, builder);
else builder.callback('treeview', 'collapse', treeViewData, row, builder);
this._builder.callback(
'treeview',
'expand',
this._data,
row,
this._builder,
);
else
this._builder.callback(
'treeview',
'collapse',
this._data,
row,
this._builder,
);
$(span).toggleClass('collapsed');
}

expandEntry(span: any, treeViewData: TreeWidgetJSON, row: any, builder: any) {
expandEntry(span: any, row: any) {
if (span._ondemand && L.DomUtil.hasClass(span, 'collapsed'))
builder.callback('treeview', 'expand', treeViewData, row, builder);
this._builder.callback(
'treeview',
'expand',
this._data,
row,
this._builder,
);
$(span).toggleClass('collapsed');
}

Expand Down Expand Up @@ -883,10 +862,10 @@ class TreeViewControl {
});
}

build(data: TreeWidgetJSON, builder: any, parentContainer: HTMLElement) {
this.preprocessColumnData(data.entries);
this.fillHeaders(data.headers);
this.fillEntries(data.entries, 1, this._tbody);
build(parentContainer: HTMLElement) {
this.preprocessColumnData(this._data.entries);
this.fillHeaders(this._data.headers);
this.fillEntries(this._data.entries, 1, this._tbody);

parentContainer.appendChild(this._container);

Expand Down Expand Up @@ -985,9 +964,9 @@ class TreeViewControl {

onExpanderClick(expander: any) {
if (expander._ondemand) {
this.expandEntry(expander, this._data, expander._row, this._builder);
this.expandEntry(expander, expander._row);
} else {
this.toggleEntry(expander, this._data, expander._row, this._builder);
this.toggleEntry(expander, expander._row);
}
}

Expand Down Expand Up @@ -1161,7 +1140,7 @@ JSDialog.treeView = function (
builder: any,
) {
var treeView = new TreeViewControl(data, builder);
treeView.build(data, builder, parentContainer);
treeView.build(parentContainer);

return false;
};
Expand Down

0 comments on commit e8048bb

Please sign in to comment.