Compare commits

...

3 Commits

Author SHA1 Message Date
a4f72d746c Merge pull request 'quick-add-people-from-planned-trip' (#670) from quick-add-people-from-planned-trip into staging
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m2s
CI/CD Pipeline / deploy-staging (push) Successful in 6m50s
CI/CD Pipeline / deploy-main (push) Has been skipped
Reviewed-on: #670
2024-08-13 23:10:53 +02:00
e55f380c4f be able to auto populate people from planned trip
Some checks failed
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
CI/CD Pipeline / test (push) Has been cancelled
2024-08-13 23:02:34 +02:00
bb502a4561 Merge pull request 'fix typo' (#669) from typo into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m9s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 6m38s
Reviewed-on: #669
2024-08-13 15:38:07 +02:00
8 changed files with 59 additions and 8 deletions

View File

@ -773,3 +773,4 @@ function replaceStrings() {
weekday.innerHTML = weekday.innerHTML.replace("Freitag", "Markttag"); weekday.innerHTML = weekday.innerHTML.replace("Freitag", "Markttag");
}); });
} }

View File

@ -1,4 +1,4 @@
use chrono::NaiveDate; use chrono::{Local, NaiveDate};
use serde::Serialize; use serde::Serialize;
use sqlx::SqlitePool; use sqlx::SqlitePool;
@ -164,6 +164,11 @@ WHERE trip.id=?
} }
} }
pub async fn get_for_today(db: &SqlitePool) -> Vec<TripWithUserAndType> {
let today = Local::now().date_naive();
Self::get_for_day(db, today).await
}
pub async fn get_for_day(db: &SqlitePool, day: NaiveDate) -> Vec<TripWithUserAndType> { pub async fn get_for_day(db: &SqlitePool, day: NaiveDate) -> Vec<TripWithUserAndType> {
let day = format!("{day}"); let day = format!("{day}");
let trips = sqlx::query_as!( let trips = sqlx::query_as!(

View File

@ -24,6 +24,7 @@ use crate::model::{
LogbookDeleteError, LogbookUpdateError, LogbookDeleteError, LogbookUpdateError,
}, },
logtype::LogType, logtype::LogType,
trip::Trip,
user::{AdminUser, DonauLinzUser, User, UserWithDetails, VorstandUser}, user::{AdminUser, DonauLinzUser, User, UserWithDetails, VorstandUser},
}; };
@ -84,6 +85,7 @@ async fn index(
} }
context.insert("boats", &boats); context.insert("boats", &boats);
context.insert("planned_trips", &Trip::get_for_today(db).await);
context.insert( context.insert(
"reservations", "reservations",
&BoatReservation::all_future_with_groups(db).await, &BoatReservation::all_future_with_groups(db).await,
@ -187,6 +189,7 @@ async fn kiosk(
context.insert("flash", &msg.into_inner()); context.insert("flash", &msg.into_inner());
} }
context.insert("planned_trips", &Trip::get_for_today(db).await);
context.insert("boats", &boats); context.insert("boats", &boats);
context.insert( context.insert(
"reservations", "reservations",

View File

@ -61,7 +61,8 @@
<small class="block text-gray-600 dark:text-gray-100"> <small class="block text-gray-600 dark:text-gray-100">
{% for role in user.roles -%} {% for role in user.roles -%}
{{ role }} {{ role }}
{%- if not loop.last %}, {% endif -%} {%- if not loop.last %},
{% endif -%}
{% endfor %} {% endfor %}
</small> </small>
</span> </span>

View File

@ -1,3 +1,42 @@
{% macro plannedtrips() %}
{% if planned_trips %}
<script>
function setChoiceByLabel(choicesInstance, label) {
const choices = choicesInstance.config.choices;
const normalizedLabel = label.trim().replace(/\n/g, '');
const choice = choices.find(c => {
const choiceLabel = c.label.trim().replace(/\n/g, '');
return choiceLabel === normalizedLabel;
});
if (choice) {
choicesInstance.setChoiceByValue(choice.value);
} else {
console.warn(`Choice with label "${normalizedLabel}" not found`);
}
}
</script>
<div class="bg-white dark:bg-primary-900 rounded-md shadow pb-2 mt-3">
<h2 class="h2">Heute geplante Ausfahrten</h2>
<div class="grid grid-cols-1 gap-3 mb-3 w-full">
{% for planned_trip in planned_trips | sort(attribute='planned_starting_time') %}
<div class="pt-2 px-3 border-t text-primary-900 dark:text-white">
<strong class="block">
{{ planned_trip.cox_name }} ({{ planned_trip.rower | length + 1 }} Personen)
<small>{{ planned_trip.planned_starting_time }}</small>
<button class="btn btn-primary"
onclick="choiceObjects['newrower'].removeActiveItems(-1);choiceObjects['newrower'].setChoiceByValue('{{ planned_trip.cox_id }}'); {% for rower in planned_trip.rower %}setChoiceByLabel(choiceObjects['newrower'], '{{ rower.name }}'){% endfor %} ">
👥
</button>
</strong>
</div>
{% endfor %}
</div>
</div>
{% endif %}
{% endmacro plannedtrips %}
{% macro boatreservation() %} {% macro boatreservation() %}
<div class="bg-white dark:bg-primary-900 rounded-md shadow pb-2 mt-3"> <div class="bg-white dark:bg-primary-900 rounded-md shadow pb-2 mt-3">
<h2 class="h2">Reservierungen ({{ reservations | length }})</h2> <h2 class="h2">Reservierungen ({{ reservations | length }})</h2>

View File

@ -53,6 +53,7 @@
</div> </div>
</div> </div>
{{ macros::boatreservation() }} {{ macros::boatreservation() }}
{{ macros::plannedtrips() }}
</div> </div>
</div> </div>
</div> </div>

View File

@ -35,6 +35,7 @@
{% endif %} {% endif %}
</div> </div>
{{ macros::boatreservation() }} {{ macros::boatreservation() }}
{{ macros::plannedtrips() }}
</div> </div>
</div> </div>
</div> </div>