diff --git a/fd b/fd index 2b162ce..deb623b 100755 --- a/fd +++ b/fd @@ -1,5 +1,5 @@ #!/bin/bash scp read@128.140.64.118:/home/rowing/db.sqlite db.sqlite -sqlite3 db.sqlite < seeds.sql +#sqlite3 db.sqlite < seeds.sql diff --git a/frontend/main.ts b/frontend/main.ts index 8a71157..69efee5 100644 --- a/frontend/main.ts +++ b/frontend/main.ts @@ -118,6 +118,8 @@ interface ChoiceBoatEvent extends Event { default_destination: string; boat_in_ottensheim: boolean; boat_reserved_today: boolean; + default_handoperated: boolean; + convert_handoperated_possible: boolean; }; }; } @@ -147,6 +149,19 @@ function selectBoatChange() { const amount_seats = event.detail.customProperties.amount_seats; setMaxAmountRowers("newrower", amount_seats); + let only_steering = document.querySelector('#shipmaster_only_steering'); + if (event.detail.customProperties.default_handoperated) { + only_steering.setAttribute('checked', 'true'); + }else { + only_steering.removeAttribute('checked'); + } + + if (event.detail.customProperties.convert_handoperated_possible) { + only_steering.removeAttribute('disabled'); + }else { + only_steering.setAttribute('disabled', 'disabled'); + } + const destination = ( document.querySelector("#destination") ); @@ -159,9 +174,7 @@ function selectBoatChange() { if(event.detail.value === '36') { /** custom code for Etsch */ - choiceObjects["newrower"].setChoiceByValue( - "81", - ); + choiceObjects["newrower"].setChoiceByValue("81"); } } @@ -250,22 +263,6 @@ function setMaxAmountRowers(name: string, rowers: number) { } } - //let only_steering = document.querySelector('#shipmaster_only_steering'); - //if(only_steering) { - // if(isShipmasterSteering == 'true') { - // only_steering.removeAttribute('disabled'); - // only_steering.setAttribute('checked', 'true'); - // only_steering.parentElement?.parentElement?.parentElement?.classList.remove('hidden'); - // only_steering.parentElement?.parentElement?.parentElement?.classList.remove('md:block'); - // only_steering.parentElement?.parentElement?.parentElement?.classList.remove('opacity-50'); - // } else { - // only_steering.setAttribute('disabled', 'disabled'); - // only_steering.removeAttribute('checked'); - // only_steering.parentElement?.parentElement?.parentElement?.classList.add('hidden'); - // only_steering.parentElement?.parentElement?.parentElement?.classList.add('md:block'); - // only_steering.parentElement?.parentElement?.parentElement?.classList.add('opacity-50'); - // } - //} let shipmaster = ( document.querySelector("#shipmaster-" + name + "js") ); diff --git a/migration.sql b/migration.sql index f19d5f8..4ce8ee2 100644 --- a/migration.sql +++ b/migration.sql @@ -99,6 +99,7 @@ CREATE TABLE IF NOT EXISTS "boat" ( "year_built" INTEGER, "boatbuilder" TEXT, "default_shipmaster_only_steering" boolean default false not null, + "convert_handoperated_possible" boolean default false not null, "default_destination" text, "skull" boolean default true NOT NULL, -- false => riemen "external" boolean default false NOT NULL, -- false => owned by different club diff --git a/src/model/boat.rs b/src/model/boat.rs index 05a2e1c..702aed8 100644 --- a/src/model/boat.rs +++ b/src/model/boat.rs @@ -21,6 +21,8 @@ pub struct Boat { pub boatbuilder: Option, pub default_destination: Option, #[serde(default = "bool::default")] + convert_handoperated_possible: bool, + #[serde(default = "bool::default")] default_shipmaster_only_steering: bool, #[serde(default = "bool::default")] skull: bool, @@ -53,6 +55,7 @@ pub struct BoatToAdd<'r> { pub year_built: Option, pub boatbuilder: Option<&'r str>, pub default_shipmaster_only_steering: bool, + pub convert_handoperated_possible: bool, pub default_destination: Option<&'r str>, pub skull: bool, pub external: bool, @@ -69,6 +72,7 @@ pub struct BoatToUpdate<'r> { pub default_shipmaster_only_steering: bool, pub default_destination: Option<&'r str>, pub skull: bool, + pub convert_handoperated_possible: bool, pub external: bool, pub location_id: i64, pub owner: Option, @@ -189,7 +193,7 @@ AND date('now') BETWEEN start_date AND end_date;", let boats = sqlx::query_as!( Boat, " -SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted +SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted, convert_handoperated_possible FROM boat WHERE deleted=false ORDER BY amount_seats DESC @@ -218,7 +222,8 @@ SELECT b.default_destination, b.skull, b.external, - b.deleted + b.deleted, + b.convert_handoperated_possible FROM boat AS b WHERE @@ -244,7 +249,7 @@ ORDER BY sqlx::query_as!( Boat, " -SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted +SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted, convert_handoperated_possible FROM boat WHERE owner is null or owner = ? ORDER BY amount_seats DESC @@ -258,7 +263,7 @@ ORDER BY amount_seats DESC sqlx::query_as!( Boat, " -SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted +SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted, convert_handoperated_possible FROM boat WHERE owner = ? OR (owner is null and amount_seats = 1) ORDER BY amount_seats DESC @@ -276,7 +281,7 @@ ORDER BY amount_seats DESC .unwrap(); let boats_in_ottensheim = sqlx::query_as!( Boat, - "SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted + "SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted, convert_handoperated_possible FROM boat WHERE owner is null and location_id = ? ORDER BY amount_seats DESC @@ -295,7 +300,7 @@ ORDER BY amount_seats DESC let boats = sqlx::query_as!( Boat, " -SELECT boat.id, boat.name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted +SELECT boat.id, boat.name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted, convert_handoperated_possible FROM boat INNER JOIN location ON boat.location_id = location.id WHERE location.name=? @@ -312,7 +317,7 @@ ORDER BY amount_seats DESC pub async fn create(db: &SqlitePool, boat: BoatToAdd<'_>) -> Result<(), String> { sqlx::query!( - "INSERT INTO boat(name, amount_seats, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, location_id, owner) VALUES (?,?,?,?,?,?,?,?,?,?)", + "INSERT INTO boat(name, amount_seats, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, location_id, owner, convert_handoperated_possible) VALUES (?,?,?,?,?,?,?,?,?,?,?)", boat.name, boat.amount_seats, boat.year_built, @@ -322,7 +327,8 @@ ORDER BY amount_seats DESC boat.skull, boat.external, boat.location_id, - boat.owner + boat.owner, + boat.convert_handoperated_possible ) .execute(db) .await.map_err(|e| e.to_string())?; @@ -331,7 +337,7 @@ ORDER BY amount_seats DESC pub async fn update(&self, db: &SqlitePool, boat: BoatToUpdate<'_>) -> Result<(), String> { sqlx::query!( - "UPDATE boat SET name=?, amount_seats=?, year_built=?, boatbuilder=?, default_shipmaster_only_steering=?, default_destination=?, skull=?, external=?, location_id=?, owner=? WHERE id=?", + "UPDATE boat SET name=?, amount_seats=?, year_built=?, boatbuilder=?, default_shipmaster_only_steering=?, default_destination=?, skull=?, external=?, location_id=?, owner=?, convert_handoperated_possible=? WHERE id=?", boat.name, boat.amount_seats, boat.year_built, @@ -342,6 +348,7 @@ ORDER BY amount_seats DESC boat.external, boat.location_id, boat.owner, + boat.convert_handoperated_possible, self.id ) .execute(db) diff --git a/staging-diff.sql b/staging-diff.sql index 6fb21fc..3cbc8dc 100644 --- a/staging-diff.sql +++ b/staging-diff.sql @@ -1,3 +1,6 @@ +ALTER TABLE boat ADD COLUMN convert_handoperated_possible BOOLEAN DEFAULT false NOT NULL; + + -- test user INSERT INTO user(name) VALUES('Marie'); INSERT INTO "user_role" (user_id, role_id) VALUES((SELECT id from user where name = 'Marie'),(SELECT id FROM role where name = 'Donau Linz')); diff --git a/templates/includes/forms/boat.html.tera b/templates/includes/forms/boat.html.tera index bb37e33..9d90b72 100644 --- a/templates/includes/forms/boat.html.tera +++ b/templates/includes/forms/boat.html.tera @@ -24,6 +24,7 @@ {{ macros::input(label='Default destination', name='default_destination', type='text') }}
{{ macros::checkbox(label="handgesteuert", name="default_shipmaster_only_steering") }} + {{ macros::checkbox(label="Umbau Hand-/Fußsteuerung möglich", name="convert_handoperated_possible") }} {{ macros::checkbox(label="Skull", name="skull", checked=true) }} {{ macros::checkbox(label="Externes Boot (anderer Verein)", name="external") }}
@@ -66,6 +67,7 @@ {{ macros::input(label='Baujahr', name='year_built', type='number', min=1950, value=boat.year_built) }} {{ macros::input(label='Bootsbauer', name='boatbuilder', type='text', value=boat.boatbuilder) }} {{ macros::checkbox(label='handgesteuert', name='default_shipmaster_only_steering', id=uuid , checked=boat.default_shipmaster_only_steering) }} + {{ macros::checkbox(label='Umbau Hand-/Fußsteuerung möglich', name='convert_handoperated_possible', id=uuid , checked=boat.convert_handoperated_possible) }} {{ macros::input(label='Default destination', name='default_destination', type='text', value=boat.default_destination) }} {{ macros::checkbox(label='Skull', name='skull', id=uuid , checked=boat.skull) }} {{ macros::checkbox(label='Externes Boot', name='external', id=uuid , checked=boat.external) }} diff --git a/templates/includes/forms/log.html.tera b/templates/includes/forms/log.html.tera index 42fbbca..99d308e 100644 --- a/templates/includes/forms/log.html.tera +++ b/templates/includes/forms/log.html.tera @@ -7,12 +7,12 @@
- {% if grouped_boats[0].amount_seats < 9 or grouped_boats[0].amount_seats == 24 %} - {{ amount_seats }}x - {% elif grouped_boats[0].amount_seats == 9 %} + {% if grouped_boats[0].external %} + Vereinsfremde Boote + {% elif grouped_boats[0].default_shipmaster_only_steering %} {{ grouped_boats[0].amount_seats - 1 }}+ {% else %} - Vereinsfremde Boote + {{ amount_seats }}x {% endif %} ({{ grouped_boats | length }}) diff --git a/templates/includes/macros.html.tera b/templates/includes/macros.html.tera index 09c1c8b..3593c62 100644 --- a/templates/includes/macros.html.tera +++ b/templates/includes/macros.html.tera @@ -159,7 +159,7 @@ {% if required %}required="required"{% endif %}> {% if default %}{% endif %} {% for d in data %} -