Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd62cd7e

Browse files
Dan estimator fix (#1075)
1 parentc1aacf6 commitd62cd7e

File tree

3 files changed

+38
-19
lines changed

3 files changed

+38
-19
lines changed

‎pgml-dashboard/src/components/inputs/range_group/mod.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use pgml_components::component;
22
use sailfish::TemplateOnce;
3+
usecrate::components::stimulus::stimulus_target::StimulusTarget;
34

45
#[derive(TemplateOnce,Default)]
56
#[template(path ="inputs/range_group/template.html")]
@@ -10,10 +11,11 @@ pub struct RangeGroup {
1011
pubmax:i64,
1112
pubstep:f32,
1213
pubinitial_value:f64,
13-
pubtext_target:Option<String>,
14-
pubrange_target:Option<String>,
14+
pubtext_target:StimulusTarget,
15+
pubrange_target:StimulusTarget,
1516
pubcost_rate:Option<f32>,
1617
pubunits:String,
18+
pubgroup_target:StimulusTarget,
1719
}
1820

1921
implRangeGroup{
@@ -25,10 +27,11 @@ impl RangeGroup {
2527
max:100,
2628
step:1.0,
2729
initial_value:1.0,
28-
text_target:None,
29-
range_target:None,
30+
text_target:StimulusTarget::new(),
31+
range_target:StimulusTarget::new(),
3032
cost_rate:None,
3133
units:String::default(),
34+
group_target:StimulusTarget::new(),
3235
}
3336
}
3437

@@ -49,13 +52,13 @@ impl RangeGroup {
4952
self
5053
}
5154

52-
pubfntext_target(mutself,target:&str) ->Self{
53-
self.text_target =Some(target.to_owned());
55+
pubfntext_target(mutself,target:StimulusTarget) ->Self{
56+
self.text_target = target;
5457
self
5558
}
5659

57-
pubfnrange_target(mutself,target:&str) ->Self{
58-
self.range_target =Some(target.to_owned());
60+
pubfnrange_target(mutself,target:StimulusTarget) ->Self{
61+
self.range_target = target.to_owned();
5962
self
6063
}
6164

@@ -68,6 +71,11 @@ impl RangeGroup {
6871
self.units = units.to_owned();
6972
self
7073
}
74+
75+
pubfngroup_target(mutself,target:StimulusTarget) ->Self{
76+
self.group_target = target;
77+
self
78+
}
7179
}
7280

7381
component!(RangeGroup);

‎pgml-dashboard/src/components/inputs/range_group/range_group_controller.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ export default class extends Controller {
55
statictargets=[
66
"range",
77
"text",
8+
"group"
89
]
910

1011
staticvalues={
11-
bounds:Object
12+
bounds:Object,
13+
initial:Number
1214
}
1315

1416
initialize(){
@@ -17,26 +19,30 @@ export default class extends Controller {
1719

1820
updateText(e){
1921
this.textTarget.value=e.target.value
22+
this.groupTarget.dispatchEvent(newEvent("rangeInput"))
2023
}
2124

2225
updateRange(e){
2326
if(e.target.value<this.boundsValue.min
2427
||!e.target.value||!this.isNumeric(e.target.value)){
2528
this.rangeTarget.value=this.boundsValue.min
2629
this.textTarget.value=this.boundsValue.min
27-
return
28-
}
29-
30-
if(e.target.value>this.boundsValue.max){
30+
}elseif(e.target.value>this.boundsValue.max){
3131
this.rangeTarget.value=this.boundsValue.max
3232
this.textTarget.value=this.boundsValue.max
33-
return
33+
}else{
34+
this.rangeTarget.value=e.target.value
3435
}
3536

36-
this.rangeTarget.value=e.target.value
37+
this.groupTarget.dispatchEvent(newEvent("rangeInput"))
3738
}
3839

3940
isNumeric(n){
4041
return!isNaN(parseFloat(n))&&isFinite(n);
4142
}
43+
44+
reset(){
45+
this.rangeTarget.value=this.initialValue
46+
this.textTarget.value=this.initialValue
47+
}
4248
}

‎pgml-dashboard/src/components/inputs/range_group/template.html

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
<divdata-controller="inputs-range-group"data-inputs-range-group-bounds-value='{"min": <%- min%>, "max": <%- max%>}'>
1+
<divdata-controller="inputs-range-group"
2+
data-inputs-range-group-bounds-value='{"min": <%- min%>, "max": <%- max%>}'
3+
data-inputs-range-group-initial-value="<%- initial_value.to_string() %>"
4+
data-inputs-range-group-target="group"
5+
<%- group_target %>
6+
data-action="reset->inputs-range-group#reset">
27
<divclass="d-flex flex-column flex-md-row">
38
<divclass="flex-grow-1">
49
<h6class="h6"><%- title %></h6>
510
</div>
611
<div>
712
<divclass="input-group">
8-
<inputclass="text-input form-control text-end text-white fw-bold"maxlength="4"type="text"
13+
<inputclass="text-input form-control text-end text-white fw-bold"maxlength="5"type="text"
914
data-inputs-range-group-target="text"
1015
data-action="focusout->inputs-range-group#updateRange"
11-
<% if text_target.is_some() {%><%- text_target.unwrap()%><% } %>>
16+
<%- text_target %>>
1217
<divclass="input-group-text fw-bold text-start"style="width: 2em;">
1318
<%- units %>
1419
</div>
@@ -25,7 +30,7 @@ <h6 class="h6"><%- title %></h6>
2530
value="<%- initial_value.to_string() %>"
2631
data-action="inputs-range-group#updateText"
2732
data-inputs-range-group-target="range"
28-
<% if range_target.is_some() { %><%- range_target.unwrap() %><% } %>>
33+
<%- range_target %>>
2934

3035
<% if cost_rate.is_some() { %>
3136
<divclass="w-100 d-flex justify-content-end">

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp