More bug fixes (see description)
- Fixed bug where opening room would show null-error, for a couple of seconds. This was caused by the FAB not checking if widget.info!=null - Added try&catch for item category, to prevent index-out-of-bounds when the item uses a category that no longer exists - Renamed add/remove Articles to fit the new name: ShoppingListItem
This commit is contained in:
parent
5b398eb2ae
commit
eba0790f7c
5 changed files with 22 additions and 15 deletions
|
@ -62,11 +62,11 @@ class ServerPermission {
|
|||
}
|
||||
|
||||
class RoomPermission {
|
||||
static int get addArticles {
|
||||
static int get addShoppingListItems {
|
||||
return oB("0000001");
|
||||
}
|
||||
|
||||
static int get removeArticles {
|
||||
static int get removeShoppingListItems {
|
||||
return oB("0000010");
|
||||
}
|
||||
|
||||
|
@ -92,8 +92,8 @@ class RoomPermission {
|
|||
|
||||
static List<int> get asList {
|
||||
return [
|
||||
addArticles,
|
||||
removeArticles,
|
||||
addShoppingListItems,
|
||||
removeShoppingListItems,
|
||||
editRoomContent,
|
||||
changeMeta,
|
||||
ota,
|
||||
|
|
|
@ -31,6 +31,7 @@ Future<Response> postWithCreadentials(
|
|||
required User credentials}) async {
|
||||
Map<String, String> headers = {
|
||||
"Content-Type": "application/json",
|
||||
'Connection': 'keep-alive',
|
||||
'Authorization':
|
||||
'Digest name=${credentials.username} server=${target.tag} accountKey=${credentials.password}'
|
||||
};
|
||||
|
|
|
@ -178,6 +178,7 @@ class _RoomCategoriesPageState extends State<RoomCategoriesPage> {
|
|||
credentials: user),
|
||||
onOK: (_) async {
|
||||
// TODO: remove cached category
|
||||
fetchCategories();
|
||||
},
|
||||
after: () {
|
||||
// close popup
|
||||
|
@ -232,10 +233,10 @@ class _RoomCategoriesPageState extends State<RoomCategoriesPage> {
|
|||
});
|
||||
},
|
||||
),
|
||||
floatingActionButton: ((widget.info?.isAdmin ?? false) ||
|
||||
floatingActionButton: (widget.info != null && ((widget.info?.isAdmin ?? false) ||
|
||||
(widget.info?.isOwner ?? false) ||
|
||||
((widget.info?.permissions)! & RoomPermission.editRoomContent !=
|
||||
0))
|
||||
0)))
|
||||
? FloatingActionButton.extended(
|
||||
icon: const Icon(Icons.add),
|
||||
label: Text(AppLocalizations.of(context)!.newCategoryShort),
|
||||
|
|
|
@ -200,12 +200,15 @@ class _ShoppingListPageState extends State<ShoppingListPage> {
|
|||
itemBuilder: (context, index) {
|
||||
final item = list[index];
|
||||
|
||||
RoomCategory cat = RoomCategory.other(context);
|
||||
try {
|
||||
cat = categories[item.category!];
|
||||
}catch(_){}
|
||||
|
||||
return ShoppingListItem(
|
||||
name: item.name,
|
||||
description: item.description,
|
||||
category: (item.category != null)
|
||||
? categories[item.category!]
|
||||
: RoomCategory.other(context),
|
||||
category: cat,
|
||||
key: Key(item.id.toString()),
|
||||
inCart: item.state != 0,
|
||||
onDismiss: () {
|
||||
|
@ -294,10 +297,12 @@ class _ShoppingListPageState extends State<ShoppingListPage> {
|
|||
},
|
||||
)
|
||||
]),
|
||||
floatingActionButton: ((widget.info?.isAdmin ?? false) ||
|
||||
(widget.info?.isOwner ?? false) ||
|
||||
((widget.info?.permissions)! & RoomPermission.editRoomContent !=
|
||||
0))
|
||||
floatingActionButton: (widget.info != null &&
|
||||
((widget.info?.isAdmin ?? false) ||
|
||||
(widget.info?.isOwner ?? false) ||
|
||||
((widget.info?.permissions)! &
|
||||
RoomPermission.addShoppingListItems !=
|
||||
0)))
|
||||
? FloatingActionButton.extended(
|
||||
icon: const Icon(Icons.add),
|
||||
label: Text(AppLocalizations.of(context)!.newItemShort),
|
||||
|
|
|
@ -81,10 +81,10 @@ class _RoomProductsPageState extends State<RoomProductsPage> {
|
|||
);
|
||||
},
|
||||
),
|
||||
floatingActionButton: ((widget.info?.isAdmin ?? false) ||
|
||||
floatingActionButton: (widget.info != null && ((widget.info?.isAdmin ?? false) ||
|
||||
(widget.info?.isOwner ?? false) ||
|
||||
((widget.info?.permissions)! & RoomPermission.editRoomContent !=
|
||||
0))
|
||||
0)))
|
||||
? FloatingActionButton.extended(
|
||||
icon: const Icon(Icons.add),
|
||||
label: Text(AppLocalizations.of(context)!.newProductShort),
|
||||
|
|
Loading…
Reference in a new issue