Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
S
sparrowzz
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
sgool
sparrowzz
Commits
d0d4860a
Commit
d0d4860a
authored
Oct 17, 2024
by
dongshufeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
输入控件
parent
a554184e
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
143 行增加
和
0 行删除
+143
-0
mems/examples/iesplan/src/lib.rs
+1
-0
mems/examples/iesplan/src/paracard.rs
+142
-0
没有找到文件。
mems/examples/iesplan/src/lib.rs
查看文件 @
d0d4860a
...
@@ -5,6 +5,7 @@ use crate::startpage::StartPage;
...
@@ -5,6 +5,7 @@ use crate::startpage::StartPage;
use
yew_bulma
::
layout
::
tiles
::
Tiles
;
use
yew_bulma
::
layout
::
tiles
::
Tiles
;
use
eig_domain
::
excel
::
get_first_sheet_merged_cells
;
use
eig_domain
::
excel
::
get_first_sheet_merged_cells
;
pub
mod
startpage
;
pub
mod
startpage
;
mod
paracard
;
#[wasm_bindgen]
#[wasm_bindgen]
pub
fn
create_view
(
e
:
Element
)
{
pub
fn
create_view
(
e
:
Element
)
{
...
...
mems/examples/iesplan/src/paracard.rs
0 → 100644
查看文件 @
d0d4860a
use
wasm_bindgen
::
JsCast
;
use
web_sys
::
InputEvent
;
use
yew
::
prelude
::
*
;
use
yew_bulma
::
*
;
pub
enum
ParaType
{
// show expresion, true expression, false expression
Checkbox
,
Radio
,
Switch
,
Select
(
Vec
<
f64
>
),
Slider
(
f64
,
f64
,
f64
,
bool
),
TextField
,
}
pub
enum
Msg
{
SetBool
(
usize
,
bool
),
SetString
(
usize
),
SetOption
(
usize
,
String
),
}
pub
struct
ParaCard
{
labels
:
Vec
<
String
>
,
points
:
Vec
<
u64
>
,
para_types
:
Vec
<
ParaType
>
,
}
impl
Component
for
ParaCard
{
type
Message
=
Msg
;
type
Properties
=
();
fn
create
(
ctx
:
&
Context
<
Self
>
)
->
Self
{
todo!
()
}
fn
view
(
&
self
,
ctx
:
&
Context
<
Self
>
)
->
Html
{
let
input_html
=
(
0
..
self
.points
.len
())
.map
(|
i
|
{
self
.create_input
(
ctx
,
i
)
})
.collect
::
<
Html
>
();
html!
{
<
Card
>
<
CardContent
>
{
input_html
}
<
/
CardContent
>
<
/
Card
>
}
}
}
impl
ParaCard
{
fn
create_input
(
&
self
,
ctx
:
&
Context
<
Self
>
,
i
:
usize
)
->
Html
{
let
point_id
=
&
self
.points
[
i
];
let
input_type
=
&
self
.para_types
[
i
];
let
link
=
ctx
.link
();
let
label
=
if
let
Some
(
label
)
=
self
.labels
.get
(
i
)
{
label
.clone
()
}
else
{
""
.to_string
()
};
match
input_type
{
ParaType
::
Checkbox
=>
{
let
checked
=
true
;
html!
{
<
Field
horizontal
=
{
true
}
>
<
Checkbox
checked
=
{
checked
}
update
=
{
link
.callback
(
move
|
b
|
Msg
::
SetBool
(
i
,
b
))}
>
{
label
}
<
/
Checkbox
>
<
/
Field
>
}
}
ParaType
::
Radio
=>
{
let
checked
=
true
;
html!
{
<
Field
horizontal
=
{
true
}
>
<
Radio
update
=
{
link
.callback
(
move
|
_
|
Msg
::
SetBool
(
i
,
!
checked
))}
checked_value
=
{
"selected"
}
value
=
{
if
checked
{
"selected"
}
else
{
"none"
}}
>
<
span
>
{
label
}
<
/
span
>
<
/
Radio
>
<
/
Field
>
}
}
ParaType
::
Switch
=>
{
let
checked
=
true
;
html!
{
<
Field
horizontal
=
{
true
}
label
=
{
label
}
>
<
input
class
=
{
classes!
(
"mui-switch"
,
"mui-switch-animbg"
)}
type
=
"checkbox"
checked
=
{
checked
}
onclick
=
{
link
.callback
(
move
|
_
|
Msg
::
SetBool
(
i
,
!
checked
))}
/
>
<
/
Field
>
}
}
ParaType
::
Slider
(
lower
,
upper
,
step
,
is_vertical
)
=>
{
let
oninput
=
link
.callback
(
move
|
e
:
InputEvent
|
{
let
target
=
e
.target
()
.unwrap
();
let
input
=
target
.dyn_into
::
<
web_sys
::
HtmlInputElement
>
()
.unwrap
();
Msg
::
SetOption
(
i
,
input
.value
())
});
html!
{
<
Field
horizontal
=
{
true
}
label
=
{
label
}
>
<
input
class
=
{
"slider is-fullwidth"
}
type
=
{
"range"
}
orient
=
{
if
*
is_vertical
{
"vertical"
}
else
{
"horizontal"
}}
oninput
=
{
oninput
}
step
=
{
step
.to_string
()}
min
=
{
lower
.to_string
()}
max
=
{
upper
.to_string
()}
value
=
{
lower
.to_string
()}
/
>
<
/
Field
>
}
}
ParaType
::
Select
(
options
)
=>
{
html!
{
<
Field
horizontal
=
{
true
}
label
=
{
label
}
>
<
Select
update
=
{
link
.callback
(
move
|
s
|
Msg
::
SetOption
(
i
,
s
))}
>
{
for
options
.iter
()
.map
(|
f
|
{
html!
{
<
option
value
=
{
f
.to_string
()}
>
{
f
.to_string
()}
<
/
option
>
}
})}
<
option
value
=
{
"None"
}
>
{
"no_selection"
}
<
/
option
>
<
/
Select
>
<
/
Field
>
}
}
ParaType
::
TextField
=>
{
let
name
=
format!
(
"tf_{}"
,
point_id
);
html!
{
<
Field
horizontal
=
{
true
}
label
=
{
label
}
>
<
Control
classes
=
{
classes!
(
"is-expanded"
)}
>
<
Input
placeholder
=
{
"eg: 10"
}
width
=
{
"12"
}
name
=
{
name
}
onenterdown
=
{
link
.callback
(
move
|
_
|
Msg
::
SetString
(
i
))}
/
>
<
/
Control
>
<
Control
>
<
Button
classes
=
{
classes!
(
"is-outlined"
)}
onclick
=
{
link
.callback
(
move
|
_
|
Msg
::
SetString
(
i
))}
>
<
Icon
awesome_icon
=
{
"fa fa-check"
}
/
>
<
/
Button
>
<
/
Control
>
<
/
Field
>
}
}
}
}
}
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论