|
|
|
|
@ -7,6 +7,7 @@ import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:test_sa/helper/utils.dart';
|
|
|
|
|
import 'package:test_sa/models/enums/demo_request_step.dart';
|
|
|
|
|
import 'package:test_sa/models/helper_data_models/workorder/work_order_helper_models.dart';
|
|
|
|
|
import 'package:test_sa/models/module_permissions_model.dart';
|
|
|
|
|
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
|
|
|
|
|
import 'package:test_sa/modules/demo_module/demo_extension_bottom_sheet.dart';
|
|
|
|
|
import 'package:test_sa/modules/demo_module/models/demo_request_model.dart';
|
|
|
|
|
@ -29,8 +30,9 @@ import 'models/demo_attachment_model.dart';
|
|
|
|
|
class DemoDetailViewPage extends StatefulWidget {
|
|
|
|
|
static const String id = "/demo-detail-page";
|
|
|
|
|
final int demoId;
|
|
|
|
|
final int moduleId;
|
|
|
|
|
|
|
|
|
|
DemoDetailViewPage({Key? key, required this.demoId}) : super(key: key);
|
|
|
|
|
DemoDetailViewPage({Key? key, required this.demoId, required this.moduleId}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_DemoDetailViewPageState createState() {
|
|
|
|
|
@ -48,11 +50,12 @@ class _DemoDetailViewPageState extends State<DemoDetailViewPage> {
|
|
|
|
|
|
|
|
|
|
//Todo need to check about attachments.
|
|
|
|
|
|
|
|
|
|
// bool loading = false;
|
|
|
|
|
ModulesPermissionsModel? modelPermission;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
demoProvider = Provider.of<DemoProvider>(context, listen: false);
|
|
|
|
|
modelPermission = context.userProvider.currentModelPermission(widget.moduleId);
|
|
|
|
|
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
|
// getDetailsById();
|
|
|
|
|
// });
|
|
|
|
|
@ -143,43 +146,44 @@ class _DemoDetailViewPageState extends State<DemoDetailViewPage> {
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(context, padding: 12),
|
|
|
|
|
).expanded,
|
|
|
|
|
if (context.userProvider.isNurse && context.settingProvider.isUserFlowMedical && (demoData.status!.value == 2))
|
|
|
|
|
FooterActionButton.footerContainer(
|
|
|
|
|
context: context,
|
|
|
|
|
child: AppFilledButton(
|
|
|
|
|
label: context.translation.cancel,
|
|
|
|
|
buttonColor: AppColor.white60,
|
|
|
|
|
textColor: AppColor.black10,
|
|
|
|
|
loading: false,
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (BuildContext cxt) => AcknowledgeWorkDialog(
|
|
|
|
|
message: "Are you sure, you want to cancel request?",
|
|
|
|
|
confirmButtonText: 'Confirm',
|
|
|
|
|
cancelButtonText: 'Cancel',
|
|
|
|
|
onSave: () async {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
DemoProvider demoProvider = Provider.of<DemoProvider>(context, listen: false);
|
|
|
|
|
bool isSuccess = await demoProvider.cancelRequest(demoData.id!);
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
if (isSuccess) {
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onDiscard: () {},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
else
|
|
|
|
|
FooterActionButton.demoRequestDetailsFooterWidget(
|
|
|
|
|
demoRequestStage: demoData.status!.demoRequestStepEnum!,
|
|
|
|
|
dataModel: demoData,
|
|
|
|
|
status: demoData.status!,
|
|
|
|
|
if (modelPermission?.canEdit ?? false)
|
|
|
|
|
if (context.userProvider.isNurse && context.settingProvider.isUserFlowMedical && (demoData.status!.value == 2))
|
|
|
|
|
FooterActionButton.footerContainer(
|
|
|
|
|
context: context,
|
|
|
|
|
refreshData: () => setState(() {})).toShadowContainer(context, padding: 0, showShadow: false, borderRadius: 0),
|
|
|
|
|
child: AppFilledButton(
|
|
|
|
|
label: context.translation.cancel,
|
|
|
|
|
buttonColor: AppColor.white60,
|
|
|
|
|
textColor: AppColor.black10,
|
|
|
|
|
loading: false,
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (BuildContext cxt) => AcknowledgeWorkDialog(
|
|
|
|
|
message: "Are you sure, you want to cancel request?",
|
|
|
|
|
confirmButtonText: 'Confirm',
|
|
|
|
|
cancelButtonText: 'Cancel',
|
|
|
|
|
onSave: () async {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
DemoProvider demoProvider = Provider.of<DemoProvider>(context, listen: false);
|
|
|
|
|
bool isSuccess = await demoProvider.cancelRequest(demoData.id!);
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
if (isSuccess) {
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onDiscard: () {},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
else
|
|
|
|
|
FooterActionButton.demoRequestDetailsFooterWidget(
|
|
|
|
|
demoRequestStage: demoData.status!.demoRequestStepEnum!,
|
|
|
|
|
dataModel: demoData,
|
|
|
|
|
status: demoData.status!,
|
|
|
|
|
context: context,
|
|
|
|
|
refreshData: () => setState(() {})).toShadowContainer(context, padding: 0, showShadow: false, borderRadius: 0),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}));
|
|
|
|
|
|