loadForm method
Fills the form: empty for item == null, otherwise with the full room (photos included).
Implementation
Future<void> loadForm(UHotelRoomResponse? item) async {
final UHotelRoomResponse? r = item == null
? null
: (await UServices.hotel.readHotelRoomById(
p: UIdParams(
id: item.id,
selectorArgs: const UHotelRoomSelectorArgs(media: UMediaSelectorArgs()),
),
)).$1?.result ??
item;
final UHotelRoomJson? d = r?.jsonData;
editing = r;
formHotel = r?.hotel ?? item?.hotel ?? hotel;
titleController.text = r?.title ?? "";
capacityController.text = r?.capacity.toString() ?? "";
priceController.text = r?.pricePerNight.toInt().toString() ?? "";
descriptionController.text = d?.description ?? d?.detail1 ?? "";
roomNumberController.text = r?.roomNumber ?? "";
quantityController.text = (r?.quantity ?? 1).toString();
bedTypeController.text = d?.bedType ?? "";
sizeController.text = d?.sizeSquareMeters?.toInt().toString() ?? "";
floorController.text = d?.floor?.toString() ?? "";
extraGuestCapacityController.text = d?.extraGuestCapacity?.toString() ?? "";
extraGuestPriceController.text = d?.extraGuestPrice?.toInt().toString() ?? "";
isAvailable = r?.isAvailable ?? true;
tags = List<int>.from(r?.tags ?? <int>[TagRoom.double_.number]);
media = (r?.media ?? <UMediaResponse>[]).sortedForGallery();
photos.dispose();
photos = UFilePickerController.fromMedia(media);
}