feat(wip): modern approach for planning

This commit is contained in:
Max Hohlfeld 2024-07-03 00:10:58 +02:00
parent 016e690dbd
commit 95c0324098
2 changed files with 74 additions and 31 deletions

View File

@ -18,7 +18,8 @@ pub struct NewAssignmentTemplate {
user: User,
event: Event,
available_wachhabende: Vec<Availabillity>,
available_posten: Vec<Availabillity>
available_posten: Vec<Availabillity>,
all: Vec<Availabillity>
}
#[actix_web::get("/assignments/new")]
@ -29,10 +30,11 @@ pub async fn get(user: Identity, pool: web::Data<PgPool>, query: web::Query<Even
if let Ok(event) = Event::read_by_id_including_location(pool.get_ref(), query.event).await {
if current_user.role == Role::Admin || current_user.role == Role::AreaManager && event.location.as_ref().unwrap().area_id == current_user.area_id {
let all = Availabillity::read_not_assigned_by_date_including_user(pool.get_ref(), event.date).await.unwrap();
let available_posten = Availabillity::read_not_assigned_by_date_including_user(pool.get_ref(), event.date).await.unwrap();
let available_wachhabende = available_posten.iter().filter(|a| a.user.as_ref().unwrap().function == Function::Wachhabender).map(|avl| avl.clone()).collect();
let template = NewAssignmentTemplate { user: current_user, event, available_wachhabende, available_posten };
let template = NewAssignmentTemplate { user: current_user, event, available_wachhabende, available_posten, all };
return template.to_response();
}

View File

@ -16,6 +16,47 @@
<p>Kleidungsordnung: {{ event.clothing }}</p>
</div>
<div class="box">
<table class="table is-fullwidth">
<thead>
<tr>
<th>Name</th>
<th>Funktion</th>
<th>Zeit</th>
<th>Kommentar</th>
<th></th>
</tr>
</thead>
<tbody>
{% for a in all %}
{% let u = a.user.as_ref().unwrap() %}
<tr>
<td>{{ u.name }}</td>
<td>
{% match user.function %}
{% when Function::Posten %}
<span class="tag is-info">Posten</span>
{% when Function::Wachhabender %}
<span class="tag is-info">Wachhabender</span>
{% else %}
{% endmatch %}
</td>
<td>
{% if a.start_time.is_some() && a.end_time.is_some() %}
{{ a.start_time.as_ref().unwrap() }} - {{ a.end_time.as_ref().unwrap() }}
{% else %}
ganztägig
{% endif %}
</td>
<td>
{{ a.comment.as_deref().unwrap_or("") }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% if event.voluntary_wachhabender %}
<div class="field">
<label class="label">Wachhabender</label>
@ -24,20 +65,20 @@
{% for a in available_wachhabende %}
{% let user = a.user.as_ref().unwrap() %}
<option value="{{ a.id }}">
{{ user.name }} -
{% match user.function %}
{{ user.name }} -
{% match user.function %}
{% when Function::Posten %}
Posten
{% when Function::Wachhabender %}
Wachhabender
{% else %}
{% endmatch %}
-
{% if a.start_time.is_some() && a.end_time.is_some() %}
{{ a.start_time.as_ref().unwrap() }} - {{ a.end_time.as_ref().unwrap() }}
{% else %}
ganztägig
{% endif %}
{% endmatch %}
-
{% if a.start_time.is_some() && a.end_time.is_some() %}
{{ a.start_time.as_ref().unwrap() }} - {{ a.end_time.as_ref().unwrap() }}
{% else %}
ganztägig
{% endif %}
</option>
{% endfor %}
</select>
@ -53,20 +94,20 @@
{% for a in available_posten %}
{% let user = a.user.as_ref().unwrap() %}
<option value="{{ a.id }}">
{{ user.name }} -
{% match user.function %}
{{ user.name }} -
{% match user.function %}
{% when Function::Posten %}
Posten
{% when Function::Wachhabender %}
Wachhabender
{% else %}
{% endmatch %}
-
{% if a.start_time.is_some() && a.end_time.is_some() %}
{{ a.start_time.as_ref().unwrap() }} - {{ a.end_time.as_ref().unwrap() }}
{% else %}
ganztägig
{% endif %}
{% endmatch %}
-
{% if a.start_time.is_some() && a.end_time.is_some() %}
{{ a.start_time.as_ref().unwrap() }} - {{ a.end_time.as_ref().unwrap() }}
{% else %}
ganztägig
{% endif %}
</option>
{% endfor %}
</select>
@ -83,17 +124,17 @@
</div>
<div class="field is-horizontal">
<div class="field-label"></div>
<div class="field-body">
<div class="field is-grouped">
<div class="control">
<input class="button is-link" type="submit" value="Erstellen">
</div>
<div class="control">
<a class="button is-link is-light" href="/">Zurück</a>
</div>
</div>
</div>
<div class="field-label"></div>
<div class="field-body">
<div class="field is-grouped">
<div class="control">
<input class="button is-link" type="submit" value="Erstellen">
</div>
<div class="control">
<a class="button is-link is-light" href="/">Zurück</a>
</div>
</div>
</div>
</div>
</form>