Commit b354d55d authored by Volker Krause's avatar Volker Krause
Browse files

Select appropriate default countries for places in editor pages

parent a14ed062
Pipeline #152847 passed with stage
in 1 minute and 26 seconds
......@@ -21,6 +21,15 @@ Kirigami.ScrollablePage {
property alias dateTimeEditSheet: _dateTimeEditSheet
/** Returns the country we are assumed to be in at the given time. */
function countryAtTime(dt) {
const place = TimelineModel.locationAtTime(dt);
if (place && place.address.addressCountry) {
return place.address.addressCountry;
}
return Settings.homeCountryIsoCode;
}
actions {
main: Kirigami.Action {
iconName: "document-save"
......
......@@ -43,6 +43,7 @@ App.EditorPage {
nameLabel: i18n("Venue:")
place: reservation.reservationFor.location
name: reservation.reservationFor.location.name
defaultCountry: countryAtTime(reservation.reservationFor.startDate)
}
// TODO start/end/entrance times
......
......@@ -35,6 +35,13 @@ App.EditorPage {
Kirigami.FormData.isSection: true
place: reservation.reservationFor
name: reservation.reservationFor.name
defaultCountry: {
const HOUR = 60 * 60 * 1000;
const DAY = 24 * HOUR;
var dt = reservation.checkinTime;
dt.setTime(dt.getTime() - (dt.getHours() * HOUR) + DAY);
return countryAtTime(dt);
}
}
Kirigami.FormLayout {
......
......@@ -32,6 +32,7 @@ App.EditorPage {
id: address
place: reservation.reservationFor
name: reservation.reservationFor.name
defaultCountry: countryAtTime(reservation.startTime)
}
// time
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment