Warning, /pim/itinerary/src/app/HotelEditor.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 0008 import QtQuick.Layouts 0009 import QtQuick.Controls as QQC2 0010 import org.kde.kirigami as Kirigami 0011 import org.kde.kirigamiaddons.formcard as FormCard 0012 import org.kde.i18n.localeData 0013 import org.kde.kitinerary 0014 import org.kde.itinerary 0015 0016 EditorPage { 0017 id: root 0018 0019 title: i18n("Edit Hotel Reservation") 0020 0021 isValidInput: checkinEdit.hasValue && checkoutEdit.hasValue && hotelName.text !== "" && checkinEdit.value < checkoutEdit.value 0022 0023 function apply(reservation) { 0024 let hotel = address.save(reservation.reservationFor); 0025 if (hotelName.text) { 0026 hotel.name = hotelName.text; 0027 } 0028 hotel = contactEdit.save(hotel); 0029 let newRes = reservation; 0030 newRes.reservationFor = hotel; 0031 0032 if (checkinEdit.isModified) 0033 newRes = Util.setDateTimePreserveTimezone(newRes, "checkinTime", checkinEdit.value); 0034 if (checkoutEdit.isModified) 0035 newRes = Util.setDateTimePreserveTimezone(newRes, "checkoutTime", checkoutEdit.value); 0036 0037 bookingEdit.apply(newRes); 0038 return newRes; 0039 } 0040 0041 ColumnLayout { 0042 spacing: 0 0043 0044 CardPageTitle { 0045 emojiIcon: "🏨" 0046 text: i18n("Hotel") 0047 } 0048 0049 FormCard.FormHeader { 0050 title: i18nc("@title:group", "Accommodation") 0051 } 0052 0053 FormCard.FormCard { 0054 FormCard.FormTextFieldDelegate { 0055 id: hotelName 0056 label: i18nc("hotel name", "Name") 0057 text: reservation.reservationFor.name 0058 status: Kirigami.MessageType.Error 0059 statusMessage: text === "" ? i18n("Name must not be empty.") : "" 0060 } 0061 0062 FormCard.FormDelegateSeparator {} 0063 0064 FormPlaceEditorDelegate { 0065 id: address 0066 place: { 0067 if (root.batchId || !root.reservation.reservationFor.address.isEmpty || root.reservation.reservationFor.geo.isValid) 0068 return reservation.reservationFor 0069 0070 const HOUR = 60 * 60 * 1000; 0071 const DAY = 24 * HOUR; 0072 let dt = reservation.checkinTime; 0073 dt.setTime(dt.getTime() - (dt.getHours() * HOUR) + DAY); 0074 return cityAtTime(dt); 0075 } 0076 } 0077 } 0078 0079 FormCard.FormCard { 0080 Layout.topMargin: Kirigami.Units.largeSpacing 0081 0082 FormDateTimeEditDelegate { 0083 id: checkinEdit 0084 text: i18nc("hotel checkin", "Check-in") 0085 obj: reservation 0086 propertyName: "checkinTime" 0087 status: Kirigami.MessageType.Error 0088 statusMessage: checkinEdit.hasValue ? '' : i18n("Check-in time has to be set.") 0089 } 0090 FormCard.FormDelegateSeparator {} 0091 FormDateTimeEditDelegate { 0092 id: checkoutEdit 0093 text: i18nc("hotel checkout", "Check-out") 0094 obj: reservation 0095 propertyName: "checkoutTime" 0096 initialValue: { 0097 let d = new Date(checkinEdit.value); 0098 d.setDate(d.getDate() + 1); 0099 d.setHours(12); 0100 return d; 0101 } 0102 status: Kirigami.MessageType.Error 0103 statusMessage: { 0104 if (!checkoutEdit.hasValue) 0105 return i18n("Check-out time has to be set.") 0106 if (checkinEdit.hasValue && checkoutEdit.value < checkinEdit.value) 0107 return i18n("Check-out time has to be after the check-in time.") 0108 return ''; 0109 } 0110 } 0111 } 0112 0113 ContactEditorCard { 0114 id: contactEdit 0115 contact: reservation.reservationFor 0116 } 0117 0118 BookingEditorCard { 0119 id: bookingEdit 0120 item: reservation 0121 defaultCurrency: Country.fromAlpha2(address.currentCountry).currencyCode 0122 } 0123 } 0124 }