Skip to content

Commit

Permalink
move logic to DashBase
Browse files Browse the repository at this point in the history
  • Loading branch information
BeastyBlacksmith committed Aug 2, 2023
1 parent f68151f commit 68dca5e
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 37 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6"
[compat]
Aqua = "0.6"
CodecZlib = "0.6, 0.7"
DashBase = "0.2"
DashBase = "0.2.1"
DashCoreComponents = "2.0.0"
DashHtmlComponents = "2.0.0"
DashTable = "5.0.0"
Expand Down
22 changes: 0 additions & 22 deletions src/app/dashapp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,6 @@ mutable struct DashApp

end

const VecChildTypes = Union{NTuple{N, DashBase.Component} where {N}, Vector{<:DashBase.Component}}

function Base.getindex(component::DashBase.Component, id::AbstractString)
component.id == id && return component
hasproperty(component, :children) || return nothing
cc = component.children
return if cc isa Union{VecChildTypes, DashBase.Component}
cc[id]
elseif cc isa AbstractVector
fcc = identity.(filter(x->hasproperty(x, :id), cc))
isempty(fcc) ? nothing : fcc[id]
else
nothing
end
end
function Base.getindex(children::VecChildTypes, id::AbstractString)
for element in children
element.id == id && return element
el = element[id]
el !== nothing && return el
end
end

#only name, index_string and layout are available to set
function Base.setproperty!(app::DashApp, property::Symbol, value)
Expand Down
14 changes: 0 additions & 14 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -201,17 +201,3 @@ end
@test_throws ErrorException make_handler(app)
end

@testset "Index by id" begin
app = dash()
app.layout = html_div() do
dcc_input(id = "my-id", value="initial value", type = "text"),
html_div(id = "my-div", children = [
html_div(children = []),
"string",
html_div(id = "target")
]),
html_div(id = "my-div2")
end
@test app.layout["target"].id == "target"
@test app.layout["ups"] === nothing
end

0 comments on commit 68dca5e

Please sign in to comment.