Add the ability to edit the time of a workout and the associated activity. #183
|
@ -386,7 +386,7 @@ where
|
|||
biking_button.connect_clicked({
|
||||
let view_model = view_model.clone();
|
||||
move |_| {
|
||||
let workout = view_model.new_time_distance(TimeDistanceActivity::BikeRide);
|
||||
let workout = view_model.new_time_distance(TimeDistanceActivity::Biking);
|
||||
add_row(workout.map(TraxRecord::TimeDistance));
|
||||
}
|
||||
});
|
||||
|
|
|
@ -129,7 +129,7 @@ impl Default for TimeDistanceEditPrivate {
|
|||
Self {
|
||||
workout: RefCell::new(TimeDistance {
|
||||
datetime: chrono::Utc::now().into(),
|
||||
activity: TimeDistanceActivity::BikeRide,
|
||||
activity: TimeDistanceActivity::Biking,
|
||||
duration: None,
|
||||
distance: None,
|
||||
comments: None,
|
||||
|
|
|
@ -510,7 +510,7 @@ mod test {
|
|||
id: RecordId::default(),
|
||||
data: TraxRecord::TimeDistance(ft_core::TimeDistance {
|
||||
datetime: oct_13_am.clone(),
|
||||
activity: TimeDistanceActivity::BikeRide,
|
||||
activity: TimeDistanceActivity::Biking,
|
||||
distance: Some(15000. * si::M),
|
||||
duration: Some(3600. * si::S),
|
||||
comments: Some("somecomments present".to_owned()),
|
||||
|
@ -560,11 +560,11 @@ mod test {
|
|||
async fn it_can_construct_new_records() {
|
||||
let (view_model, provider) = create_empty_view_model().await;
|
||||
assert_eq!(
|
||||
view_model.time_distance_summary(TimeDistanceActivity::BikeRide),
|
||||
view_model.time_distance_summary(TimeDistanceActivity::Biking),
|
||||
(0. * si::M, 0. * si::S)
|
||||
);
|
||||
|
||||
let mut record = view_model.new_time_distance(TimeDistanceActivity::BikeRide);
|
||||
let mut record = view_model.new_time_distance(TimeDistanceActivity::Biking);
|
||||
record.data.duration = Some(60. * si::S);
|
||||
view_model.async_save().await;
|
||||
|
||||
|
@ -577,17 +577,17 @@ mod test {
|
|||
async fn it_can_update_a_new_record_before_saving() {
|
||||
let (view_model, provider) = create_empty_view_model().await;
|
||||
assert_eq!(
|
||||
view_model.time_distance_summary(TimeDistanceActivity::BikeRide),
|
||||
view_model.time_distance_summary(TimeDistanceActivity::Biking),
|
||||
(0. * si::M, 0. * si::S)
|
||||
);
|
||||
|
||||
let mut record = view_model.new_time_distance(TimeDistanceActivity::BikeRide);
|
||||
let mut record = view_model.new_time_distance(TimeDistanceActivity::Biking);
|
||||
record.data.duration = Some(60. * si::S);
|
||||
let record = record.map(TraxRecord::TimeDistance);
|
||||
view_model.update_record(record.clone());
|
||||
assert_eq!(view_model.get_record(&record.id), Some(record));
|
||||
assert_eq!(
|
||||
view_model.time_distance_summary(TimeDistanceActivity::BikeRide),
|
||||
view_model.time_distance_summary(TimeDistanceActivity::Biking),
|
||||
(0. * si::M, 60. * si::S)
|
||||
);
|
||||
assert_eq!(
|
||||
|
@ -610,7 +610,7 @@ mod test {
|
|||
view_model.update_record(workout.map(TraxRecord::TimeDistance));
|
||||
|
||||
assert_eq!(
|
||||
view_model.time_distance_summary(TimeDistanceActivity::BikeRide),
|
||||
view_model.time_distance_summary(TimeDistanceActivity::Biking),
|
||||
(15000. * si::M, 1800. * si::S)
|
||||
);
|
||||
|
||||
|
@ -625,11 +625,11 @@ mod test {
|
|||
async fn it_can_remove_a_new_record() {
|
||||
let (view_model, provider) = create_empty_view_model().await;
|
||||
assert_eq!(
|
||||
view_model.time_distance_summary(TimeDistanceActivity::BikeRide),
|
||||
view_model.time_distance_summary(TimeDistanceActivity::Biking),
|
||||
(0. * si::M, 0. * si::S)
|
||||
);
|
||||
|
||||
let record = view_model.new_time_distance(TimeDistanceActivity::BikeRide);
|
||||
let record = view_model.new_time_distance(TimeDistanceActivity::Biking);
|
||||
view_model.remove_record(record.id);
|
||||
view_model.save();
|
||||
|
||||
|
@ -645,7 +645,7 @@ mod test {
|
|||
|
||||
view_model.remove_record(workout.id);
|
||||
assert_eq!(
|
||||
view_model.time_distance_summary(TimeDistanceActivity::BikeRide),
|
||||
view_model.time_distance_summary(TimeDistanceActivity::Biking),
|
||||
(0. * si::M, 0. * si::S)
|
||||
);
|
||||
view_model.async_save().await;
|
||||
|
|
|
@ -51,7 +51,7 @@ impl Recordable for Steps {
|
|||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub enum TimeDistanceActivity {
|
||||
BikeRide,
|
||||
Biking,
|
||||
Running,
|
||||
Rowing,
|
||||
Swimming,
|
||||
|
@ -59,7 +59,7 @@ pub enum TimeDistanceActivity {
|
|||
}
|
||||
|
||||
pub const TIME_DISTANCE_ACTIVITIES: [TimeDistanceActivity; 5] = [
|
||||
TimeDistanceActivity::BikeRide,
|
||||
TimeDistanceActivity::Biking,
|
||||
TimeDistanceActivity::Rowing,
|
||||
TimeDistanceActivity::Running,
|
||||
TimeDistanceActivity::Swimming,
|
||||
|
@ -141,7 +141,7 @@ impl TraxRecord {
|
|||
matches!(
|
||||
self,
|
||||
TraxRecord::TimeDistance(TimeDistance {
|
||||
activity: TimeDistanceActivity::BikeRide,
|
||||
activity: TimeDistanceActivity::Biking,
|
||||
..
|
||||
}) | TraxRecord::TimeDistance(TimeDistance {
|
||||
activity: TimeDistanceActivity::Running,
|
||||
|
|
Loading…
Reference in New Issue