mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-13 11:38:56 +03:30
Fix access to change status of items
This commit is contained in:
@@ -139,8 +139,10 @@ class ItemItemBox extends StatelessWidget {
|
|||||||
// SizedBox(
|
// SizedBox(
|
||||||
// width: 5.0,
|
// width: 5.0,
|
||||||
// ),
|
// ),
|
||||||
|
if (userData['roles']?.contains('Admin') ||
|
||||||
|
(userData['roles']?.contains('Supervisor') &&
|
||||||
|
item!.packageId != null))
|
||||||
item?.status == "pending" || item?.status == "rejected"
|
item?.status == "pending" || item?.status == "rejected"
|
||||||
? userData['roles']?.contains('Admin') ?? false
|
|
||||||
? InkWell(
|
? InkWell(
|
||||||
customBorder: CircleBorder(),
|
customBorder: CircleBorder(),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
@@ -154,8 +156,7 @@ class ItemItemBox extends StatelessWidget {
|
|||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
Consumer<ItemProvider>(builder:
|
Consumer<ItemProvider>(builder:
|
||||||
(context, itemProvider, _) {
|
(context, itemProvider, _) {
|
||||||
return itemProvider
|
return itemProvider.isloadingButton
|
||||||
.isloadingButton
|
|
||||||
? CircularProgressIndicator(
|
? CircularProgressIndicator(
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
)
|
)
|
||||||
@@ -175,11 +176,9 @@ class ItemItemBox extends StatelessWidget {
|
|||||||
if (value) {
|
if (value) {
|
||||||
print('true');
|
print('true');
|
||||||
}
|
}
|
||||||
Navigator.of(
|
Navigator.of(context)
|
||||||
context)
|
|
||||||
.pop();
|
.pop();
|
||||||
Navigator.of(
|
Navigator.of(context)
|
||||||
context)
|
|
||||||
.popAndPushNamed(
|
.popAndPushNamed(
|
||||||
Routes
|
Routes
|
||||||
.itemResultScreen);
|
.itemResultScreen);
|
||||||
@@ -226,103 +225,6 @@ class ItemItemBox extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: userData['roles']?.contains('Supervisor')
|
|
||||||
? item!.packageId != null
|
|
||||||
? InkWell(
|
|
||||||
customBorder: CircleBorder(),
|
|
||||||
onTap: () {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: Text(
|
|
||||||
'Are you Confirm this item?',
|
|
||||||
),
|
|
||||||
actions: <Widget>[
|
|
||||||
Consumer<ItemProvider>(
|
|
||||||
builder: (context,
|
|
||||||
itemProvider, _) {
|
|
||||||
return itemProvider
|
|
||||||
.isloadingButton
|
|
||||||
? CircularProgressIndicator(
|
|
||||||
color:
|
|
||||||
Colors.black,
|
|
||||||
)
|
|
||||||
: TextButton(
|
|
||||||
onPressed:
|
|
||||||
() async {
|
|
||||||
itemProvider
|
|
||||||
.setLoadingButton();
|
|
||||||
await Provider.of<
|
|
||||||
ItemProvider>(
|
|
||||||
context,
|
|
||||||
listen:
|
|
||||||
false)
|
|
||||||
.changeStatus(
|
|
||||||
item!
|
|
||||||
.id,
|
|
||||||
"approved")
|
|
||||||
.then(
|
|
||||||
(value) {
|
|
||||||
if (value) {
|
|
||||||
print(
|
|
||||||
'true');
|
|
||||||
}
|
|
||||||
Navigator.of(
|
|
||||||
context)
|
|
||||||
.pop();
|
|
||||||
Navigator.of(
|
|
||||||
context)
|
|
||||||
.popAndPushNamed(
|
|
||||||
Routes.itemResultScreen);
|
|
||||||
Fluttertoast
|
|
||||||
.showToast(
|
|
||||||
msg:
|
|
||||||
"Item is Approved.",
|
|
||||||
toastLength:
|
|
||||||
Toast
|
|
||||||
.LENGTH_SHORT,
|
|
||||||
gravity:
|
|
||||||
ToastGravity
|
|
||||||
.BOTTOM,
|
|
||||||
);
|
|
||||||
itemProvider
|
|
||||||
.resetLoadingButton();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child:
|
|
||||||
Text('Yes'),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context)
|
|
||||||
.pop();
|
|
||||||
},
|
|
||||||
child: Text('No'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
padding: EdgeInsets.all(7),
|
|
||||||
width: 8 * _deviceBlockSize,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
color: kLightBlue,
|
|
||||||
),
|
|
||||||
child: Icon(
|
|
||||||
Icons.check,
|
|
||||||
size: 4 * _deviceBlockSize,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: Container()
|
|
||||||
: Container()
|
|
||||||
: InkWell(
|
: InkWell(
|
||||||
customBorder: CircleBorder(),
|
customBorder: CircleBorder(),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
@@ -330,11 +232,14 @@ class ItemItemBox extends StatelessWidget {
|
|||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: Text('Are you Reject this item?'),
|
title:
|
||||||
|
Text('Are you Reject this item?'),
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
Consumer<ItemProvider>(
|
Consumer<ItemProvider>(
|
||||||
builder: (context, itemProvider, _) {
|
builder:
|
||||||
return itemProvider.isloadingButton
|
(context, itemProvider, _) {
|
||||||
|
return itemProvider
|
||||||
|
.isloadingButton
|
||||||
? CircularProgressIndicator(
|
? CircularProgressIndicator(
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
)
|
)
|
||||||
@@ -354,9 +259,11 @@ class ItemItemBox extends StatelessWidget {
|
|||||||
if (value) {
|
if (value) {
|
||||||
print('true');
|
print('true');
|
||||||
}
|
}
|
||||||
Navigator.of(context)
|
Navigator.of(
|
||||||
|
context)
|
||||||
.pop();
|
.pop();
|
||||||
Navigator.of(context)
|
Navigator.of(
|
||||||
|
context)
|
||||||
.popAndPushNamed(
|
.popAndPushNamed(
|
||||||
Routes
|
Routes
|
||||||
.itemResultScreen);
|
.itemResultScreen);
|
||||||
@@ -403,6 +310,270 @@ class ItemItemBox extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
// item?.status == "pending" || item?.status == "rejected"
|
||||||
|
// ? userData['roles']?.contains('Admin') ?? false
|
||||||
|
// ? InkWell(
|
||||||
|
// customBorder: CircleBorder(),
|
||||||
|
// onTap: () {
|
||||||
|
// showDialog(
|
||||||
|
// context: context,
|
||||||
|
// builder: (context) {
|
||||||
|
// return AlertDialog(
|
||||||
|
// title: Text(
|
||||||
|
// 'Are you Confirm this item?',
|
||||||
|
// ),
|
||||||
|
// actions: <Widget>[
|
||||||
|
// Consumer<ItemProvider>(builder:
|
||||||
|
// (context, itemProvider, _) {
|
||||||
|
// return itemProvider
|
||||||
|
// .isloadingButton
|
||||||
|
// ? CircularProgressIndicator(
|
||||||
|
// color: Colors.black,
|
||||||
|
// )
|
||||||
|
// : TextButton(
|
||||||
|
// onPressed: () async {
|
||||||
|
// itemProvider
|
||||||
|
// .setLoadingButton();
|
||||||
|
// await Provider.of<
|
||||||
|
// ItemProvider>(
|
||||||
|
// context,
|
||||||
|
// listen: false)
|
||||||
|
// .changeStatus(
|
||||||
|
// item!.id,
|
||||||
|
// "approved")
|
||||||
|
// .then(
|
||||||
|
// (value) {
|
||||||
|
// if (value) {
|
||||||
|
// print('true');
|
||||||
|
// }
|
||||||
|
// Navigator.of(
|
||||||
|
// context)
|
||||||
|
// .pop();
|
||||||
|
// Navigator.of(
|
||||||
|
// context)
|
||||||
|
// .popAndPushNamed(
|
||||||
|
// Routes
|
||||||
|
// .itemResultScreen);
|
||||||
|
// Fluttertoast
|
||||||
|
// .showToast(
|
||||||
|
// msg:
|
||||||
|
// "Item is Approved.",
|
||||||
|
// toastLength: Toast
|
||||||
|
// .LENGTH_SHORT,
|
||||||
|
// gravity:
|
||||||
|
// ToastGravity
|
||||||
|
// .BOTTOM,
|
||||||
|
// );
|
||||||
|
// itemProvider
|
||||||
|
// .resetLoadingButton();
|
||||||
|
// },
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// child: Text('Yes'),
|
||||||
|
// );
|
||||||
|
// }),
|
||||||
|
// TextButton(
|
||||||
|
// onPressed: () {
|
||||||
|
// Navigator.of(context).pop();
|
||||||
|
// },
|
||||||
|
// child: Text('No'),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// child: Container(
|
||||||
|
// padding: EdgeInsets.all(7),
|
||||||
|
// width: 8 * _deviceBlockSize,
|
||||||
|
// decoration: BoxDecoration(
|
||||||
|
// shape: BoxShape.circle,
|
||||||
|
// color: kLightBlue,
|
||||||
|
// ),
|
||||||
|
// child: Icon(
|
||||||
|
// Icons.check,
|
||||||
|
// size: 4 * _deviceBlockSize,
|
||||||
|
// color: Colors.white,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// )
|
||||||
|
// : userData['roles']?.contains('Supervisor')
|
||||||
|
// ? item!.packageId != null
|
||||||
|
// ? InkWell(
|
||||||
|
// customBorder: CircleBorder(),
|
||||||
|
// onTap: () {
|
||||||
|
// showDialog(
|
||||||
|
// context: context,
|
||||||
|
// builder: (context) {
|
||||||
|
// return AlertDialog(
|
||||||
|
// title: Text(
|
||||||
|
// 'Are you Confirm this item?',
|
||||||
|
// ),
|
||||||
|
// actions: <Widget>[
|
||||||
|
// Consumer<ItemProvider>(
|
||||||
|
// builder: (context,
|
||||||
|
// itemProvider, _) {
|
||||||
|
// return itemProvider
|
||||||
|
// .isloadingButton
|
||||||
|
// ? CircularProgressIndicator(
|
||||||
|
// color:
|
||||||
|
// Colors.black,
|
||||||
|
// )
|
||||||
|
// : TextButton(
|
||||||
|
// onPressed:
|
||||||
|
// () async {
|
||||||
|
// itemProvider
|
||||||
|
// .setLoadingButton();
|
||||||
|
// await Provider.of<
|
||||||
|
// ItemProvider>(
|
||||||
|
// context,
|
||||||
|
// listen:
|
||||||
|
// false)
|
||||||
|
// .changeStatus(
|
||||||
|
// item!
|
||||||
|
// .id,
|
||||||
|
// "approved")
|
||||||
|
// .then(
|
||||||
|
// (value) {
|
||||||
|
// if (value) {
|
||||||
|
// print(
|
||||||
|
// 'true');
|
||||||
|
// }
|
||||||
|
// Navigator.of(
|
||||||
|
// context)
|
||||||
|
// .pop();
|
||||||
|
// Navigator.of(
|
||||||
|
// context)
|
||||||
|
// .popAndPushNamed(
|
||||||
|
// Routes.itemResultScreen);
|
||||||
|
// Fluttertoast
|
||||||
|
// .showToast(
|
||||||
|
// msg:
|
||||||
|
// "Item is Approved.",
|
||||||
|
// toastLength:
|
||||||
|
// Toast
|
||||||
|
// .LENGTH_SHORT,
|
||||||
|
// gravity:
|
||||||
|
// ToastGravity
|
||||||
|
// .BOTTOM,
|
||||||
|
// );
|
||||||
|
// itemProvider
|
||||||
|
// .resetLoadingButton();
|
||||||
|
// },
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// child:
|
||||||
|
// Text('Yes'),
|
||||||
|
// );
|
||||||
|
// }),
|
||||||
|
// TextButton(
|
||||||
|
// onPressed: () {
|
||||||
|
// Navigator.of(context)
|
||||||
|
// .pop();
|
||||||
|
// },
|
||||||
|
// child: Text('No'),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// child: Container(
|
||||||
|
// padding: EdgeInsets.all(7),
|
||||||
|
// width: 8 * _deviceBlockSize,
|
||||||
|
// decoration: BoxDecoration(
|
||||||
|
// shape: BoxShape.circle,
|
||||||
|
// color: kLightBlue,
|
||||||
|
// ),
|
||||||
|
// child: Icon(
|
||||||
|
// Icons.check,
|
||||||
|
// size: 4 * _deviceBlockSize,
|
||||||
|
// color: Colors.white,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// )
|
||||||
|
// : Container()
|
||||||
|
// : Container()
|
||||||
|
// : InkWell(
|
||||||
|
// customBorder: CircleBorder(),
|
||||||
|
// onTap: () {
|
||||||
|
// showDialog(
|
||||||
|
// context: context,
|
||||||
|
// builder: (context) {
|
||||||
|
// return AlertDialog(
|
||||||
|
// title: Text('Are you Reject this item?'),
|
||||||
|
// actions: <Widget>[
|
||||||
|
// Consumer<ItemProvider>(
|
||||||
|
// builder: (context, itemProvider, _) {
|
||||||
|
// return itemProvider.isloadingButton
|
||||||
|
// ? CircularProgressIndicator(
|
||||||
|
// color: Colors.black,
|
||||||
|
// )
|
||||||
|
// : TextButton(
|
||||||
|
// onPressed: () async {
|
||||||
|
// itemProvider
|
||||||
|
// .setLoadingButton();
|
||||||
|
// await Provider.of<
|
||||||
|
// ItemProvider>(
|
||||||
|
// context,
|
||||||
|
// listen: false)
|
||||||
|
// .changeStatus(
|
||||||
|
// item!.id,
|
||||||
|
// "rejected")
|
||||||
|
// .then(
|
||||||
|
// (value) {
|
||||||
|
// if (value) {
|
||||||
|
// print('true');
|
||||||
|
// }
|
||||||
|
// Navigator.of(context)
|
||||||
|
// .pop();
|
||||||
|
// Navigator.of(context)
|
||||||
|
// .popAndPushNamed(
|
||||||
|
// Routes
|
||||||
|
// .itemResultScreen);
|
||||||
|
// Fluttertoast
|
||||||
|
// .showToast(
|
||||||
|
// msg:
|
||||||
|
// "Item is rejected.",
|
||||||
|
// toastLength: Toast
|
||||||
|
// .LENGTH_SHORT,
|
||||||
|
// gravity:
|
||||||
|
// ToastGravity
|
||||||
|
// .BOTTOM,
|
||||||
|
// );
|
||||||
|
// itemProvider
|
||||||
|
// .resetLoadingButton();
|
||||||
|
// },
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// child: Text('Yes'),
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// TextButton(
|
||||||
|
// onPressed: () {
|
||||||
|
// Navigator.of(context).pop();
|
||||||
|
// },
|
||||||
|
// child: Text('No'),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// child: Container(
|
||||||
|
// padding: EdgeInsets.all(7),
|
||||||
|
// width: 8 * _deviceBlockSize,
|
||||||
|
// decoration: BoxDecoration(
|
||||||
|
// shape: BoxShape.circle,
|
||||||
|
// color: Colors.black),
|
||||||
|
// child: Icon(
|
||||||
|
// Icons.close,
|
||||||
|
// size: 4 * _deviceBlockSize,
|
||||||
|
// color: Colors.white,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 5.0,
|
width: 5.0,
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user