don't lose trip_type on event cancellation; don't add empty notes in cal
Some checks failed
CI/CD Pipeline / deploy-staging (push) Blocked by required conditions
CI/CD Pipeline / deploy-main (push) Blocked by required conditions
CI/CD Pipeline / test (push) Has been cancelled

This commit is contained in:
philipp 2024-06-06 06:57:43 +02:00
parent fa14cfbf83
commit e1b78b2725
3 changed files with 7 additions and 3 deletions

View File

@ -98,6 +98,7 @@ FROM trip WHERE planned_event_id = ?
} }
} }
#[derive(Debug)]
pub struct EventUpdate<'a> { pub struct EventUpdate<'a> {
pub name: &'a str, pub name: &'a str,
pub planned_amount_cox: i32, pub planned_amount_cox: i32,
@ -361,7 +362,7 @@ WHERE trip_details.id=?
))); )));
let mut name = String::new(); let mut name = String::new();
if event.is_cancelled() { if event.is_cancelled() {
name.push_str("ABGESAGT :-( "); name.push_str("ABGESAGT! :-( ");
} }
name.push_str(&format!("{} ", event.name)); name.push_str(&format!("{} ", event.name));
@ -370,7 +371,9 @@ WHERE trip_details.id=?
name.push_str(&format!("{} ", triptype.name)) name.push_str(&format!("{} ", triptype.name))
} }
if let Some(notes) = tripdetails.notes { if let Some(notes) = tripdetails.notes {
name.push_str(&format!("({notes}) ")) if !notes.is_empty() {
name.push_str(&format!("({notes}) "))
}
} }
vevent.push(Summary::new(name)); vevent.push(Summary::new(name));
calendar.add_event(vevent); calendar.add_event(vevent);

View File

@ -40,7 +40,7 @@ async fn create(
} }
//TODO: add constraints (e.g. planned_amount_cox > 0) //TODO: add constraints (e.g. planned_amount_cox > 0)
#[derive(FromForm)] #[derive(FromForm, Debug)]
struct UpdateEventForm<'r> { struct UpdateEventForm<'r> {
id: i64, id: i64,
name: &'r str, name: &'r str,

View File

@ -251,6 +251,7 @@
{{ macros::input(label='', name='planned_amount_cox', type='hidden', value=event.planned_amount_cox) }} {{ macros::input(label='', name='planned_amount_cox', type='hidden', value=event.planned_amount_cox) }}
{{ macros::input(label='', name='always_show', type='hidden', value=event.always_show) }} {{ macros::input(label='', name='always_show', type='hidden', value=event.always_show) }}
{{ macros::input(label='', name='is_locked', type='hidden', value=event.is_locked) }} {{ macros::input(label='', name='is_locked', type='hidden', value=event.is_locked) }}
{{ macros::input(label='', name='trip_type', type='hidden', value=event.trip_type_id) }}
<input value="Ausfahrt absagen" class="btn btn-alert" type="submit" /> <input value="Ausfahrt absagen" class="btn btn-alert" type="submit" />
</form> </form>
</div> </div>