mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2026-02-02 13:51:40 -08:00
add expand/collapse buttons to directories in tree view
This commit is contained in:
parent
580711cdac
commit
7d953cc6c5
5 changed files with 106 additions and 16 deletions
|
|
@ -338,6 +338,58 @@ class ExtraNetworksClusterizeTreeList extends ExtraNetworksClusterize {
|
|||
return max_width;
|
||||
}
|
||||
|
||||
async onExpandAllClick(div_id) {
|
||||
if (!keyExistsLogError(this.data_obj, div_id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const _expand = (parent_id) => {
|
||||
const this_obj = this.data_obj[parent_id];
|
||||
this_obj.visible = true;
|
||||
this_obj.expanded = true;
|
||||
for (const child_id of this_obj.children) {
|
||||
_expand(child_id);
|
||||
}
|
||||
};
|
||||
|
||||
this.data_obj[div_id].expanded = true;
|
||||
for (const child_id of this.data_obj[div_id].children) {
|
||||
_expand(child_id);
|
||||
}
|
||||
|
||||
const new_len = Object.values(this.data_obj).filter(v => v.visible).length;
|
||||
const max_items_changed = await this.setMaxItems(new_len);
|
||||
if (!max_items_changed) {
|
||||
await this.refresh(true);
|
||||
}
|
||||
}
|
||||
|
||||
async onCollapseAllClick(div_id) {
|
||||
if (!keyExistsLogError(this.data_obj, div_id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const _collapse = (parent_id) => {
|
||||
const this_obj = this.data_obj[parent_id];
|
||||
this_obj.visible = false;
|
||||
this_obj.expanded = false;
|
||||
for (const child_id of this_obj.children) {
|
||||
_collapse(child_id);
|
||||
}
|
||||
};
|
||||
|
||||
this.data_obj[div_id].expanded = false;
|
||||
for (const child_id of this.data_obj[div_id].children) {
|
||||
_collapse(child_id);
|
||||
}
|
||||
|
||||
const new_len = Object.values(this.data_obj).filter(v => v.visible).length;
|
||||
const max_items_changed = await this.setMaxItems(new_len);
|
||||
if (!max_items_changed) {
|
||||
await this.refresh(true);
|
||||
}
|
||||
}
|
||||
|
||||
async onRowExpandClick(div_id, elem) {
|
||||
/** Expands or collapses a row to show/hide children. */
|
||||
if (!keyExistsLogError(this.data_obj, div_id)) {
|
||||
|
|
@ -353,7 +405,10 @@ class ExtraNetworksClusterizeTreeList extends ExtraNetworksClusterize {
|
|||
}
|
||||
|
||||
const new_len = Object.values(this.data_obj).filter(v => v.visible).length;
|
||||
await this.setMaxItems(new_len);
|
||||
const max_items_changed = await this.setMaxItems(new_len);
|
||||
if (!max_items_changed) {
|
||||
await this.refresh(true);
|
||||
}
|
||||
}
|
||||
|
||||
async initData() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue