Skip to content

Commit

Permalink
Autopopulate the repack date, granted in UTC :/
Browse files Browse the repository at this point in the history
  • Loading branch information
richo committed Jan 31, 2020
1 parent 304886a commit 2b4826d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/web/routes/rigging.rs
Expand Up @@ -11,7 +11,7 @@ use rocket::request::{Form, FromForm, FormItems, FlashMessage};
use rocket::response::{status, Flash, Redirect};
use rocket_contrib::templates::Template;

use chrono::naive::NaiveDate;
use chrono::prelude::*;

pub static EQUIPMENT_KINDS: &[&'static str] = &["container", "reserve", "aad"];

Expand Down Expand Up @@ -300,6 +300,15 @@ fn get_equipment(conn: &DbConn, user: &User, customer_id: Option<i32>) -> Vec<As
struct EquipmentDetailView {
equipment: Assembly,
repacks: Vec<Repack>,
today: String,
}

pub fn today_for_form() -> String {
// TODO(richo) timezones? Do we do this in JS?

Utc::today()
.format("%Y-%m-%d")
.to_string()
}

#[get("/equipment/<equipment_id>")]
Expand All @@ -314,6 +323,7 @@ pub fn equipment_detail(user: WebUser, conn: DbConn, flash: Option<FlashMessage<
let view = EquipmentDetailView {
equipment,
repacks,
today: today_for_form(),
};

let context = Context::rigging(view)
Expand Down
2 changes: 1 addition & 1 deletion web/templates/rigging/equipment-detail.html.hbs
Expand Up @@ -50,7 +50,7 @@
<input type="text" name="certificate" placeholder="Certificate">
<input type="text" name="seal" placeholder="Serial">
<input type="textbox" name="service" placeholder="service">
<input type="date" name="date" placeholder="Date">
<input type="date" name="date" placeholder="Date" value={{data.today}}>
</fieldset>
<button type="submit" class="pure-button pure-button-primary">repack</button>
</form>
Expand Down

0 comments on commit 2b4826d

Please sign in to comment.