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 {
|
class RoomPermission {
|
||||||
static int get addArticles {
|
static int get addShoppingListItems {
|
||||||
return oB("0000001");
|
return oB("0000001");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get removeArticles {
|
static int get removeShoppingListItems {
|
||||||
return oB("0000010");
|
return oB("0000010");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,8 +92,8 @@ class RoomPermission {
|
||||||
|
|
||||||
static List<int> get asList {
|
static List<int> get asList {
|
||||||
return [
|
return [
|
||||||
addArticles,
|
addShoppingListItems,
|
||||||
removeArticles,
|
removeShoppingListItems,
|
||||||
editRoomContent,
|
editRoomContent,
|
||||||
changeMeta,
|
changeMeta,
|
||||||
ota,
|
ota,
|
||||||
|
|
|
@ -31,6 +31,7 @@ Future<Response> postWithCreadentials(
|
||||||
required User credentials}) async {
|
required User credentials}) async {
|
||||||
Map<String, String> headers = {
|
Map<String, String> headers = {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
'Connection': 'keep-alive',
|
||||||
'Authorization':
|
'Authorization':
|
||||||
'Digest name=${credentials.username} server=${target.tag} accountKey=${credentials.password}'
|
'Digest name=${credentials.username} server=${target.tag} accountKey=${credentials.password}'
|
||||||
};
|
};
|
||||||
|
|
|
@ -178,6 +178,7 @@ class _RoomCategoriesPageState extends State<RoomCategoriesPage> {
|
||||||
credentials: user),
|
credentials: user),
|
||||||
onOK: (_) async {
|
onOK: (_) async {
|
||||||
// TODO: remove cached category
|
// TODO: remove cached category
|
||||||
|
fetchCategories();
|
||||||
},
|
},
|
||||||
after: () {
|
after: () {
|
||||||
// close popup
|
// 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?.isOwner ?? false) ||
|
||||||
((widget.info?.permissions)! & RoomPermission.editRoomContent !=
|
((widget.info?.permissions)! & RoomPermission.editRoomContent !=
|
||||||
0))
|
0)))
|
||||||
? FloatingActionButton.extended(
|
? FloatingActionButton.extended(
|
||||||
icon: const Icon(Icons.add),
|
icon: const Icon(Icons.add),
|
||||||
label: Text(AppLocalizations.of(context)!.newCategoryShort),
|
label: Text(AppLocalizations.of(context)!.newCategoryShort),
|
||||||
|
|
|
@ -200,12 +200,15 @@ class _ShoppingListPageState extends State<ShoppingListPage> {
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final item = list[index];
|
final item = list[index];
|
||||||
|
|
||||||
|
RoomCategory cat = RoomCategory.other(context);
|
||||||
|
try {
|
||||||
|
cat = categories[item.category!];
|
||||||
|
}catch(_){}
|
||||||
|
|
||||||
return ShoppingListItem(
|
return ShoppingListItem(
|
||||||
name: item.name,
|
name: item.name,
|
||||||
description: item.description,
|
description: item.description,
|
||||||
category: (item.category != null)
|
category: cat,
|
||||||
? categories[item.category!]
|
|
||||||
: RoomCategory.other(context),
|
|
||||||
key: Key(item.id.toString()),
|
key: Key(item.id.toString()),
|
||||||
inCart: item.state != 0,
|
inCart: item.state != 0,
|
||||||
onDismiss: () {
|
onDismiss: () {
|
||||||
|
@ -294,10 +297,12 @@ class _ShoppingListPageState extends State<ShoppingListPage> {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
]),
|
]),
|
||||||
floatingActionButton: ((widget.info?.isAdmin ?? false) ||
|
floatingActionButton: (widget.info != null &&
|
||||||
|
((widget.info?.isAdmin ?? false) ||
|
||||||
(widget.info?.isOwner ?? false) ||
|
(widget.info?.isOwner ?? false) ||
|
||||||
((widget.info?.permissions)! & RoomPermission.editRoomContent !=
|
((widget.info?.permissions)! &
|
||||||
0))
|
RoomPermission.addShoppingListItems !=
|
||||||
|
0)))
|
||||||
? FloatingActionButton.extended(
|
? FloatingActionButton.extended(
|
||||||
icon: const Icon(Icons.add),
|
icon: const Icon(Icons.add),
|
||||||
label: Text(AppLocalizations.of(context)!.newItemShort),
|
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?.isOwner ?? false) ||
|
||||||
((widget.info?.permissions)! & RoomPermission.editRoomContent !=
|
((widget.info?.permissions)! & RoomPermission.editRoomContent !=
|
||||||
0))
|
0)))
|
||||||
? FloatingActionButton.extended(
|
? FloatingActionButton.extended(
|
||||||
icon: const Icon(Icons.add),
|
icon: const Icon(Icons.add),
|
||||||
label: Text(AppLocalizations.of(context)!.newProductShort),
|
label: Text(AppLocalizations.of(context)!.newProductShort),
|
||||||
|
|
Loading…
Reference in a new issue