Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix lint
Browse files Browse the repository at this point in the history
hoxbro committed May 22, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent ef9b149 commit 607122a
Showing 4 changed files with 69 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ repos:
rev: v8.56.0
hooks:
- id: eslint
args: ['-c', 'panel/.eslintrc.js', 'panel/*.ts', 'panel/models/**/*.ts']
args: ['-c', 'panel/.eslintrc.js', 'panel/*.ts', 'panel/models/**/*.ts', '--fix']
additional_dependencies:
- '[email protected]'
- '@stylistic/[email protected]'
135 changes: 66 additions & 69 deletions panel/models/jstree.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as p from "@bokehjs/core/properties"
import type * as p from "@bokehjs/core/properties"
import type {StyleSheetLike} from "@bokehjs/core/dom"
import { div } from "@bokehjs/core/dom"
import {div} from "@bokehjs/core/dom"
import {ModelEvent} from "@bokehjs/core/bokeh_events"
import type {Attrs} from "@bokehjs/core/types"
import {LayoutDOM, LayoutDOMView} from "@bokehjs/models/layouts/layout_dom"
@@ -9,8 +9,8 @@ import {ID} from "./util"
import jstree_css from "styles/models/jstree.css"

type Node = {
[key: string]: any;
};
[key: string]: any
}

declare function jQuery(...args: any[]): any

@@ -37,10 +37,10 @@ export class jsTreeView extends LayoutDOMView {
override connect_signals(): void {
super.connect_signals()
const {nodes, value, checkbox, show_icons, show_dots, multiple} = this.model.properties
this.on_change(nodes, () => this._jstree.jstree(true).load_node('#', () => {
this.on_change(nodes, () => this._jstree.jstree(true).load_node("#", () => {
this._jstree.jstree(true).refresh({
"skip_loading": false,
"forget_state": true,
skip_loading: false,
forget_state: true,
})
this._update_selection_from_value()
}))
@@ -77,62 +77,62 @@ export class jsTreeView extends LayoutDOMView {
override render(): void {
super.render()
this._id = ID()
this._container = div({id: this._id, style: "overflow: auto; minHeight: 200px; minWidth: 200px;"},)
this.shadow_el.appendChild(this._container);
this._container = div({id: this._id, style: "overflow: auto; minHeight: 200px; minWidth: 200px;"})
this.shadow_el.appendChild(this._container)
this._jstree = jQuery(this._container).jstree({
"checkbox": {
"three_state": this.model.cascade,
"cascade": this.model.cascade ? "undetermined" : "down+undetermined",
checkbox: {
three_state: this.model.cascade,
cascade: this.model.cascade ? "undetermined" : "down+undetermined",
},
"core": {
"data": (obj: Node, callback: (nodes: Node[]) => void) => {
if (obj.id == '#') {
callback(this.model.nodes)
} else {
this.model.trigger_event(new NodeEvent({type: 'open', node: obj}))
new Promise((resolve) => {
const loop = () => {
const nodes = this.model._new_nodes
if (nodes != null) {
obj.new_nodes = nodes
callback(obj.children_nodes)
this.model._new_nodes = null
resolve(this.model.nodes)
} else {
setTimeout(loop, 10)
}
}
loop();
}).catch(() => console.warn('Failed to fetch nodes'))
}
},
"check_callback": true,
"multiple": this.model.multiple,
"themes": {
"dots": this.model.show_dots,
"icons": this.model.show_icons,
"stripes": this.model.show_stripes,
}
core: {
data: (obj: Node, callback: (nodes: Node[]) => void) => {
if (obj.id == "#") {
callback(this.model.nodes)
} else {
this.model.trigger_event(new NodeEvent({type: "open", node: obj}))
new Promise((resolve) => {
const loop = () => {
const nodes = this.model._new_nodes
if (nodes != null) {
obj.new_nodes = nodes
callback(obj.children_nodes)
this.model._new_nodes = null
resolve(this.model.nodes)
} else {
setTimeout(loop, 10)
}
}
loop()
}).catch(() => console.warn("Failed to fetch nodes"))
}
},
check_callback: true,
multiple: this.model.multiple,
themes: {
dots: this.model.show_dots,
icons: this.model.show_icons,
stripes: this.model.show_stripes,
},
},
"plugins": this.plugins,
"sort": (n1: string, n2: string) => {
const n1_folder = n1.endsWith('/')
const n2_folder = n2.endsWith('/')
if (n1_folder && !n2_folder) {
return -1
} else if (!n1_folder && n2_folder) {
return 1
}
return n1 > n2 ? 1 : -1
plugins: this.plugins,
sort: (n1: string, n2: string) => {
const n1_folder = n1.endsWith("/")
const n2_folder = n2.endsWith("/")
if (n1_folder && !n2_folder) {
return -1
} else if (!n1_folder && n2_folder) {
return 1
}
return n1 > n2 ? 1 : -1
},
});
})
this.init_callbacks()
}

init_callbacks(): void {
this._jstree.on('activate_node.jstree', ({}, data: any) => this.selectNodeFromEditor({}, data));
this._jstree.on('refresh.jstree', ({}, {}) => this._update_selection_from_value());
this._jstree.on('before_open.jstree', (_: any, data: any) => this._listen_for_node_open(data));
this._jstree.on("activate_node.jstree", ({}, data: any) => this.selectNodeFromEditor({}, data))
this._jstree.on("refresh.jstree", ({}, {}) => this._update_selection_from_value())
this._jstree.on("before_open.jstree", (_: any, data: any) => this._listen_for_node_open(data))
}

selectNodeFromEditor({}, data: any): void {
@@ -146,28 +146,25 @@ export class jsTreeView extends LayoutDOMView {

_setShowIcons(): void {
if (this.model.show_icons) {
this._jstree.jstree(true).show_icons();
}
else {
this._jstree.jstree(true).hide_icons();
this._jstree.jstree(true).show_icons()
} else {
this._jstree.jstree(true).hide_icons()
}
}

_setShowDots(): void {
// console.log("setShowDots")
if (this.model.show_dots) {
this._jstree.jstree(true).show_dots()
}
else {
} else {
this._jstree.jstree(true).hide_dots()
}
}

setCheckboxes(): void {
if (this.model.checkbox) {
this._jstree.jstree(true).show_checkboxes()
}
else {
} else {
this._jstree.jstree(true).hide_checkboxes()
}
}
@@ -181,17 +178,17 @@ export class jsTreeView extends LayoutDOMView {
let request_load = false
for (const child of data.node.children) {
const child_node = data.instance.get_node(child)
if (child_node.original.type === 'folder' && !child_node.children.length) {
request_load = true
if (child_node.original.type === "folder" && !child_node.children.length) {
request_load = true
}
data.node.children_nodes.push(child_node)
}
if (request_load) {
data.instance.load_node(data.node.id, (node: Node) => {
for (const new_node of node.new_nodes) {
this._jstree.jstree(true).create_node(new_node["parent"], new_node)
}
delete node.new_nodes
for (const new_node of node.new_nodes) {
this._jstree.jstree(true).create_node(new_node.parent, new_node)
}
delete node.new_nodes
})
}
}
2 changes: 1 addition & 1 deletion panel/models/util.ts
Original file line number Diff line number Diff line change
@@ -81,5 +81,5 @@ export function ID() {
// Math.random should be unique because of its seeding algorithm.
// Convert it to base 36 (numbers + letters), and grab the first 9 characters
// after the decimal.
return '_' + Math.random().toString(36).substring(2, 11);
return `_${ Math.random().toString(36).substring(2, 11)}`
}
2 changes: 1 addition & 1 deletion panel/models/vtk/vtkvolume.ts
Original file line number Diff line number Diff line change
@@ -133,7 +133,7 @@ export class VTKVolumePlotView extends AbstractVTKView {
this._create_orientation_widget()
this._set_axes()
this._vtk_renwin.getRenderer().resetCamera()
if (Object.keys(this.model.camera).length) {
if (Object.keys(this.model.camera).length > 0) {
this._set_camera_state()
}
this._get_camera_state()

0 comments on commit 607122a

Please sign in to comment.