Skip to content

Commit

Permalink
Reject training dates that lie in the future
Browse files Browse the repository at this point in the history
  • Loading branch information
senier authored and treiher committed Jun 1, 2024
1 parent 0d0e94d commit 0505ced
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed

- Reject future training dates

## [0.4.1] - 2024-05-20

### Fixed
Expand Down Expand Up @@ -110,6 +116,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Initial version of web app

[Unreleased]: https://github.com/treiher/valens/compare/v0.4.1...HEAD
[0.4.1]: https://github.com/treiher/valens/compare/v0.4.0...v0.4.1
[0.4.0]: https://github.com/treiher/valens/compare/v0.3.0...v0.4.0
[0.3.0]: https://github.com/treiher/valens/compare/v0.2.0...v0.3.0
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/page/training.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,9 @@ fn view_training_sessions_dialog(
return empty![];
}
}
let save_disabled = loading || form.date.1.is_none();
let today = Local::now().date_naive();
let date_valid = form.date.1.map_or(false, |d| d <= today);
let save_disabled = loading || !date_valid;
common::view_dialog(
"primary",
title,
Expand All @@ -416,11 +418,12 @@ fn view_training_sessions_dialog(
input_ev(Ev::Input, Msg::DateChanged),
input![
C!["input"],
C![IF![form.date.1.is_none() => "is-danger"]],
C![IF![!date_valid => "is-danger"]],
attrs! {
At::Type => "date",
At::Value => form.date.0,
At::Disabled => date_disabled.as_at_value(),
At::Max => today,
}
],
]
Expand Down

0 comments on commit 0505ced

Please sign in to comment.