Commit 170b29a2 authored by Volker Krause's avatar Volker Krause
Browse files

Fix editing of event reservations without any location data

In that case the location property is undefined, so we need to create a
new one, which requires a helper function in C++.
parent 4a64b282
......@@ -85,6 +85,7 @@ target_sources(itinerary-app PRIVATE
countrysubdivisionmodel.cpp
developmentmodecontroller.cpp
documentsmodel.cpp
factory.cpp
locationinformationdelegatecontroller.cpp
mapdownloadmanager.cpp
notificationconfigcontroller.cpp
......
......@@ -18,7 +18,7 @@ App.EditorPage {
function save(resId, reservation) {
var event = reservation.reservationFor;
var loc = address.save(reservation.reservationFor.location);
var loc = address.save(reservation.reservationFor.location ? reservation.reservationFor.location : Factory.makePlace());
loc.name = address.name;
event.location = loc;
var newRes = reservation;
......@@ -41,8 +41,8 @@ App.EditorPage {
id: address
Kirigami.FormData.isSection: true
nameLabel: i18n("Venue:")
place: reservation.reservationFor.location
name: reservation.reservationFor.location.name
place: reservation.reservationFor.location ? reservation.reservationFor.location : Factory.makePlace()
name: reservation.reservationFor.location ? reservation.reservationFor.location.name : ""
defaultCountry: countryAtTime(reservation.reservationFor.startDate)
}
......
/*
SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "factory.h"
#include <KItinerary/Place>
QVariant Factory::makePlace()
{
return KItinerary::Place();
}
/*
SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef FACTORY_H
#define FACTORY_H
#include "qobjectdefs.h"
class QVariant;
/** QML factory functions for gadget types. */
class Factory
{
Q_GADGET
public:
Q_INVOKABLE static QVariant makePlace();
};
#endif // FACTORY_H
......@@ -13,6 +13,7 @@
#include "developmentmodecontroller.h"
#include "documentmanager.h"
#include "documentsmodel.h"
#include "factory.h"
#include "favoritelocationmodel.h"
#include "genericpkpass.h"
#include "healthcertificatemanager.h"
......@@ -199,6 +200,7 @@ void registerApplicationSingletons()
REGISTER_SINGLETON_GADGET_INSTANCE(TripGroupInfoProvider, s_tripGroupInfoProvider)
REGISTER_SINGLETON_GADGET_FACTORY(DevelopmentModeController)
REGISTER_SINGLETON_GADGET_FACTORY(Factory)
REGISTER_SINGLETON_GADGET_FACTORY(Localizer)
REGISTER_SINGLETON_GADGET_FACTORY(NavigationController)
REGISTER_SINGLETON_GADGET_FACTORY(NotificationConfigController)
......
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