handoperatable-feature #431

Merged
philipp merged 3 commits from handoperatable-feature into staging 2024-04-24 12:19:08 +02:00
8 changed files with 44 additions and 34 deletions
Showing only changes of commit a0dbd0f490 - Show all commits

2
fd
View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
scp read@128.140.64.118:/home/rowing/db.sqlite db.sqlite scp read@128.140.64.118:/home/rowing/db.sqlite db.sqlite
sqlite3 db.sqlite < seeds.sql #sqlite3 db.sqlite < seeds.sql

View File

@ -118,6 +118,8 @@ interface ChoiceBoatEvent extends Event {
default_destination: string; default_destination: string;
boat_in_ottensheim: boolean; boat_in_ottensheim: boolean;
boat_reserved_today: 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; const amount_seats = event.detail.customProperties.amount_seats;
setMaxAmountRowers("newrower", amount_seats); setMaxAmountRowers("newrower", amount_seats);
let only_steering = <HTMLSelectElement>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 = <HTMLSelectElement>( const destination = <HTMLSelectElement>(
document.querySelector("#destination") document.querySelector("#destination")
); );
@ -159,9 +174,7 @@ function selectBoatChange() {
if(event.detail.value === '36') { if(event.detail.value === '36') {
/** custom code for Etsch */ /** custom code for Etsch */
choiceObjects["newrower"].setChoiceByValue( choiceObjects["newrower"].setChoiceByValue("81");
"81",
);
} }
} }
@ -250,22 +263,6 @@ function setMaxAmountRowers(name: string, rowers: number) {
} }
} }
//let only_steering = <HTMLSelectElement>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 = <HTMLElement>( let shipmaster = <HTMLElement>(
document.querySelector("#shipmaster-" + name + "js") document.querySelector("#shipmaster-" + name + "js")
); );

View File

@ -99,6 +99,7 @@ CREATE TABLE IF NOT EXISTS "boat" (
"year_built" INTEGER, "year_built" INTEGER,
"boatbuilder" TEXT, "boatbuilder" TEXT,
"default_shipmaster_only_steering" boolean default false not null, "default_shipmaster_only_steering" boolean default false not null,
"convert_handoperated_possible" boolean default false not null,
"default_destination" text, "default_destination" text,
"skull" boolean default true NOT NULL, -- false => riemen "skull" boolean default true NOT NULL, -- false => riemen
"external" boolean default false NOT NULL, -- false => owned by different club "external" boolean default false NOT NULL, -- false => owned by different club

View File

@ -21,6 +21,8 @@ pub struct Boat {
pub boatbuilder: Option<String>, pub boatbuilder: Option<String>,
pub default_destination: Option<String>, pub default_destination: Option<String>,
#[serde(default = "bool::default")] #[serde(default = "bool::default")]
convert_handoperated_possible: bool,
#[serde(default = "bool::default")]
default_shipmaster_only_steering: bool, default_shipmaster_only_steering: bool,
#[serde(default = "bool::default")] #[serde(default = "bool::default")]
skull: bool, skull: bool,
@ -53,6 +55,7 @@ pub struct BoatToAdd<'r> {
pub year_built: Option<i64>, pub year_built: Option<i64>,
pub boatbuilder: Option<&'r str>, pub boatbuilder: Option<&'r str>,
pub default_shipmaster_only_steering: bool, pub default_shipmaster_only_steering: bool,
pub convert_handoperated_possible: bool,
pub default_destination: Option<&'r str>, pub default_destination: Option<&'r str>,
pub skull: bool, pub skull: bool,
pub external: bool, pub external: bool,
@ -69,6 +72,7 @@ pub struct BoatToUpdate<'r> {
pub default_shipmaster_only_steering: bool, pub default_shipmaster_only_steering: bool,
pub default_destination: Option<&'r str>, pub default_destination: Option<&'r str>,
pub skull: bool, pub skull: bool,
pub convert_handoperated_possible: bool,
pub external: bool, pub external: bool,
pub location_id: i64, pub location_id: i64,
pub owner: Option<i64>, pub owner: Option<i64>,
@ -189,7 +193,7 @@ AND date('now') BETWEEN start_date AND end_date;",
let boats = sqlx::query_as!( let boats = sqlx::query_as!(
Boat, 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 FROM boat
WHERE deleted=false WHERE deleted=false
ORDER BY amount_seats DESC ORDER BY amount_seats DESC
@ -218,7 +222,8 @@ SELECT
b.default_destination, b.default_destination,
b.skull, b.skull,
b.external, b.external,
b.deleted b.deleted,
b.convert_handoperated_possible
FROM FROM
boat AS b boat AS b
WHERE WHERE
@ -244,7 +249,7 @@ ORDER BY
sqlx::query_as!( sqlx::query_as!(
Boat, 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 FROM boat
WHERE owner is null or owner = ? WHERE owner is null or owner = ?
ORDER BY amount_seats DESC ORDER BY amount_seats DESC
@ -258,7 +263,7 @@ ORDER BY amount_seats DESC
sqlx::query_as!( sqlx::query_as!(
Boat, 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 FROM boat
WHERE owner = ? OR (owner is null and amount_seats = 1) WHERE owner = ? OR (owner is null and amount_seats = 1)
ORDER BY amount_seats DESC ORDER BY amount_seats DESC
@ -276,7 +281,7 @@ ORDER BY amount_seats DESC
.unwrap(); .unwrap();
let boats_in_ottensheim = sqlx::query_as!( let boats_in_ottensheim = sqlx::query_as!(
Boat, 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 FROM boat
WHERE owner is null and location_id = ? WHERE owner is null and location_id = ?
ORDER BY amount_seats DESC ORDER BY amount_seats DESC
@ -295,7 +300,7 @@ ORDER BY amount_seats DESC
let boats = sqlx::query_as!( let boats = sqlx::query_as!(
Boat, 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 FROM boat
INNER JOIN location ON boat.location_id = location.id INNER JOIN location ON boat.location_id = location.id
WHERE location.name=? WHERE location.name=?
@ -312,26 +317,7 @@ ORDER BY amount_seats DESC
pub async fn create(db: &SqlitePool, boat: BoatToAdd<'_>) -> Result<(), String> { pub async fn create(db: &SqlitePool, boat: BoatToAdd<'_>) -> Result<(), String> {
sqlx::query!( 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,
boat.boatbuilder,
boat.default_shipmaster_only_steering,
boat.default_destination,
boat.skull,
boat.external,
boat.location_id,
boat.owner
)
.execute(db)
.await.map_err(|e| e.to_string())?;
Ok(())
}
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=?",
boat.name, boat.name,
boat.amount_seats, boat.amount_seats,
boat.year_built, boat.year_built,
@ -342,6 +328,27 @@ ORDER BY amount_seats DESC
boat.external, boat.external,
boat.location_id, boat.location_id,
boat.owner, boat.owner,
boat.convert_handoperated_possible
)
.execute(db)
.await.map_err(|e| e.to_string())?;
Ok(())
}
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=?, convert_handoperated_possible=? WHERE id=?",
boat.name,
boat.amount_seats,
boat.year_built,
boat.boatbuilder,
boat.default_shipmaster_only_steering,
boat.default_destination,
boat.skull,
boat.external,
boat.location_id,
boat.owner,
boat.convert_handoperated_possible,
self.id self.id
) )
.execute(db) .execute(db)

View File

@ -1,3 +1,6 @@
ALTER TABLE boat ADD COLUMN convert_handoperated_possible BOOLEAN DEFAULT false NOT NULL;
-- test user -- test user
INSERT INTO user(name) VALUES('Marie'); 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')); INSERT INTO "user_role" (user_id, role_id) VALUES((SELECT id from user where name = 'Marie'),(SELECT id FROM role where name = 'Donau Linz'));

View File

@ -24,6 +24,7 @@
{{ macros::input(label='Default destination', name='default_destination', type='text') }} {{ macros::input(label='Default destination', name='default_destination', type='text') }}
<div> <div>
{{ macros::checkbox(label="handgesteuert", name="default_shipmaster_only_steering") }} {{ 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="Skull", name="skull", checked=true) }}
{{ macros::checkbox(label="Externes Boot (anderer Verein)", name="external") }} {{ macros::checkbox(label="Externes Boot (anderer Verein)", name="external") }}
</div> </div>
@ -66,6 +67,7 @@
{{ macros::input(label='Baujahr', name='year_built', type='number', min=1950, value=boat.year_built) }} {{ 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::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='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::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='Skull', name='skull', id=uuid , checked=boat.skull) }}
{{ macros::checkbox(label='Externes Boot', name='external', id=uuid , checked=boat.external) }} {{ macros::checkbox(label='Externes Boot', name='external', id=uuid , checked=boat.external) }}

View File

@ -7,12 +7,12 @@
<details> <details>
<summary class="font-bold cursor-pointer text-primary-900 dark:text-white border-t p-3 hover:bg-gray-100 dark:hover:bg-primary-950"> <summary class="font-bold cursor-pointer text-primary-900 dark:text-white border-t p-3 hover:bg-gray-100 dark:hover:bg-primary-950">
<span> <span>
{% if grouped_boats[0].amount_seats < 9 or grouped_boats[0].amount_seats == 24 %} {% if grouped_boats[0].external %}
{{ amount_seats }}x Vereinsfremde Boote
{% elif grouped_boats[0].amount_seats == 9 %} {% elif grouped_boats[0].default_shipmaster_only_steering %}
{{ grouped_boats[0].amount_seats - 1 }}+ {{ grouped_boats[0].amount_seats - 1 }}+
{% else %} {% else %}
Vereinsfremde Boote {{ amount_seats }}x
{% endif %} {% endif %}
</span> </span>
<small class="text-gray-500 dark:text-gray-100">({{ grouped_boats | length }})</small> <small class="text-gray-500 dark:text-gray-100">({{ grouped_boats | length }})</small>

View File

@ -159,7 +159,7 @@
{% if required %}required="required"{% endif %}> {% if required %}required="required"{% endif %}>
{% if default %}<option selected value>{{ default }}</option>{% endif %} {% if default %}<option selected value>{{ default }}</option>{% endif %}
{% for d in data %} {% for d in data %}
<option value="{{ d.id }}" {% if d.id == selected_id %}selected{% endif %} {% if extras != '' %} {% for extra in extras %} {% if extra != 'on_water' and d[extra] %} data- {{ extra }}={{ d[extra] }} {% else %} {% if d[extra] %}disabled{% endif %} {% endif %} {% endfor %} {% endif %} {% if show_seats %} data-custom-properties='{"amount_seats": {{ d["amount_seats"] }}, "owner": "{{ d["owner"] }}", "default_destination": "{{ d["default_destination"] }}", "boat_in_ottensheim": {{ d["location_id"] == 2 }}, "boat_reserved_today": {{ d["reserved_today"] }}}' {% endif %}> <option value="{{ d.id }}" {% if d.id == selected_id %}selected{% endif %} {% if extras != '' %} {% for extra in extras %} {% if extra != 'on_water' and d[extra] %} data- {{ extra }}={{ d[extra] }} {% else %} {% if d[extra] %}disabled{% endif %} {% endif %} {% endfor %} {% endif %} {% if show_seats %} data-custom-properties='{"amount_seats": {{ d["amount_seats"] }}, "owner": "{{ d["owner"] }}", "default_destination": "{{ d["default_destination"] }}", "boat_in_ottensheim": {{ d["location_id"] == 2 }}, "boat_reserved_today": {{ d["reserved_today"] }}, "convert_handoperated_possible": {{ d["convert_handoperated_possible"] }}, "default_handoperated": {{ d["default_shipmaster_only_steering"] }}}' {% endif %}>
{% for displa in display -%} {% for displa in display -%}
{%- if d[displa] -%} {%- if d[displa] -%}
{{- d[displa] -}} {{- d[displa] -}}