loadForm method
Fills the form: empty for item == null, otherwise with the full room (photos included).
Implementation
Future<void> loadForm(UDormRoomResponse? item) async {
final UDormRoomResponse? r = item == null
? null
: (await UServices.hotel.readDormRoomById(
p: UIdParams(
id: item.id,
selectorArgs: const UDormRoomSelectorArgs(media: UMediaSelectorArgs()),
),
)).$1?.result ??
item;
editing = r;
formDorm = r?.dorm ?? item?.dorm ?? dorm;
titleController.text = r?.title ?? "";
descriptionController.text = r?.jsonData.description ?? "";
capacityController.text = r?.capacity.toString() ?? "";
floorController.text = r?.jsonData.floor?.toString() ?? "";
tags = List<int>.from(r?.tags ?? <int>[TagDormRoom.dorm.number]);
media = (r?.media ?? <UMediaResponse>[]).sortedForGallery();
photos.dispose();
photos = UFilePickerController.fromMedia(media);
}