From a1dc92defd879a3251ce8abcca43f9e6bba88304 Mon Sep 17 00:00:00 2001 From: PhilippHofer Date: Tue, 5 Sep 2023 20:48:02 +0000 Subject: [PATCH 001/137] Refactor code --- frontend/logbook.ts | 33 ++ frontend/main.ts | 40 ++ frontend/vite.config.js | 1 + src/model/logbook.rs | 1 + src/tera/log.rs | 5 +- templates/forms/event.html.tera | 2 +- templates/forms/trip.html.tera | 2 +- templates/includes/forms/boat.html.tera | 8 +- templates/includes/forms/log.html.tera | 499 +++++++++++------------- templates/includes/macros.html.tera | 4 +- templates/index.html.tera | 2 +- templates/kiosk.html.tera | 2 + templates/log.html.tera | 57 +-- 13 files changed, 346 insertions(+), 310 deletions(-) create mode 100644 frontend/logbook.ts diff --git a/frontend/logbook.ts b/frontend/logbook.ts new file mode 100644 index 0000000..26c5a18 --- /dev/null +++ b/frontend/logbook.ts @@ -0,0 +1,33 @@ +/*document.addEventListener('DOMContentLoaded', function() { + setDistance('.set-distance-js'); +}); + +function setDistance(selector: string) { + const fields = document.querySelectorAll(selector); + if(fields) { + Array.prototype.forEach.call(fields, (field: HTMLInputElement) => { + if(field.dataset.relation){ + const relatedField = document.getElementById(field.dataset.relation); + + if(relatedField) { + field.addEventListener('input', (e) => { + e.preventDefault(); + + const dataList = document.getElementById('destinations'); + if(dataList) { + var option = Array.prototype.find.call(dataList.options, function(option) { + return option.value === field.value; + }); + + // Get distance + const distance = option.getAttribute('distance'); + if(distance) relatedField.value = distance; + } + }); + } + } + }); + } +} +*/ +export {} diff --git a/frontend/main.ts b/frontend/main.ts index 95adeee..d78c41e 100644 --- a/frontend/main.ts +++ b/frontend/main.ts @@ -202,9 +202,22 @@ function initTripSidebar(triggerElement: HTMLElement) { } }); + const prefixedContent = >bodyElement.querySelectorAll('.change-id-js'); + Array.prototype.forEach.call(prefixedContent, (content: HTMLElement) => { + if(content) { + content.id += 'js'; + + if(content.dataset.relation){ + content.dataset.relation += 'js'; + } + } + }); + if(bodyContainerElement) { bodyContainerElement.innerHTML = ''; bodyContainerElement.append(bodyElement); + + addRelationMagic(bodyElement); } if(triggerElement.dataset.day) { let hiddenElement = bodyElement.querySelector('.day-js'); @@ -220,6 +233,33 @@ function initTripSidebar(triggerElement: HTMLElement) { } } +function addRelationMagic(bodyElement: HTMLElement) { + const fields = bodyElement.querySelectorAll('.set-distance-js'); + if(fields) { + Array.prototype.forEach.call(fields, (field: HTMLInputElement) => { + if(field.dataset.relation){ + const relatedField = bodyElement.querySelector('#' + field.dataset.relation); + + if(relatedField) { + field.addEventListener('input', (e) => { + e.preventDefault(); + const dataList = document.getElementById('destinations'); + if(dataList) { + var option = Array.prototype.find.call(dataList.options, function(option) { + return option.value === field.value; + }); + + // Get distance + const distance = option.getAttribute('distance'); + if(distance) relatedField.value = distance; + } + }); + } + } + }); + } +} + function replaceStrings() { const weekdays = document.querySelectorAll('.weekday-js'); Array.prototype.forEach.call(weekdays, (weekday: HTMLElement) => { diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 1c99ca6..8ccb8a1 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -17,6 +17,7 @@ export default defineConfig({ rollupOptions: { input: { main: './main.ts', + logbook: './logbook.ts', // Example for more entry points // test: './src/test.ts', }, diff --git a/src/model/logbook.rs b/src/model/logbook.rs index 1ea7cbc..10b814c 100644 --- a/src/model/logbook.rs +++ b/src/model/logbook.rs @@ -204,6 +204,7 @@ ORDER BY departure DESC let mut tx = db.begin().await.unwrap(); let departure = NaiveDateTime::parse_from_str(&log.departure, "%Y-%m-%dT%H:%M").unwrap(); + println!("@@@@@@ {:?}", log.arrival); let arrival = log .arrival .map(|a| NaiveDateTime::parse_from_str(&a, "%Y-%m-%dT%H:%M").unwrap()); diff --git a/src/tera/log.rs b/src/tera/log.rs index 9d65dd7..7eb3c2f 100644 --- a/src/tera/log.rs +++ b/src/tera/log.rs @@ -341,8 +341,9 @@ mod test { let response = req.dispatch().await; let text = response.into_string().await.unwrap(); + println!("{text:?}"); assert!(text.contains("Logbuch")); - assert!(text.contains("Bootsname: Joe")); + assert!(text.contains("Joe")); } #[sqlx::test] @@ -361,7 +362,7 @@ mod test { let text = response.into_string().await.unwrap(); assert!(text.contains("Logbuch")); - assert!(text.contains("Bootsname: Joe")); + assert!(text.contains("Joe")); } #[sqlx::test] diff --git a/templates/forms/event.html.tera b/templates/forms/event.html.tera index 4f2e6c2..1144eab 100644 --- a/templates/forms/event.html.tera +++ b/templates/forms/event.html.tera @@ -10,7 +10,7 @@ {{ macros::checkbox(label='Gäste erlauben', name='tripdetails.allow_guests') }} {{ macros::checkbox(label='Immer anzeigen', name='tripdetails.always_show') }} {{ macros::input(label='Anmerkungen', name='tripdetails.notes', type='input') }} - {{ macros::select(data=trip_types, select_name='tripdetails.trip_type', default='Reguläre Ausfahrt') }} + {{ macros::select(data=trip_types, name='tripdetails.trip_type', default='Reguläre Ausfahrt') }} diff --git a/templates/forms/trip.html.tera b/templates/forms/trip.html.tera index d38d9ab..a8d1405 100644 --- a/templates/forms/trip.html.tera +++ b/templates/forms/trip.html.tera @@ -8,7 +8,7 @@ {{ macros::checkbox(label='Gäste erlauben', name='allow_guests') }} {{ macros::checkbox(label='Immer anzeigen', name='always_show') }} {{ macros::input(label='Anmerkungen', name='notes', type='input') }} - {{ macros::select(data=trip_types, select_name='trip_type', default='Reguläre Ausfahrt') }} + {{ macros::select(data=trip_types, name='trip_type', default='Reguläre Ausfahrt') }} diff --git a/templates/includes/forms/boat.html.tera b/templates/includes/forms/boat.html.tera index f29e633..4fee26b 100644 --- a/templates/includes/forms/boat.html.tera +++ b/templates/includes/forms/boat.html.tera @@ -8,8 +8,8 @@ {{ macros::input(label="Anzahl Sitze", name="amount_seats", type="number", required=true, min=1) }} {{ macros::input(label="Baujahr", name="year_built", type="number", min=1950, max=2050) }} {{ macros::input(label="Bootsbauer", name="boatbuilder", type="text") }} - {{ macros::select(data=locations, label='location', select_name='location_id', selected_id=1) }} - {{ macros::select(data=users, label='users', select_name='owner', default="Vereinsboot") }} + {{ macros::select(data=locations, label='location', name='location_id', selected_id=1) }} + {{ macros::select(data=users, label='users', name='owner', default="Vereinsboot") }} {{ macros::checkbox(label="Steuerperson steuert nur", name="default_shipmaster_only_steering")}} {{ macros::checkbox(label="Skull", name="skull", checked=true)}} {{ macros::checkbox(label="Externes Boot (anderer Verein)", name="external")}} @@ -29,8 +29,8 @@
{{ macros::input(label='Name', name='name', type='text', value=boat.name) }} {{ macros::input(label='Amount Seats', name='amount_seats', type='number', min=0, value=boat.amount_seats) }} - {{ macros::select(data=locations, label='location', select_name='location_id', selected_id=boat.location_id) }} - {{ macros::select(data=users, label='users', select_name='owner', selected_id=boat.owner, default="Vereinsboot") }} + {{ macros::select(data=locations, label='location', name='location_id', selected_id=boat.location_id) }} + {{ macros::select(data=users, label='users', name='owner', selected_id=boat.owner, default="Vereinsboot") }} {{ 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='default_shipmaster_only_steering', name='default_shipmaster_only_steering', id=uuid , checked=boat.default_shipmaster_only_steering) }} diff --git a/templates/includes/forms/log.html.tera b/templates/includes/forms/log.html.tera index 74d5706..5de655c 100644 --- a/templates/includes/forms/log.html.tera +++ b/templates/includes/forms/log.html.tera @@ -1,297 +1,252 @@ +{# Shows a fancy, optional lists of boats. They are grouped by boat category. + + Inputs: boats + Parameters: only_ones: if set, only 1x boats are shown + #} +{% macro show_boats(only_ones) %} + {% if only_ones %} + {% set_global boats = boats | filter(attribute="amount_seats", value=1) %} + {% endif %} + {% for amount_seats, grouped_boats in boats | group_by(attribute="amount_seats") %} +
+
+ {{ amount_seats }}x +
+ {% for boat in grouped_boats %} +
+ + {{ boat.name }} + {% if boat.owner %} + (privat) + {% endif %} + +
+ {% endfor %} +
+ {% endfor %} +{% endmacro show_boats %} + +{# Shows the form for creating a new logbook entry. #} {% macro new(only_ones, allow_any_shipmaster, shipmaster) %} -
- {{ log::boat_select(only_ones=only_ones) }} + + {{ log::boat_select(only_ones=only_ones) }} - {% if allow_any_shipmaster %} - - {% else %} - - {% endif %} - {% if not only_ones %} - {{ macros::checkbox(label='handgesteuert', name='shipmaster_only_steering') }} - {% endif %} - - {% if not only_ones %} - {{ log::rower_select(id="newrower", selected=[], class="col-span-2") }} - {% endif %} + {% if allow_any_shipmaster %} + + {% else %} + + {% endif %} + {% if not only_ones %} + {{ macros::checkbox(label='handgesteuert', name='shipmaster_only_steering') }} + {% endif %} -
+ {% if not only_ones %} + {{ log::rower_select(id="newrower", selected=[], class="col-span-2") }} + {% endif %} - {{ macros::input(label='Abfahrtszeit', name='departure', type='datetime-local', required=true) }} - {{ macros::input(label='Ankunftszeit', name='arrival', type='datetime-local') }} +
-
- - - - {% for distance in distances %} - -
+
+ + + + {% for distance in distances %} + +
+ {{ macros::input(label='Abfahrtszeit', name='departure', type='datetime-local', required=true) }} + {{ macros::input(label='Ankunftszeit', name='arrival', type='datetime-local') }} -
- {{ macros::input(label="Distanz", name="distance_in_km", type="number", min=1) }} - km -
- {{ macros::input(label="Kommentar", name="comments", type="text", wrapper_class="col-span-2") }} +
+ + + + {% for distance in distances %} + +
-
- - {{ macros::select(data=logtypes, select_name='logtype', default="Normal") }} -
- - - -
- - - +
+ + {{ macros::select(data=logtypes, name='logtype', default="Normal") }} +
+ + {% endmacro new %} -{% macro show_boats(only_ones) %} - {% if only_ones %} - {% set_global boats = boats | filter(attribute="amount_seats", value=1) %} - {% endif %} - {% for amount_seats, grouped_boats in boats | group_by(attribute="amount_seats") %} -
-
- {{ amount_seats }}x -
- {% for boat in grouped_boats %} -
- - {{ boat.name }} -
- {% endfor %} -
- {% endfor %} - - -{% endmacro boats %} {% macro boat_select(only_ones) %} - {% if not only_ones %} - {{ macros::select(data=boats, select_name='boat_id', display=["name", " (","amount_seats", " x)"], extras=["default_shipmaster_only_steering", "amount_seats"], class="col-span-2") }} - {% else %} - {% set ones = boats | filter(attribute="amount_seats", value=1) %} - {{ macros::select(data=ones, select_name='boat_id', display=["name", " (","amount_seats", " x)"], extras=["default_shipmaster_only_steering", "amount_seats"], class="col-span-2") }} - {% endif %} - + {% if not only_ones %} + {{ macros::select(data=boats, name='boat_id', display=["name", " (","amount_seats", " x)"], extras=["default_shipmaster_only_steering", "amount_seats"], class="col-span-2") }} + {% else %} + {% set ones = boats | filter(attribute="amount_seats", value=1) %} + {{ macros::select(data=ones, name='boat_id', display=["name", " (","amount_seats", " x)"], extras=["default_shipmaster_only_steering", "amount_seats"], class="col-span-2") }} + {% endif %} {% endmacro boat_select %} +{% macro rower_select(id, selected, amount_seats='', class='') %} +
+ +
+
+ + {{amount_seats}} + Ruderer auszuwählen +
+{% endmacro rower_select %} + {% macro show(log, state, allowed_to_close=false, only_ones) %} -
-
-
-
-
- - {{ log.departure_timestamp | date(format="%H:%M") }} Uhr - - ({{ log.boat.name }}) -
- - ({{ log.boat.name }})" data-body="#log{{ log.id }}" class="inline-block link-primary mr-3"> - Details - -
- -
- {% if allowed_to_close and state == "on_water" %} - ({{ log.boat.name }})" data-body="#close{{ log.id }}" class="btn btn-dark w-full mt-3"> - Beenden - - {% endif %} -
+
+
+
+
+
+ + {{ log.departure_timestamp | date(format="%H:%M") }} + Uhr + + ({{ log.boat.name }}) +
- -
-
-
-
-{% endmacro show %} +
+ {% if allowed_to_close and state == "on_water" %} + ({{ log.boat.name }})" data-body="#close{{ log.id }}" class="btn btn-dark w-full mt-3"> + Beenden + + {% endif %} +
+ + +
+
+
+{% endmacro show %} {% macro show_old(log, state, allowed_to_close=false, only_ones) %} - Bootsname: {{ log.boat.name }}
- Schiffsführer: {{ log.shipmaster_user.name }}
- {% if log.shipmaster_only_steering %} - Schiffsführer steuert nur - {% endif %} - Weggefahren: {{ log.departure }}
- {% if state == "completed" %} - Angekommen: {{ log.arrival}}
- {% endif %} - {% set amount_rowers = log.rowers | length %} - {% set amount_guests = log.boat.amount_seats - amount_rowers -1 %} - {% if allowed_to_close and state == "on_water" %} - {{ log::home(log=log, only_ones=only_ones) }} - {% else %} - Ziel: {{ log.destination }}
- {% if state == "completed" %} - Km: {{ log.distance_in_km }}
- {% endif %} - {% if log.comments %} - Kommentare: {{ log.comments }}
- {% endif %} - {% if log.logtype %} - Logtype: {{ log.logtype }}
- {% endif %} - {% if amount_guests > 0 or log.rowers | length > 0 %} - Ruderer: - {% endif %} - {% if amount_guests > 0 %} - {{ amount_guests }} Gäste (ohne Account) - {% endif %} - {% for rower in log.rowers %} - {{ rower.name }} - {% endfor %} - {% endif %} -{% endmacro show_old %} + Bootsname: + {{ log.boat.name }}
+ Schiffsführer: + {{ log.shipmaster_user.name }}
+ {% if log.shipmaster_only_steering %} + Schiffsführer steuert nur + {% endif %} + Weggefahren: + {{ log.departure }}
+ {% if state == "completed" %} + Angekommen: + {{ log.arrival}}
+ {% endif %} + {% set amount_rowers = log.rowers | length %} + {% set amount_guests = log.boat.amount_seats - amount_rowers -1 %} + {% if allowed_to_close and state == "on_water" %} + {{ log::home(log=log, only_ones=only_ones) }} + {% else %} + Ziel: + {{ log.destination }}
+ {% if state == "completed" %} + Km: + {{ log.distance_in_km }}
+ {% endif %} + {% if log.comments %} + Kommentare: + {{ log.comments }}
+ {% endif %} + {% if log.logtype %} + Logtype: + {{ log.logtype }}
+ {% endif %} + {% if amount_guests > 0 or log.rowers | length > 0 %} + Ruderer: + {% endif %} + {% if amount_guests > 0 %} + {{ amount_guests }} + Gäste (ohne Account) + {% endif %} + {% for rower in log.rowers %} + {{ rower.name }} + {% endfor %} + {% endif %} +{% endmacro show_old %} {% macro home(log, only_ones) %} -
- {% if not only_ones %} - - {% endif %} -
- - -
+ + {% if not only_ones %} + {{ log::rower_select(id="rowers"~log.id, selected=log.rowers, amount_seats=log.boat.amount_seats) }} + {% endif %} +
+ -
- {{ macros::input(label="Distanz", name="distance_in_km", id="distance_in_km_home", type="number", min=0, value=log.distance_in_km, required=true) }} - km -
- - {{ macros::input(label="Kommentar", name="comments", type="text", value=log.comments) }} + +
-
- - {{ macros::select(data=logtypes, select_name='logtype', default="Normal", selected_id=log.logtype) }} -
- -
-{% endmacro home %} +
+ {{ macros::input(label="Distanz", name="distance_in_km", id="distance_in_km" ~ log.id , type="number", min=0, value=log.distance_in_km, required=true, class="rounded-md change-id-js") }} + km +
+ {{ macros::input(label="Kommentar", name="comments", id="comments" ~ log.id, type="text", value=log.comments, class="rounded-md change-id-js") }} -{% macro rower_select(id, selected, amount_seats='', class='') %} -
- - -
- -
- /{{amount_seats}} Ruderer ausgewählt -
-{% endmacro rower_select %} +
+ + {{ macros::select(data=logtypes, name="logtype", id="logtype" ~ log.id, default="Normal", selected_id=log.logtype, class="rounded-md change-id-js") }} +
+ + +{% endmacro home %} diff --git a/templates/includes/macros.html.tera b/templates/includes/macros.html.tera index de64ad4..585be2c 100644 --- a/templates/includes/macros.html.tera +++ b/templates/includes/macros.html.tera @@ -74,11 +74,11 @@ {% endmacro checkbox %} -{% macro select(data, select_name='trip_type', default='', selected_id='', display='', extras='', class='') %} +{% macro select(data, name='trip_type', default='', id='', selected_id='', display='', extras='', class='') %} {% if display == '' %} {% set display = ["name"] %} {% endif %} - {% if default %} {% endif %} diff --git a/templates/index.html.tera b/templates/index.html.tera index 5a5bd2c..4645ceb 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -239,7 +239,7 @@ {{ macros::input(label='Anmerkungen', name='notes', type='input', value=trip.notes) }} {{ macros::checkbox(label='Immer anzeigen', name='always_show', id=trip.id,checked=trip.always_show) }} {{ macros::checkbox(label='Gesperrt', name='is_locked', id=trip.id,checked=trip.is_locked) }} - {{ macros::select(select_name='trip_type', data=trip_types, default='Reguläre Ausfahrt', selected_id=trip.trip_type_id) }} + {{ macros::select(name='trip_type', data=trip_types, default='Reguläre Ausfahrt', selected_id=trip.trip_type_id) }} diff --git a/templates/kiosk.html.tera b/templates/kiosk.html.tera index 96f3f7a..8150a6d 100644 --- a/templates/kiosk.html.tera +++ b/templates/kiosk.html.tera @@ -39,4 +39,6 @@
{% include "dynamics/sidebar" %} + + {% endblock content%} diff --git a/templates/log.html.tera b/templates/log.html.tera index 045d169..90e7d3f 100644 --- a/templates/log.html.tera +++ b/templates/log.html.tera @@ -11,33 +11,36 @@

Logbuch

-
- -
-

Neue Ausfahrt

-
- {{ log::new(only_ones=loggedin_user.is_cox==false, allow_any_shipmaster=loggedin_user.is_cox, shipmaster=loggedin_user.id) }} -
-
-
-

Am Wasser

+
+ -
-
+
+ {{ log::show_boats(only_ones=false) }} +
+
+
+

Neue Ausfahrt

+
+ {{ log::new(only_ones=loggedin_user.is_cox==false, allow_any_shipmaster=loggedin_user.is_cox, shipmaster=loggedin_user.id) }} +
+
+
+

Am Wasser

-{% include "dynamics/sidebar" %} + {% for log in on_water %} + {% if log.shipmaster == loggedin_user.id %} + {{ log::show(log=log, state="on_water", allowed_to_close=true, only_ones=loggedin_user.is_cox==false) }} + {% else %} + {{ log::show(log=log, state="on_water", only_ones=true) }} + {% endif %} + {% endfor %} +
+
+ + + {% include "dynamics/sidebar" %} + + + {% endblock content%} From 6e1bc101bf79e70064c8b9116ee967a4eb6011b4 Mon Sep 17 00:00:00 2001 From: philipp Date: Wed, 6 Sep 2023 14:39:36 +0200 Subject: [PATCH 002/137] clean code with clippy --- Cargo.lock | 8 ++++---- src/model/boat.rs | 2 +- src/model/boatdamage.rs | 2 +- src/model/logbook.rs | 10 ++++------ src/model/rower.rs | 2 +- src/model/tripdetails.rs | 4 ++-- src/tera/cox.rs | 6 +++--- 7 files changed, 16 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0bc3a5f..fd4dd09 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -278,9 +278,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.28" +version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ed24df0632f708f5f6d8082675bef2596f7084dee3dd55f632290bf35bfe0f" +checksum = "d87d9d13be47a5b7c3907137f1290b0459a7f80efb26be8c52afb11963bccb02" dependencies = [ "android-tzdata", "iana-time-zone", @@ -2702,9 +2702,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "walkdir" -version = "2.3.3" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" dependencies = [ "same-file", "winapi-util", diff --git a/src/model/boat.rs b/src/model/boat.rs index ef6755d..ddd02fb 100644 --- a/src/model/boat.rs +++ b/src/model/boat.rs @@ -109,7 +109,7 @@ impl Boat { damage, on_water: boat.on_water(db).await, boat, - }) + }); } res } diff --git a/src/model/boatdamage.rs b/src/model/boatdamage.rs index 3e60085..7dbabfb 100644 --- a/src/model/boatdamage.rs +++ b/src/model/boatdamage.rs @@ -101,7 +101,7 @@ ORDER BY created_at DESC user_fixed, user_verified, boat_damage, - }) + }); } res } diff --git a/src/model/logbook.rs b/src/model/logbook.rs index 10b814c..e38e1b8 100644 --- a/src/model/logbook.rs +++ b/src/model/logbook.rs @@ -226,9 +226,7 @@ ORDER BY departure DESC for rower in &log.rower { Rower::create(&mut tx, inserted_row.id, *rower) .await - .map_err(|e| { - return LogbookCreateError::RowerCreateError(*rower, e.to_string()); - })?; + .map_err(|e| LogbookCreateError::RowerCreateError(*rower, e.to_string()))?; } tx.commit().await.unwrap(); @@ -300,9 +298,9 @@ ORDER BY departure DESC self.remove_rowers(&mut tx).await; for rower in &log.rower { - Rower::create(&mut tx, self.id, *rower).await.map_err(|e| { - return LogbookUpdateError::RowerCreateError(*rower, e.to_string()); - })?; + Rower::create(&mut tx, self.id, *rower) + .await + .map_err(|e| LogbookUpdateError::RowerCreateError(*rower, e.to_string()))?; } tx.commit().await.unwrap(); diff --git a/src/model/rower.rs b/src/model/rower.rs index 99065ef..f6a40a8 100644 --- a/src/model/rower.rs +++ b/src/model/rower.rs @@ -39,7 +39,7 @@ WHERE id in (SELECT rower_id FROM rower WHERE logbook_id=?) ) .execute(db) .await - .map_err(|e| return e.to_string())?; + .map_err(|e| e.to_string())?; Ok(()) } diff --git a/src/model/tripdetails.rs b/src/model/tripdetails.rs index b913810..71a427c 100644 --- a/src/model/tripdetails.rs +++ b/src/model/tripdetails.rs @@ -120,9 +120,9 @@ ORDER BY day;", pub(crate) async fn user_allowed_to_change(&self, db: &SqlitePool, user: &User) -> bool { if self.belongs_to_event(db).await { - return user.is_admin; + user.is_admin } else { - return self.user_is_cox(db, user).await != CoxAtTrip::No; + self.user_is_cox(db, user).await != CoxAtTrip::No } } diff --git a/src/tera/cox.rs b/src/tera/cox.rs index 79bc5aa..a62e2b7 100644 --- a/src/tera/cox.rs +++ b/src/tera/cox.rs @@ -145,13 +145,13 @@ async fn remove(db: &State, planned_event_id: i64, cox: CoxUser) -> ) .await; - return Flash::success(Redirect::to("/"), "Erfolgreich abgemeldet!"); + Flash::success(Redirect::to("/"), "Erfolgreich abgemeldet!") } Err(TripHelpDeleteError::DetailsLocked) => { - return Flash::error(Redirect::to("/"), "Boot bereits eingeteilt"); + Flash::error(Redirect::to("/"), "Boot bereits eingeteilt") } Err(TripHelpDeleteError::CoxNotHelping) => { - return Flash::error(Redirect::to("/"), "Steuermann hilft nicht aus...") + Flash::error(Redirect::to("/"), "Steuermann hilft nicht aus...") } } } else { From 528477e728a0e633299332909953e7bef7f519f3 Mon Sep 17 00:00:00 2001 From: philipp Date: Fri, 22 Sep 2023 08:00:08 +0200 Subject: [PATCH 003/137] update deps --- Cargo.lock | 154 +++++++++++++++++++++++------------------------------ 1 file changed, 68 insertions(+), 86 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fd4dd09..971777e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,9 +40,9 @@ dependencies = [ [[package]] name = "aes-gcm" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "209b47e8954a928e1d72e86eca7000ebb6655fe1436d33eefc2201cad027e237" +checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" dependencies = [ "aead", "aes", @@ -76,9 +76,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.0.5" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783" +checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab" dependencies = [ "memchr", ] @@ -135,7 +135,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.37", ] [[package]] @@ -146,7 +146,7 @@ checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.37", ] [[package]] @@ -187,9 +187,9 @@ dependencies = [ [[package]] name = "base64" -version = "0.21.3" +version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53" +checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" [[package]] name = "base64ct" @@ -245,9 +245,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "byteorder" @@ -257,9 +257,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "cc" @@ -278,9 +278,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.29" +version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d87d9d13be47a5b7c3907137f1290b0459a7f80efb26be8c52afb11963bccb02" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ "android-tzdata", "iana-time-zone", @@ -288,7 +288,6 @@ dependencies = [ "num-traits", "pure-rust-locales", "serde", - "time 0.1.45", "wasm-bindgen", "windows-targets 0.48.5", ] @@ -338,7 +337,7 @@ dependencies = [ "rand", "sha2", "subtle", - "time 0.3.28", + "time", "version_check", ] @@ -463,7 +462,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.31", + "syn 2.0.37", ] [[package]] @@ -736,7 +735,7 @@ checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", ] [[package]] @@ -840,9 +839,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" [[package]] name = "hex" @@ -1125,9 +1124,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" [[package]] name = "libm" @@ -1148,9 +1147,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" +checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128" [[package]] name = "lock_api" @@ -1227,7 +1226,7 @@ checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" dependencies = [ "libc", "log", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "windows-sys 0.48.0", ] @@ -1438,7 +1437,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.31", + "syn 2.0.37", ] [[package]] @@ -1478,7 +1477,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.37", ] [[package]] @@ -1547,7 +1546,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.37", ] [[package]] @@ -1588,9 +1587,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" dependencies = [ "unicode-ident", ] @@ -1603,16 +1602,16 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.37", "version_check", "yansi 1.0.0-rc.1", ] [[package]] name = "pure-rust-locales" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b856d7d028ebb0011d78eded5bc9185932412f36c12c67930f222d6b407526b" +checksum = "ed02a829e62dc2715ceb8afb4f80e298148e1345749ceb369540fe0eb3368432" [[package]] name = "quote" @@ -1688,7 +1687,7 @@ checksum = "7f7473c2cfcf90008193dd0e3e16599455cb601a9fce322b5bb55de799664925" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.37", ] [[package]] @@ -1779,7 +1778,7 @@ dependencies = [ "serde", "state", "tempfile", - "time 0.3.28", + "time", "tokio", "tokio-stream", "tokio-util", @@ -1800,7 +1799,7 @@ dependencies = [ "proc-macro2", "quote", "rocket_http", - "syn 2.0.31", + "syn 2.0.37", "unicode-xid", ] @@ -1839,7 +1838,7 @@ dependencies = [ "smallvec", "stable-pattern", "state", - "time 0.3.28", + "time", "tokio", "uncased", ] @@ -1869,9 +1868,9 @@ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustix" -version = "0.38.11" +version = "0.38.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0c3dde1fc030af041adc40e79c0e7fbcf431dd24870053d187d7c66e4b87453" +checksum = "747c788e9ce8e92b12cd485c49ddf90723550b654b32508f979b71a7b1ecda4f" dependencies = [ "bitflags 2.4.0", "errno", @@ -1961,14 +1960,14 @@ checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.37", ] [[package]] name = "serde_json" -version = "1.0.105" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" +checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ "itoa", "ryu", @@ -2039,9 +2038,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "socket2" @@ -2055,9 +2054,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" +checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" dependencies = [ "libc", "windows-sys 0.48.0", @@ -2141,7 +2140,7 @@ dependencies = [ "sqlx-rt", "stringprep", "thiserror", - "time 0.3.28", + "time", "tokio-stream", "url", "webpki-roots", @@ -2225,9 +2224,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.31" +version = "2.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "718fa2415bcb8d8bd775917a1bf12a7931b6dfa890753378538118181e0cb398" +checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" dependencies = [ "proc-macro2", "quote", @@ -2271,9 +2270,9 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" dependencies = [ "winapi-util", ] @@ -2295,7 +2294,7 @@ checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.37", ] [[package]] @@ -2308,17 +2307,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "time" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", -] - [[package]] name = "time" version = "0.3.28" @@ -2375,7 +2363,7 @@ dependencies = [ "num_cpus", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.3", + "socket2 0.5.4", "tokio-macros", "windows-sys 0.48.0", ] @@ -2388,7 +2376,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.37", ] [[package]] @@ -2415,9 +2403,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" +checksum = "1d68074620f57a0b21594d9735eb2e98ab38b17f80d3fcb189fca266771ca60d" dependencies = [ "bytes", "futures-core", @@ -2429,9 +2417,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.7.6" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" +checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" dependencies = [ "serde", "serde_spanned", @@ -2450,9 +2438,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.19.14" +version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ "indexmap 2.0.0", "serde", @@ -2487,7 +2475,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.37", ] [[package]] @@ -2537,9 +2525,9 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "ubyte" @@ -2624,9 +2612,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" @@ -2719,12 +2707,6 @@ dependencies = [ "try-lock", ] -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -2752,7 +2734,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.37", "wasm-bindgen-shared", ] @@ -2774,7 +2756,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.37", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2832,9 +2814,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ "winapi", ] From 9bb2996a4d31dcb44ade1b22b827388a52d0bf09 Mon Sep 17 00:00:00 2001 From: philipp Date: Sat, 23 Sep 2023 17:40:17 +0200 Subject: [PATCH 004/137] make admin cox by default --- seeds.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seeds.sql b/seeds.sql index c376a44..5fa2847 100644 --- a/seeds.sql +++ b/seeds.sql @@ -1,4 +1,4 @@ -INSERT INTO "user" (name, is_cox, is_admin, is_guest, pw) VALUES('admin', false, true, false, '$argon2id$v=19$m=19456,t=2,p=1$dS/X5/sPEKTj4Rzs/CuvzQ$4P4NCw4Ukhv80/eQYTsarHhnw61JuL1KMx/L9dm82YM'); +INSERT INTO "user" (name, is_cox, is_admin, is_guest, pw) VALUES('admin', true, true, false, '$argon2id$v=19$m=19456,t=2,p=1$dS/X5/sPEKTj4Rzs/CuvzQ$4P4NCw4Ukhv80/eQYTsarHhnw61JuL1KMx/L9dm82YM'); INSERT INTO "user" (name, is_cox, is_admin, is_guest, pw) VALUES('rower', false, false, false, '$argon2id$v=19$m=19456,t=2,p=1$dS/X5/sPEKTj4Rzs/CuvzQ$jWKzDmI0jqT2dqINFt6/1NjVF4Dx15n07PL1ZMBmFsY'); INSERT INTO "user" (name, is_cox, is_admin, is_guest, pw) VALUES('guest', false, false, true, '$argon2id$v=19$m=19456,t=2,p=1$dS/X5/sPEKTj4Rzs/CuvzQ$GF6gizbI79Bh0zA9its8S0gram956v+YIV8w8VpwJnQ'); INSERT INTO "user" (name, is_cox, is_admin, is_guest, pw) VALUES('cox', true, false, false, '$argon2id$v=19$m=19456,t=2,p=1$dS/X5/sPEKTj4Rzs/CuvzQ$lnWzHx3DdqS9GQyWYel82kIotZuK2wk9EyfhPFtjNzs'); From c6a8866207c0c913775aaa8c5d63160058079c39 Mon Sep 17 00:00:00 2001 From: philipp Date: Sat, 23 Sep 2023 18:12:48 +0200 Subject: [PATCH 005/137] add debug trait; switch to proper name of form field (rowerS) --- src/model/logbook.rs | 15 +++++++-------- src/tera/log.rs | 2 ++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/model/logbook.rs b/src/model/logbook.rs index e38e1b8..2f48c1b 100644 --- a/src/model/logbook.rs +++ b/src/model/logbook.rs @@ -26,7 +26,7 @@ impl PartialEq for Logbook { } } -#[derive(FromForm)] +#[derive(FromForm, Debug)] pub struct LogToAdd { pub boat_id: i32, pub shipmaster: i64, @@ -37,7 +37,7 @@ pub struct LogToAdd { pub distance_in_km: Option, pub comments: Option, pub logtype: Option, - pub rower: Vec, + pub rowers: Vec, } #[derive(FromForm)] @@ -49,7 +49,7 @@ pub struct LogToFinalize { pub rower: Vec, } -#[derive(Serialize)] +#[derive(Serialize, Debug)] pub struct LogbookWithBoatAndRowers { #[serde(flatten)] pub logbook: Logbook, @@ -187,14 +187,14 @@ ORDER BY departure DESC return Err(LogbookCreateError::ShipmasterAlreadyOnWater); } - if log.rower.len() > boat.amount_seats as usize - 1 { + if log.rowers.len() > boat.amount_seats as usize - 1 { return Err(LogbookCreateError::TooManyRowers( boat.amount_seats as usize, - log.rower.len() + 1, + log.rowers.len() + 1, )); } - for rower in &log.rower { + for rower in &log.rowers { let user = User::find_by_id(db, *rower as i32).await.unwrap(); if user.on_water(db).await { return Err(LogbookCreateError::RowerAlreadyOnWater(user)); @@ -204,7 +204,6 @@ ORDER BY departure DESC let mut tx = db.begin().await.unwrap(); let departure = NaiveDateTime::parse_from_str(&log.departure, "%Y-%m-%dT%H:%M").unwrap(); - println!("@@@@@@ {:?}", log.arrival); let arrival = log .arrival .map(|a| NaiveDateTime::parse_from_str(&a, "%Y-%m-%dT%H:%M").unwrap()); @@ -223,7 +222,7 @@ ORDER BY departure DESC .fetch_one(&mut tx) .await.unwrap(); - for rower in &log.rower { + for rower in &log.rowers { Rower::create(&mut tx, inserted_row.id, *rower) .await .map_err(|e| LogbookCreateError::RowerCreateError(*rower, e.to_string()))?; diff --git a/src/tera/log.rs b/src/tera/log.rs index 7eb3c2f..8709ac9 100644 --- a/src/tera/log.rs +++ b/src/tera/log.rs @@ -48,6 +48,8 @@ async fn index( let on_water = Logbook::on_water(db).await; + println!("{on_water:?}"); + let mut context = Context::new(); if let Some(msg) = flash { context.insert("flash", &msg.into_inner()); From 5730d27149fe1bca4db30b03a4af3e6a8322c22a Mon Sep 17 00:00:00 2001 From: philipp Date: Sat, 23 Sep 2023 18:26:04 +0200 Subject: [PATCH 006/137] fix ci --- src/model/logbook.rs | 26 +++++++++++++------------- src/model/user.rs | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/model/logbook.rs b/src/model/logbook.rs index 2f48c1b..5ded709 100644 --- a/src/model/logbook.rs +++ b/src/model/logbook.rs @@ -46,7 +46,7 @@ pub struct LogToFinalize { pub distance_in_km: i64, pub comments: Option, pub logtype: Option, - pub rower: Vec, + pub rowers: Vec, } #[derive(Serialize, Debug)] @@ -271,10 +271,10 @@ ORDER BY departure DESC let boat = Boat::find_by_id(db, self.boat_id as i32).await.unwrap(); //ok - if log.rower.len() > boat.amount_seats as usize - 1 { + if log.rowers.len() > boat.amount_seats as usize - 1 { return Err(LogbookUpdateError::TooManyRowers( boat.amount_seats as usize, - log.rower.len() + 1, + log.rowers.len() + 1, )); } @@ -296,7 +296,7 @@ ORDER BY departure DESC self.remove_rowers(&mut tx).await; - for rower in &log.rower { + for rower in &log.rowers { Rower::create(&mut tx, self.id, *rower) .await .map_err(|e| LogbookUpdateError::RowerCreateError(*rower, e.to_string()))?; @@ -384,7 +384,7 @@ mod test { distance_in_km: None, comments: None, logtype: None, - rower: Vec::new(), + rowers: Vec::new(), }, ) .await @@ -407,7 +407,7 @@ mod test { distance_in_km: None, comments: None, logtype: None, - rower: Vec::new(), + rowers: Vec::new(), }, ) .await; @@ -431,7 +431,7 @@ mod test { distance_in_km: None, comments: None, logtype: None, - rower: Vec::new(), + rowers: Vec::new(), }, ) .await; @@ -455,7 +455,7 @@ mod test { distance_in_km: None, comments: None, logtype: None, - rower: Vec::new(), + rowers: Vec::new(), }, ) .await; @@ -479,7 +479,7 @@ mod test { distance_in_km: None, comments: None, logtype: None, - rower: Vec::new(), + rowers: Vec::new(), }, ) .await; @@ -503,7 +503,7 @@ mod test { distance_in_km: None, comments: None, logtype: None, - rower: vec![1], + rowers: vec![1], }, ) .await; @@ -542,7 +542,7 @@ mod test { distance_in_km: 42, comments: Some("Perfect water".into()), logtype: None, - rower: vec![], + rowers: vec![], }, ) .await @@ -565,7 +565,7 @@ mod test { distance_in_km: 42, comments: Some("Perfect water".into()), logtype: None, - rower: vec![], + rowers: vec![], }, ) .await; @@ -589,7 +589,7 @@ mod test { distance_in_km: 42, comments: Some("Perfect water".into()), logtype: None, - rower: vec![1], + rowers: vec![1], }, ) .await; diff --git a/src/model/user.rs b/src/model/user.rs index b8363d4..4de124b 100644 --- a/src/model/user.rs +++ b/src/model/user.rs @@ -494,7 +494,7 @@ mod test { fn test_cox() { let pool = testdb!(); let res = User::cox(&pool).await; - assert_eq!(res.len(), 2); + assert_eq!(res.len(), 3); } #[sqlx::test] From 2abd483a3f7a4cabffe82350de8b21229bb1ea7b Mon Sep 17 00:00:00 2001 From: Marie Birner Date: Sat, 23 Sep 2023 19:19:28 +0200 Subject: [PATCH 007/137] [TASK] [NPM] install choices.js (styling copy & paste) --- frontend/logbook.ts | 10 + frontend/package.json | 3 + frontend/scss/components/_input.scss | 343 ++++++++++++++++++++- frontend/static/js/multiselect-dropdown.js | 225 -------------- templates/includes/forms/log.html.tera | 2 +- templates/log.html.tera | 5 +- 6 files changed, 359 insertions(+), 229 deletions(-) delete mode 100644 frontend/static/js/multiselect-dropdown.js diff --git a/frontend/logbook.ts b/frontend/logbook.ts index 26c5a18..8d848df 100644 --- a/frontend/logbook.ts +++ b/frontend/logbook.ts @@ -1,3 +1,13 @@ +import Choices from "choices.js"; + +const selects = document.querySelectorAll('select[multiple]'); + if(selects) { + Array.prototype.forEach.call(selects, (select: HTMLInputElement) => { + const choices = new Choices(select); + }); + } + + /*document.addEventListener('DOMContentLoaded', function() { setDistance('.set-distance-js'); }); diff --git a/frontend/package.json b/frontend/package.json index 6767a44..51e9ecb 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -16,5 +16,8 @@ "typescript": "^4.9.3", "vite": "^4.2.0", "vite-plugin-static-copy": "^0.13.1" + }, + "dependencies": { + "choices.js": "^10.2.0" } } diff --git a/frontend/scss/components/_input.scss b/frontend/scss/components/_input.scss index 9660691..136715e 100644 --- a/frontend/scss/components/_input.scss +++ b/frontend/scss/components/_input.scss @@ -10,4 +10,345 @@ select { background-color: white; -webkit-appearance: none; appearance: none; -} \ No newline at end of file +} + +/* =============================== += Choices = +=============================== */ +.choices { + position: relative; + overflow: hidden; + margin-bottom: 24px; + font-size: 16px; +} +.choices:focus { + outline: none; +} +.choices:last-child { + margin-bottom: 0; +} +.choices.is-open { + overflow: visible; +} +.choices.is-disabled .choices__inner, +.choices.is-disabled .choices__input { + background-color: #eaeaea; + cursor: not-allowed; + -webkit-user-select: none; + user-select: none; +} +.choices.is-disabled .choices__item { + cursor: not-allowed; +} +.choices [hidden] { + display: none !important; +} + +.choices[data-type*=select-one] { + cursor: pointer; +} +.choices[data-type*=select-one] .choices__inner { + padding-bottom: 7.5px; +} +.choices[data-type*=select-one] .choices__input { + display: block; + width: 100%; + padding: 10px; + border-bottom: 1px solid #ddd; + background-color: #fff; + margin: 0; +} +.choices[data-type*=select-one] .choices__button { + background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg=="); + padding: 0; + background-size: 8px; + position: absolute; + top: 50%; + right: 0; + margin-top: -10px; + margin-right: 25px; + height: 20px; + width: 20px; + border-radius: 10em; + opacity: 0.25; +} +.choices[data-type*=select-one] .choices__button:hover, .choices[data-type*=select-one] .choices__button:focus { + opacity: 1; +} +.choices[data-type*=select-one] .choices__button:focus { + box-shadow: 0 0 0 2px #00bcd4; +} +.choices[data-type*=select-one] .choices__item[data-value=""] .choices__button { + display: none; +} +.choices[data-type*=select-one]::after { + content: ""; + height: 0; + width: 0; + border-style: solid; + border-color: #333 transparent transparent transparent; + border-width: 5px; + position: absolute; + right: 11.5px; + top: 50%; + margin-top: -2.5px; + pointer-events: none; +} +.choices[data-type*=select-one].is-open::after { + border-color: transparent transparent #333 transparent; + margin-top: -7.5px; +} +.choices[data-type*=select-one][dir=rtl]::after { + left: 11.5px; + right: auto; +} +.choices[data-type*=select-one][dir=rtl] .choices__button { + right: auto; + left: 0; + margin-left: 25px; + margin-right: 0; +} + +.choices[data-type*=select-multiple] .choices__inner, +.choices[data-type*=text] .choices__inner { + cursor: text; +} +.choices[data-type*=select-multiple] .choices__button, +.choices[data-type*=text] .choices__button { + position: relative; + display: inline-block; + margin-top: 0; + margin-right: -4px; + margin-bottom: 0; + margin-left: 8px; + padding-left: 16px; + border-left: 1px solid #008fa1; + background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjRkZGIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg=="); + background-size: 8px; + width: 8px; + line-height: 1; + opacity: 0.75; + border-radius: 0; +} +.choices[data-type*=select-multiple] .choices__button:hover, .choices[data-type*=select-multiple] .choices__button:focus, +.choices[data-type*=text] .choices__button:hover, +.choices[data-type*=text] .choices__button:focus { + opacity: 1; +} + +.choices__inner { + display: inline-block; + vertical-align: top; + width: 100%; + background-color: #f9f9f9; + padding: 7.5px 7.5px 3.75px; + border: 1px solid #ddd; + border-radius: 2.5px; + font-size: 14px; + min-height: 44px; + overflow: hidden; +} +.is-focused .choices__inner, .is-open .choices__inner { + border-color: #b7b7b7; +} +.is-open .choices__inner { + border-radius: 2.5px 2.5px 0 0; +} +.is-flipped.is-open .choices__inner { + border-radius: 0 0 2.5px 2.5px; +} + +.choices__list { + margin: 0; + padding-left: 0; + list-style: none; +} +.choices__list--single { + display: inline-block; + padding: 4px 16px 4px 4px; + width: 100%; +} +[dir=rtl] .choices__list--single { + padding-right: 4px; + padding-left: 16px; +} +.choices__list--single .choices__item { + width: 100%; +} + +.choices__list--multiple { + display: inline; +} +.choices__list--multiple .choices__item { + display: inline-block; + vertical-align: middle; + border-radius: 20px; + padding: 4px 10px; + font-size: 12px; + font-weight: 500; + margin-right: 3.75px; + margin-bottom: 3.75px; + background-color: #00bcd4; + border: 1px solid #00a5bb; + color: #fff; + word-break: break-all; + box-sizing: border-box; +} +.choices__list--multiple .choices__item[data-deletable] { + padding-right: 5px; +} +[dir=rtl] .choices__list--multiple .choices__item { + margin-right: 0; + margin-left: 3.75px; +} +.choices__list--multiple .choices__item.is-highlighted { + background-color: #00a5bb; + border: 1px solid #008fa1; +} +.is-disabled .choices__list--multiple .choices__item { + background-color: #aaaaaa; + border: 1px solid #919191; +} + +.choices__list--dropdown, .choices__list[aria-expanded] { + visibility: hidden; + z-index: 1; + position: absolute; + width: 100%; + background-color: #fff; + border: 1px solid #ddd; + top: 100%; + margin-top: -1px; + border-bottom-left-radius: 2.5px; + border-bottom-right-radius: 2.5px; + overflow: hidden; + word-break: break-all; + will-change: visibility; +} +.is-active.choices__list--dropdown, .is-active.choices__list[aria-expanded] { + visibility: visible; +} +.is-open .choices__list--dropdown, .is-open .choices__list[aria-expanded] { + border-color: #b7b7b7; +} +.is-flipped .choices__list--dropdown, .is-flipped .choices__list[aria-expanded] { + top: auto; + bottom: 100%; + margin-top: 0; + margin-bottom: -1px; + border-radius: 0.25rem 0.25rem 0 0; +} +.choices__list--dropdown .choices__list, .choices__list[aria-expanded] .choices__list { + position: relative; + max-height: 300px; + overflow: auto; + -webkit-overflow-scrolling: touch; + will-change: scroll-position; +} +.choices__list--dropdown .choices__item, .choices__list[aria-expanded] .choices__item { + position: relative; + padding: 10px; + font-size: 14px; +} +[dir=rtl] .choices__list--dropdown .choices__item, [dir=rtl] .choices__list[aria-expanded] .choices__item { + text-align: right; +} +@media (min-width: 640px) { + .choices__list--dropdown .choices__item--selectable, .choices__list[aria-expanded] .choices__item--selectable { + padding-right: 100px; + } + .choices__list--dropdown .choices__item--selectable::after, .choices__list[aria-expanded] .choices__item--selectable::after { + content: attr(data-select-text); + font-size: 12px; + opacity: 0; + position: absolute; + right: 10px; + top: 50%; + transform: translateY(-50%); + } + [dir=rtl] .choices__list--dropdown .choices__item--selectable, [dir=rtl] .choices__list[aria-expanded] .choices__item--selectable { + text-align: right; + padding-left: 100px; + padding-right: 10px; + } + [dir=rtl] .choices__list--dropdown .choices__item--selectable::after, [dir=rtl] .choices__list[aria-expanded] .choices__item--selectable::after { + right: auto; + left: 10px; + } +} +.choices__list--dropdown .choices__item--selectable.is-highlighted, .choices__list[aria-expanded] .choices__item--selectable.is-highlighted { + background-color: #f2f2f2; +} +.choices__list--dropdown .choices__item--selectable.is-highlighted::after, .choices__list[aria-expanded] .choices__item--selectable.is-highlighted::after { + opacity: 0.5; +} + +.choices__item { + cursor: default; +} + +.choices__item--selectable { + cursor: pointer; +} + +.choices__item--disabled { + cursor: not-allowed; + -webkit-user-select: none; + user-select: none; + opacity: 0.5; +} + +.choices__heading { + font-weight: 600; + font-size: 12px; + padding: 10px; + border-bottom: 1px solid #f7f7f7; + color: gray; +} + +.choices__button { + text-indent: -9999px; + -webkit-appearance: none; + appearance: none; + border: 0; + background-color: transparent; + background-repeat: no-repeat; + background-position: center; + cursor: pointer; +} +.choices__button:focus { + outline: none; +} + +.choices__input { + display: inline-block; + vertical-align: baseline; + background-color: #f9f9f9; + font-size: 14px; + margin-bottom: 5px; + border: 0; + border-radius: 0; + max-width: 100%; + padding: 4px 0 4px 2px; +} +.choices__input:focus { + outline: 0; +} +.choices__input::-webkit-search-decoration, .choices__input::-webkit-search-cancel-button, .choices__input::-webkit-search-results-button, .choices__input::-webkit-search-results-decoration { + display: none; +} +.choices__input::-ms-clear, .choices__input::-ms-reveal { + display: none; + width: 0; + height: 0; +} +[dir=rtl] .choices__input { + padding-right: 2px; + padding-left: 0; +} + +.choices__placeholder { + opacity: 0.5; +} + +/* ===== End of Choices ====== */ diff --git a/frontend/static/js/multiselect-dropdown.js b/frontend/static/js/multiselect-dropdown.js deleted file mode 100644 index 89d5bd9..0000000 --- a/frontend/static/js/multiselect-dropdown.js +++ /dev/null @@ -1,225 +0,0 @@ -var style = document.createElement('style'); -style.setAttribute("id","multiselect_dropdown_styles"); -style.innerHTML = ` -.multiselect-dropdown{ - display: inline-block; - border-radius: 4px; - border: solid 1px #ced4da; - background-color: white; - position: relative; - background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e"); - background-repeat: no-repeat; - background-position: right .75rem center; - background-size: 16px 12px; - padding: 0.375rem 0.5rem; - line-height: 1.5rem; -} -.multiselect-dropdown span.optext, .multiselect-dropdown span.placeholder{ - margin-right:0.5em; - margin-bottom:2px; - padding:1px 0; - border-radius: 4px; - display:inline-block; -} -.multiselect-dropdown span.optext{ - background-color: rgba(226, 232, 240, 0.8); - padding:1px 0.75em; -} -.multiselect-dropdown span.optext .optdel { - float: right; - margin: 0 -6px 1px 5px; - font-size: 1em; - cursor: pointer; -} -.multiselect-dropdown span.optext .optdel:hover { color:#f43f5e;} -.multiselect-dropdown span.placeholder{ - color:#ced4da; -} -.multiselect-dropdown-list-wrapper{ - box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0.1) 0px 1px 3px 0px, rgba(0, 0, 0, 0.1) 0px 1px 2px -1px; - z-index: 100; - padding:2px; - border-radius: .375rem; - border: solid 1px #ced4da; - display: none; - margin: -1px; - position: absolute; - top:0; - left: 0; - right: 0; - background: white; -} -.multiselect-dropdown-list-wrapper .multiselect-dropdown-search{ - margin-bottom:5px; - padding: 0.375rem 0.5rem; - line-height: 1.5rem; -} -.multiselect-dropdown-list{ - padding:2px; - height: 15rem; - overflow-y:auto; - overflow-x: hidden; -} -.multiselect-dropdown-list::-webkit-scrollbar { - width: 6px; -} -.multiselect-dropdown-list::-webkit-scrollbar-thumb { - background-color: rgba(226, 232, 240, 0.8); - border-radius: .375rem; -} - -.multiselect-dropdown-list div{ - padding: 5px; -} -.multiselect-dropdown-list input{ - height: 1.15em; - width: 1.15em; - margin-right: 0.35em; -} -.multiselect-dropdown-list div.checked{ -} -.multiselect-dropdown-list div:hover{ - background-color: rgba(226, 232, 240, 0.8); -} -.multiselect-dropdown span.maxselected {width:100%;} -.multiselect-dropdown-all-selector {border-bottom:solid 1px #999;} -`; -document.head.appendChild(style); - -function MultiselectDropdown(options){ - var config={ - search:true, - height:'15rem', - placeholder:'Auswählen', - txtSelected:'ausgewählt', - txtAll:'Alle', - txtRemove: 'Entfernen', - txtSearch:'Suchen', - ...options - }; - function newEl(tag,attrs){ - var e=document.createElement(tag); - if(attrs!==undefined) Object.keys(attrs).forEach(k=>{ - if(k==='class') { Array.isArray(attrs[k]) ? attrs[k].forEach(o=>o!==''?e.classList.add(o):0) : (attrs[k]!==''?e.classList.add(attrs[k]):0)} - else if(k==='style'){ - Object.keys(attrs[k]).forEach(ks=>{ - e.style[ks]=attrs[k][ks]; - }); - } - else if(k==='text'){attrs[k]===''?e.innerHTML=' ':e.innerText=attrs[k]} - else e[k]=attrs[k]; - }); - return e; - } - - - document.querySelectorAll("select[multiple]").forEach((el,k)=>{ - - var div=newEl('div',{class:'multiselect-dropdown',style:{width:config.style?.width??el.clientWidth+'px',padding:config.style?.padding??''}}); - el.style.display='none'; - el.parentNode.insertBefore(div,el.nextSibling); - var listWrap=newEl('div',{class:'multiselect-dropdown-list-wrapper'}); - var list=newEl('div',{class:'multiselect-dropdown-list',style:{height:config.height}}); - var search=newEl('input',{class:['multiselect-dropdown-search'].concat([config.searchInput?.class??'form-control']),style:{width:'100%',display:el.attributes['multiselect-search']?.value==='true'?'block':'none'},placeholder:config.txtSearch}); - listWrap.appendChild(search); - div.appendChild(listWrap); - listWrap.appendChild(list); - - el.loadOptions=()=>{ - list.innerHTML=''; - - if(el.attributes['multiselect-select-all']?.value=='true'){ - var op=newEl('div',{class:'multiselect-dropdown-all-selector'}) - var ic=newEl('input',{type:'checkbox'}); - op.appendChild(ic); - op.appendChild(newEl('label',{text:config.txtAll})); - - op.addEventListener('click',()=>{ - op.classList.toggle('checked'); - op.querySelector("input").checked=!op.querySelector("input").checked; - - var ch=op.querySelector("input").checked; - list.querySelectorAll(":scope > div:not(.multiselect-dropdown-all-selector)") - .forEach(i=>{if(i.style.display!=='none'){i.querySelector("input").checked=ch; i.optEl.selected=ch}}); - - el.dispatchEvent(new Event('change')); - }); - ic.addEventListener('click',(ev)=>{ - ic.checked=!ic.checked; - }); - el.addEventListener('change', (ev)=>{ - let itms=Array.from(list.querySelectorAll(":scope > div:not(.multiselect-dropdown-all-selector)")).filter(e=>e.style.display!=='none') - let existsNotSelected=itms.find(i=>!i.querySelector("input").checked); - if(ic.checked && existsNotSelected) ic.checked=false; - else if(ic.checked==false && existsNotSelected===undefined) ic.checked=true; - }); - - list.appendChild(op); - } - - Array.from(el.options).map(o=>{ - var op=newEl('div',{class:o.selected?'checked':'',optEl:o}) - var ic=newEl('input',{type:'checkbox',checked:o.selected}); - op.appendChild(ic); - op.appendChild(newEl('label',{text:o.text})); - - op.addEventListener('click',()=>{ - op.classList.toggle('checked'); - op.querySelector("input").checked=!op.querySelector("input").checked; - op.optEl.selected=!!!op.optEl.selected; - el.dispatchEvent(new Event('change')); - }); - ic.addEventListener('click',(ev)=>{ - ic.checked=!ic.checked; - }); - o.listitemEl=op; - list.appendChild(op); - }); - div.listEl=listWrap; - - div.refresh=()=>{ - div.querySelectorAll('span.optext, span.placeholder').forEach(t=>div.removeChild(t)); - var sels=Array.from(el.selectedOptions); - if(sels.length>(el.attributes['multiselect-max-items']?.value??5)){ - div.appendChild(newEl('span',{class:['optext','maxselected'],text:sels.length+' '+config.txtSelected})); - } - else{ - sels.map(x=>{ - var c=newEl('span',{class:'optext',text:x.text, srcOption: x}); - if((el.attributes['multiselect-hide-x']?.value !== 'true')) - c.appendChild(newEl('span',{class:'optdel',text:'x',title:config.txtRemove, onclick:(ev)=>{c.srcOption.listitemEl.dispatchEvent(new Event('click'));div.refresh();ev.stopPropagation();}})); - - div.appendChild(c); - }); - } - if(0==el.selectedOptions.length) div.appendChild(newEl('span',{class:'placeholder',text:el.attributes['placeholder']?.value??config.placeholder})); - }; - div.refresh(); - } - el.loadOptions(); - - search.addEventListener('input',()=>{ - list.querySelectorAll(":scope div:not(.multiselect-dropdown-all-selector)").forEach(d=>{ - var txt=d.querySelector("label").innerText.toUpperCase(); - d.style.display=txt.includes(search.value.toUpperCase())?'block':'none'; - }); - }); - - div.addEventListener('click',()=>{ - div.listEl.style.display='block'; - search.focus(); - search.select(); - }); - - document.addEventListener('click', function(event) { - if (!div.contains(event.target)) { - listWrap.style.display='none'; - div.refresh(); - } - }); - }); -} - -window.addEventListener('load',()=>{ - MultiselectDropdown(window.MultiselectDropdownOptions); -}); diff --git a/templates/includes/forms/log.html.tera b/templates/includes/forms/log.html.tera index 5de655c..fe1438b 100644 --- a/templates/includes/forms/log.html.tera +++ b/templates/includes/forms/log.html.tera @@ -105,7 +105,7 @@ {% macro rower_select(id, selected, amount_seats='', class='') %}
- {% for user in users %} {% set_global sel = false %} {% for rower in selected %} diff --git a/templates/log.html.tera b/templates/log.html.tera index 90e7d3f..22dbe71 100644 --- a/templates/log.html.tera +++ b/templates/log.html.tera @@ -5,7 +5,9 @@ {% block content %} {% if flash %} - {{ macros::alert(message=flash.1, type=flash.0, class="sm:col-span-2 lg:col-span-3") }} +
+ {{ macros::alert(message=flash.1, type=flash.0, class="sm:col-span-2 lg:col-span-3") }} +
{% endif %}
@@ -42,5 +44,4 @@ {% include "dynamics/sidebar" %} - {% endblock content%} From c0366edbe13799c7725217ece461bf37e2731499 Mon Sep 17 00:00:00 2001 From: Marie Birner Date: Sat, 23 Sep 2023 21:05:08 +0200 Subject: [PATCH 008/137] [TASK] add working choices.js --- frontend/logbook.ts | 10 ----- frontend/main.ts | 57 +++++++++++++++++++++++++- templates/includes/forms/log.html.tera | 13 ++---- 3 files changed, 60 insertions(+), 20 deletions(-) diff --git a/frontend/logbook.ts b/frontend/logbook.ts index 8d848df..26c5a18 100644 --- a/frontend/logbook.ts +++ b/frontend/logbook.ts @@ -1,13 +1,3 @@ -import Choices from "choices.js"; - -const selects = document.querySelectorAll('select[multiple]'); - if(selects) { - Array.prototype.forEach.call(selects, (select: HTMLInputElement) => { - const choices = new Choices(select); - }); - } - - /*document.addEventListener('DOMContentLoaded', function() { setDistance('.set-distance-js'); }); diff --git a/frontend/main.ts b/frontend/main.ts index d78c41e..4c1f938 100644 --- a/frontend/main.ts +++ b/frontend/main.ts @@ -1,14 +1,62 @@ +import Choices from "choices.js"; import { Sidebar } from './js/sidebar'; import './scss/app.scss' +export interface choiceMap { + [details: string]: Choices; +} + +let choiceObjects: choiceMap = {}; document.addEventListener('DOMContentLoaded', function() { initSearch(); initSidebar(); initToggle(); - replaceStrings(); + initChoices(); + initBoatActions(); }); +function initBoatActions() { + const boatSelects = document.querySelectorAll('.boats-js[data-onclick="true"]'); + if(boatSelects) { + Array.prototype.forEach.call(boatSelects, (select: HTMLInputElement) => { + select.addEventListener('click', function() { + if(select.dataset.seats) { + const rowers = Number(select.dataset.seats) - 1; + choiceObjects['newrower'].config.maxItemCount = rowers; + choiceObjects['newrower'].removeActiveItems(rowers); + } + }); + }); + } +} + +function initChoices() { + const selects = document.querySelectorAll('select[data-init="true"]'); + if(selects) { + Array.prototype.forEach.call(selects, (select: HTMLInputElement) => { + initNewChoice(select); + }); + } +} + +function initNewChoice(select: HTMLInputElement) { + const choice = new Choices(select, { + removeItemButton: true, + loadingText: 'Wird geladen...', + noResultsText: 'Keine Ergebnisse gefunden', + noChoicesText: 'Keine Ergebnisse gefunden', + itemSelectText: 'Zum Auswählen klicken', + placeholderValue: 'Ruderer auswählen', + maxItemCount: Number(select.dataset.seats) - 1, + maxItemText: (maxItemCount) => { + return `Nur ${maxItemCount} Ruderer können hinzugefügt werden`; + }, + }); + + choiceObjects[select.id] = choice; +} + function initToggle() { // get filter btns & set object sessionStorage const btns = >document.querySelectorAll('.filter-trips-js'); @@ -191,6 +239,13 @@ function initTripSidebar(triggerElement: HTMLElement) { let body = document.querySelector(triggerElement.dataset.body); let bodyElement = body.cloneNode(true); let bodyContainerElement = sidebarElement.querySelector('.body-js'); + + const selects = bodyElement.querySelectorAll('select[multiple]'); + if(selects) { + Array.prototype.forEach.call(selects, (select: HTMLInputElement) => { + initNewChoice(select); + }); + } /* Quickfix duplicate ids checkboxes */ const checkboxes = >bodyElement.querySelectorAll('input[type="checkbox"]'); diff --git a/templates/includes/forms/log.html.tera b/templates/includes/forms/log.html.tera index fe1438b..3e37f7c 100644 --- a/templates/includes/forms/log.html.tera +++ b/templates/includes/forms/log.html.tera @@ -13,7 +13,7 @@ {{ amount_seats }}x
{% for boat in grouped_boats %} -
+
{{ boat.name }} {% if boat.owner %} @@ -52,7 +52,7 @@ {% endif %} {% if not only_ones %} - {{ log::rower_select(id="newrower", selected=[], class="col-span-2") }} + {{ log::rower_select(id="newrower", selected=[], class="col-span-2", init=true) }} {% endif %}
@@ -103,9 +103,9 @@ {% endif %} {% endmacro boat_select %} -{% macro rower_select(id, selected, amount_seats='', class='') %} +{% macro rower_select(id, selected, amount_seats='', class='', init='false') %}
- {% for user in users %} {% set_global sel = false %} {% for rower in selected %} @@ -117,11 +117,6 @@ {% endfor %}
-
- - {{amount_seats}} - Ruderer auszuwählen -
{% endmacro rower_select %} {% macro show(log, state, allowed_to_close=false, only_ones) %} From 33cb5e025b8dcf91b0464f647b81ad95c5a659c0 Mon Sep 17 00:00:00 2001 From: Marie Birner Date: Sat, 23 Sep 2023 21:51:00 +0200 Subject: [PATCH 009/137] [TASK] improve rower select --- frontend/main.ts | 17 +++++++++++ templates/includes/forms/log.html.tera | 41 ++++++++++++++++---------- templates/includes/macros.html.tera | 2 +- 3 files changed, 43 insertions(+), 17 deletions(-) diff --git a/frontend/main.ts b/frontend/main.ts index 4c1f938..c141f05 100644 --- a/frontend/main.ts +++ b/frontend/main.ts @@ -14,8 +14,24 @@ document.addEventListener('DOMContentLoaded', function() { replaceStrings(); initChoices(); initBoatActions(); + selectBoatChange(); }); +function selectBoatChange() { + const boatSelect = document.querySelector('#boat_id'); + if(boatSelect) { + boatSelect.addEventListener('change', function() { + const selectedElement = boatSelect as HTMLSelectElement; + const opt = selectedElement.options[selectedElement.selectedIndex]; + const selectedValue = (opt).dataset.amount_seats; + const rowers = Number(selectedValue) - 1; + choiceObjects['newrower'].config.maxItemCount = rowers; + choiceObjects['newrower'].removeActiveItems(rowers); + (rowers === 0 ? choiceObjects['newrower'].disable() : choiceObjects['newrower'].enable()) + }); + } +} + function initBoatActions() { const boatSelects = document.querySelectorAll('.boats-js[data-onclick="true"]'); if(boatSelects) { @@ -25,6 +41,7 @@ function initBoatActions() { const rowers = Number(select.dataset.seats) - 1; choiceObjects['newrower'].config.maxItemCount = rowers; choiceObjects['newrower'].removeActiveItems(rowers); + (rowers === 0 ? choiceObjects['newrower'].disable() : choiceObjects['newrower'].enable()); } }); }); diff --git a/templates/includes/forms/log.html.tera b/templates/includes/forms/log.html.tera index 3e37f7c..e60b5bb 100644 --- a/templates/includes/forms/log.html.tera +++ b/templates/includes/forms/log.html.tera @@ -104,19 +104,21 @@ {% endmacro boat_select %} {% macro rower_select(id, selected, amount_seats='', class='', init='false') %} -
- -
+ {% if not amount_seats or amount_seats > 1 %} +
+ +
+ {% endif %} {% endmacro rower_select %} {% macro show(log, state, allowed_to_close=false, only_ones) %} @@ -156,10 +158,10 @@ {{ log.destination }} {% endif %} - {% for cox in coxes %} - {% if cox.id == log.shipmaster %} + {% for user in users %} + {% if user.id == log.shipmaster %}

- {{ cox.name }} + {{ user.name }}

{% endif %} {% endfor %} @@ -222,6 +224,13 @@ {% macro home(log, only_ones) %}
+ {% for user in users %} + {% if user.id == log.shipmaster %} +

+ {{ user.name }} +

+ {% endif %} + {% endfor %} {% if not only_ones %} {{ log::rower_select(id="rowers"~log.id, selected=log.rowers, amount_seats=log.boat.amount_seats) }} {% endif %} diff --git a/templates/includes/macros.html.tera b/templates/includes/macros.html.tera index 585be2c..f1cbddf 100644 --- a/templates/includes/macros.html.tera +++ b/templates/includes/macros.html.tera @@ -83,7 +83,7 @@ {% endif %} {% for d in data %} -
{{ macros::input(label="Distanz", name="distance_in_km", id="distance_in_km" ~ log.id , type="number", min=0, value=log.distance_in_km, required=true, class="rounded-md change-id-js") }} diff --git a/templates/includes/macros.html.tera b/templates/includes/macros.html.tera index f1cbddf..ad33760 100644 --- a/templates/includes/macros.html.tera +++ b/templates/includes/macros.html.tera @@ -63,7 +63,7 @@ {% macro input(label, name, type, required=false, class='rounded-md', value='', min='', hide_label=false, id='', autofocus=false, wrapper_class='') %}
- +
{% endmacro input %} @@ -83,7 +83,7 @@ {% endif %} {% for d in data %} -
- {{ macros::input(label="Distanz", name="distance_in_km", id="distance_in_km" , type="number", min=0, value='', required=true, class="rounded-md") }} + {{ macros::input(label="Distanz", name="distance_in_km", id="distance_in_km" , type="number", min=0, value='', class="rounded-md") }} km
@@ -105,7 +105,7 @@ {% set_global sel = true %} {% endif %} {% endfor %} - + {% endfor %}
From f392e83af39539735dfe912debcc434869bc860f Mon Sep 17 00:00:00 2001 From: Marie Birner Date: Sat, 23 Sep 2023 23:23:42 +0200 Subject: [PATCH 013/137] [TASK] select boat on click --- frontend/main.ts | 4 ++++ templates/includes/forms/log.html.tera | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/main.ts b/frontend/main.ts index be953be..5321d27 100644 --- a/frontend/main.ts +++ b/frontend/main.ts @@ -42,6 +42,10 @@ function initBoatActions() { const rowers = Number(select.dataset.seats) - 1; choiceObjects['newrower'].config.maxItemCount = rowers; choiceObjects['newrower'].removeActiveItems(rowers); + let boatSelect = document.querySelector('#boat_id'); + if(boatSelect && select.dataset.id) { + boatSelect.value = select.dataset.id; + } (rowers === 0 ? choiceObjects['newrower'].disable() : choiceObjects['newrower'].enable()); } }); diff --git a/templates/includes/forms/log.html.tera b/templates/includes/forms/log.html.tera index 71ba728..a22dd8d 100644 --- a/templates/includes/forms/log.html.tera +++ b/templates/includes/forms/log.html.tera @@ -13,7 +13,7 @@ {{ amount_seats }}x
{% for boat in grouped_boats %} -
+
{{ boat.name }} {% if boat.owner %} From 82a53cf1fc1618b90599edb08d4eae0bc053c683 Mon Sep 17 00:00:00 2001 From: Marie Birner Date: Sat, 23 Sep 2023 23:44:03 +0200 Subject: [PATCH 014/137] [TASK] fix alert issues styling --- templates/log.html.tera | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/templates/log.html.tera b/templates/log.html.tera index 22dbe71..a70b636 100644 --- a/templates/log.html.tera +++ b/templates/log.html.tera @@ -4,15 +4,16 @@ {% extends "base" %} {% block content %} - {% if flash %} -
- {{ macros::alert(message=flash.1, type=flash.0, class="sm:col-span-2 lg:col-span-3") }} -
- {% endif %} - +

Logbuch

+ {% if flash %} +
+ {{ macros::alert(message=flash.1, type=flash.0, class="sm:col-span-2 lg:col-span-3") }} +
+ {% endif %} +
{{ macros::input(label="Distanz", name="distance_in_km", id="distance_in_km" ~ log.id , type="number", min=0, value=log.distance_in_km, required=true, class="rounded-md change-id-js") }} diff --git a/templates/includes/macros.html.tera b/templates/includes/macros.html.tera index ad33760..20d48f6 100644 --- a/templates/includes/macros.html.tera +++ b/templates/includes/macros.html.tera @@ -15,10 +15,10 @@ {% if loggedin_user.is_admin%} - Bootsschaden + Bootsschaden Bootsschaden - + {% endif %} {% if loggedin_user.is_admin %} @@ -83,7 +83,7 @@ {% endif %} {% for d in data %} - Abmelden + Abmelden {% endif %} {% endif %}
-{% include "dynamics/sidebar" %} {% endblock content%} diff --git a/templates/includes/book.html.tera b/templates/includes/book.html.tera new file mode 100644 index 0000000..941c987 --- /dev/null +++ b/templates/includes/book.html.tera @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/templates/includes/macros.html.tera b/templates/includes/macros.html.tera index 72cc855..acd5ea2 100644 --- a/templates/includes/macros.html.tera +++ b/templates/includes/macros.html.tera @@ -13,31 +13,31 @@ {% include "includes/question-icon" %} FAQs - {% if loggedin_user.is_admin%} - - Bootsschaden - Bootsschaden - - - {% endif %} {% if loggedin_user.is_admin %} - - STATS - Logbuch - - - LOGBUCH HISTORY - Logbuch History - - - LOGBUCH - Logbuch - - - BOATS - Bootsverwaltung - - + + {% include "includes/book" %} + Logbuch + + diff --git a/templates/index.html.tera b/templates/index.html.tera index 4645ceb..c08f113 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -293,8 +293,6 @@
-{% include "dynamics/sidebar" %} - {% if loggedin_user.is_cox %} {% include "forms/trip" %} {% endif %} diff --git a/templates/kiosk.html.tera b/templates/kiosk.html.tera index 8150a6d..95715da 100644 --- a/templates/kiosk.html.tera +++ b/templates/kiosk.html.tera @@ -38,7 +38,5 @@
-{% include "dynamics/sidebar" %} - {% endblock content%} diff --git a/templates/log.html.tera b/templates/log.html.tera index a70b636..7e21ffe 100644 --- a/templates/log.html.tera +++ b/templates/log.html.tera @@ -42,7 +42,5 @@ - {% include "dynamics/sidebar" %} - {% endblock content%} From 74c0db4e755eb11ee3ca4fb12365e16597bffdce Mon Sep 17 00:00:00 2001 From: Marie Birner Date: Wed, 27 Sep 2023 13:52:15 +0200 Subject: [PATCH 027/137] [BUGFIX] js errors --- frontend/main.ts | 77 ++++++++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 36 deletions(-) diff --git a/frontend/main.ts b/frontend/main.ts index 001a585..42e84eb 100644 --- a/frontend/main.ts +++ b/frontend/main.ts @@ -20,46 +20,51 @@ document.addEventListener('DOMContentLoaded', function() { function selectBoatChange() { const boatSelect = document.querySelector('#boat_id'); - const boatChoice = new Choices(boatSelect, { - loadingText: 'Wird geladen...', - noResultsText: 'Keine Ergebnisse gefunden', - noChoicesText: 'Keine Ergebnisse gefunden', - itemSelectText: 'Zum Auswählen klicken', - callbackOnCreateTemplates: function () { - return { - option: ({ label, value, customProperties, active, disabled, }: any) => { - const opt: HTMLOptionElement = Choices.defaults.templates.option.call( - this, - { label, value, customProperties, active, disabled } - ); - // We get the original
+ -
{{ user.name }} - {% if user.last_access %} - (last access: - {{ user.last_access | date }}) - {% endif %} -
-
- {{ macros::checkbox(label='Scheckbuch', name='is_guest', id=loop.index , checked=user.is_guest) }} - {{ macros::checkbox(label='Steuerberechtigter', name='is_cox', id=loop.index , checked=user.is_cox) }} - {{ macros::checkbox(label='Technical', name='is_tech', id=loop.index , checked=user.is_tech) }} - {{ macros::checkbox(label='Admin', name='is_admin', id=loop.index , checked=user.is_admin) }} -
- {% if user.pw %} -
Passwort zurücksetzen - {% endif %} -
- - +
+
+
+ +
{{ user.name }} + {% if user.last_access %} + (last access: + {{ user.last_access | date }}) + {% endif %} +
+
+ {{ macros::checkbox(label='Scheckbuch', name='is_guest', id=loop.index , checked=user.is_guest) }} + {{ macros::checkbox(label='Steuerberechtigter', name='is_cox', id=loop.index , checked=user.is_cox) }} + {{ macros::checkbox(label='Technical', name='is_tech', id=loop.index , checked=user.is_tech) }} + {{ macros::checkbox(label='Admin', name='is_admin', id=loop.index , checked=user.is_admin) }} +
+ {% if user.pw %} + Passwort zurücksetzen + {% endif %} +
+ +
+
{% endfor %} diff --git a/templates/includes/forms/log.html.tera b/templates/includes/forms/log.html.tera index e4f643a..c16b946 100644 --- a/templates/includes/forms/log.html.tera +++ b/templates/includes/forms/log.html.tera @@ -188,50 +188,43 @@ {% endmacro show %} -{% macro show_old(log, state, allowed_to_close=false, only_ones) %} - Bootsname: - {{ log.boat.name }}
- Schiffsführer: - {{ log.shipmaster_user.name }}
- {% if log.shipmaster_only_steering %} - Schiffsführer steuert nur - {% endif %} - Weggefahren: - {{ log.departure }}
- {% if state == "completed" %} - Angekommen: - {{ log.arrival}}
- {% endif %} - {% set amount_rowers = log.rowers | length %} - {% set amount_guests = log.boat.amount_seats - amount_rowers -1 %} - {% if allowed_to_close and state == "on_water" %} - {{ log::home(log=log, only_ones=only_ones) }} - {% else %} - Ziel: - {{ log.destination }}
- {% if state == "completed" %} - Km: - {{ log.distance_in_km }}
- {% endif %} - {% if log.comments %} - Kommentare: - {{ log.comments }}
- {% endif %} - {% if log.logtype %} - Logtype: - {{ log.logtype }}
- {% endif %} - {% if amount_guests > 0 or log.rowers | length > 0 %} - Ruderer: - {% endif %} - {% if amount_guests > 0 %} - {{ amount_guests }} - Gäste (ohne Account) - {% endif %} - {% for rower in log.rowers %} - {{ rower.name }} - {% endfor %} - {% endif %} +{% macro show_old(log, state, allowed_to_close=false, only_ones, index) %} +
+
+ {{ log.boat.name }} ({{ log.shipmaster_user.name }}{% if log.shipmaster_only_steering %} - handgesteuer {% endif %}) + {{ log.departure | date(format='%d.%m.%Y - %H:%M') }} {% if state == "completed" %}- {{ log.arrival | date(format='%d.%m.%Y - %H:%M') }}{% endif %} + {% set amount_rowers = log.rowers | length %} + {% set amount_guests = log.boat.amount_seats - amount_rowers -1 %} + {% if allowed_to_close and state == "on_water" %} + {{ log::home(log=log, only_ones=only_ones) }} + {% else %} +
+ {{ log.destination }} + {% if state == "completed" %} + ({{ log.distance_in_km }} km) + {% endif %} +
+ {% if amount_guests > 0 or log.rowers | length > 0 %} + Ruderer: + {% endif %} + {% if amount_guests > 0 %} + {{ amount_guests }} + Gäste (ohne Account) + {% endif %} + {% for rower in log.rowers %} + {{ rower.name }} + {% endfor %} + {% if log.comments %} + Kommentare: + {{ log.comments }}
+ {% endif %} + {% if log.logtype %} + Logtype: + {{ log.logtype }}
+ {% endif %} + {% endif %} +
+
{% endmacro show_old %} {% macro home(log, only_ones) %} diff --git a/templates/log.completed.html.tera b/templates/log.completed.html.tera index 5246fcb..cc9aaf0 100644 --- a/templates/log.completed.html.tera +++ b/templates/log.completed.html.tera @@ -7,10 +7,18 @@

Logbuch

- {% for log in logs %} - {{ log::show_old(log=log, state="completed", only_ones=false) }} -
- {% endfor %} + +
+
+ + +
+ +
+ {% for log in logs %} + {{ log::show_old(log=log, state="completed", only_ones=false, index=loop.index) }} + {% endfor %} +
{% endblock content%} diff --git a/templates/stat.html.tera b/templates/stat.html.tera index be200f6..6152ae6 100644 --- a/templates/stat.html.tera +++ b/templates/stat.html.tera @@ -6,11 +6,13 @@
-

Statstik

-
    +

    Statistik

    +
      {% for s in stat %} -
    1. {{s.name}}: - {{s.rowed_km}}km
    2. +
    3. + {{s.name}} + {{s.rowed_km}}km +
    4. {% endfor %}
From d139bf9a60727bc990d1e76244e620cdeac2371d Mon Sep 17 00:00:00 2001 From: Marie Birner Date: Wed, 27 Sep 2023 15:55:17 +0200 Subject: [PATCH 031/137] [BUGFIX] wordings --- templates/includes/forms/log.html.tera | 18 +++++++++++------- templates/stat.html.tera | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/templates/includes/forms/log.html.tera b/templates/includes/forms/log.html.tera index c16b946..6118eb6 100644 --- a/templates/includes/forms/log.html.tera +++ b/templates/includes/forms/log.html.tera @@ -191,7 +191,7 @@ {% macro show_old(log, state, allowed_to_close=false, only_ones, index) %}
- {{ log.boat.name }} ({{ log.shipmaster_user.name }}{% if log.shipmaster_only_steering %} - handgesteuer {% endif %}) + {{ log.boat.name }} ({{ log.shipmaster_user.name }}{% if log.shipmaster_only_steering %} - handgesteuert {% endif %}) {{ log.departure | date(format='%d.%m.%Y - %H:%M') }} {% if state == "completed" %}- {{ log.arrival | date(format='%d.%m.%Y - %H:%M') }}{% endif %} {% set amount_rowers = log.rowers | length %} {% set amount_guests = log.boat.amount_seats - amount_rowers -1 %} @@ -209,18 +209,22 @@ {% endif %} {% if amount_guests > 0 %} {{ amount_guests }} - Gäste (ohne Account) + Gäste (ohne Account), {% endif %} {% for rower in log.rowers %} - {{ rower.name }} + {{ rower.name }}, {% endfor %} {% if log.comments %} - Kommentare: - {{ log.comments }}
+
+ Kommentare: + {{ log.comments }} +
{% endif %} {% if log.logtype %} - Logtype: - {{ log.logtype }}
+
+ Logtype: + {{ log.logtype }} +
{% endif %} {% endif %}
diff --git a/templates/stat.html.tera b/templates/stat.html.tera index 6152ae6..50fcb48 100644 --- a/templates/stat.html.tera +++ b/templates/stat.html.tera @@ -11,7 +11,7 @@ {% for s in stat %}
  • {{s.name}} - {{s.rowed_km}}km + {{s.rowed_km}} km
  • {% endfor %} From 3923ba9f8b56b41725b29b2f0abe6315678bea73 Mon Sep 17 00:00:00 2001 From: Marie Birner Date: Thu, 28 Sep 2023 09:26:30 +0200 Subject: [PATCH 032/137] [TASK] add current place to stats --- templates/log.completed.html.tera | 2 +- templates/stat.html.tera | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/templates/log.completed.html.tera b/templates/log.completed.html.tera index cc9aaf0..9060de3 100644 --- a/templates/log.completed.html.tera +++ b/templates/log.completed.html.tera @@ -11,7 +11,7 @@
    - +
    diff --git a/templates/stat.html.tera b/templates/stat.html.tera index 50fcb48..c8be5b4 100644 --- a/templates/stat.html.tera +++ b/templates/stat.html.tera @@ -7,11 +7,14 @@

    Statistik

    -
      +
        + {% set_global km = 0 %} {% for s in stat %} -
      1. +
      2. + {% if km != s.rowed_km %}{{loop.index}}{% else %} - {% endif %} {{s.name}} {{s.rowed_km}} km + {% set_global km = s.rowed_km %}
      3. {% endfor %}
      From 617b747942ac6a67d3d39fac1543b2f3fd26a006 Mon Sep 17 00:00:00 2001 From: Marie Birner Date: Thu, 28 Sep 2023 11:52:14 +0200 Subject: [PATCH 033/137] [TASK] improve log and stats look & feel --- templates/admin/user/index.html.tera | 4 +-- templates/includes/forms/log.html.tera | 49 +++++++++++++++----------- templates/includes/macros.html.tera | 2 +- templates/log.completed.html.tera | 2 +- templates/stat.html.tera | 28 +++++++++++---- 5 files changed, 54 insertions(+), 31 deletions(-) diff --git a/templates/admin/user/index.html.tera b/templates/admin/user/index.html.tera index 91b4543..bfdd70d 100644 --- a/templates/admin/user/index.html.tera +++ b/templates/admin/user/index.html.tera @@ -16,7 +16,7 @@
      - +
    From 97df1f16a417f9d3d9321f75e204296af017a0e3 Mon Sep 17 00:00:00 2001 From: Marie Birner Date: Thu, 28 Sep 2023 09:26:30 +0200 Subject: [PATCH 100/137] [TASK] add current place to stats --- templates/log.completed.html.tera | 2 +- templates/stat.html.tera | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/templates/log.completed.html.tera b/templates/log.completed.html.tera index cc9aaf0..9060de3 100644 --- a/templates/log.completed.html.tera +++ b/templates/log.completed.html.tera @@ -11,7 +11,7 @@
    - +
    diff --git a/templates/stat.html.tera b/templates/stat.html.tera index 50fcb48..c8be5b4 100644 --- a/templates/stat.html.tera +++ b/templates/stat.html.tera @@ -7,11 +7,14 @@

    Statistik

    -
      +
        + {% set_global km = 0 %} {% for s in stat %} -
      1. +
      2. + {% if km != s.rowed_km %}{{loop.index}}{% else %} - {% endif %} {{s.name}} {{s.rowed_km}} km + {% set_global km = s.rowed_km %}
      3. {% endfor %}
      From 3cb14835cce091d59b517b0ecfeb98cf5003e9ac Mon Sep 17 00:00:00 2001 From: Marie Birner Date: Thu, 28 Sep 2023 11:52:14 +0200 Subject: [PATCH 101/137] [TASK] improve log and stats look & feel --- templates/admin/user/index.html.tera | 4 +-- templates/includes/forms/log.html.tera | 49 +++++++++++++++----------- templates/includes/macros.html.tera | 2 +- templates/log.completed.html.tera | 2 +- templates/stat.html.tera | 28 +++++++++++---- 5 files changed, 54 insertions(+), 31 deletions(-) diff --git a/templates/admin/user/index.html.tera b/templates/admin/user/index.html.tera index 91b4543..bfdd70d 100644 --- a/templates/admin/user/index.html.tera +++ b/templates/admin/user/index.html.tera @@ -16,7 +16,7 @@
      - +