diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index ecedbdf..6821686 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -31,6 +31,7 @@ "viewAllServices": "عرض جميع الخدمات", "monthlyAttendance": "الحضور الشهري", "vacationRule": "حكم اجازة", + "vacationType": "نوع الاجازة", "startDateT": "تاريخ البدء", "endDateT": "تاريخ الانتهاء", "workFromHome": "العمل من المنزل", diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 32a5e43..03ac050 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -31,6 +31,7 @@ "viewAllServices": "View All Services", "monthlyAttendance": "Monthly Attendance", "vacationRule": "Vacation Rule", + "vacationType": "Vacation Type", "startDateT": "Start Date", "endDateT": "End Date", "workFromHome": "Work From Home", diff --git a/lib/api/vacation_rule_api_client.dart b/lib/api/vacation_rule_api_client.dart index d144174..746116a 100644 --- a/lib/api/vacation_rule_api_client.dart +++ b/lib/api/vacation_rule_api_client.dart @@ -2,10 +2,10 @@ import 'package:mohem_flutter_app/api/api_client.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/consts.dart'; import 'package:mohem_flutter_app/models/generic_response_model.dart'; +import 'package:mohem_flutter_app/models/vacation_rule/create_vacation_rule_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/get_item_type_notifications_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/get_notification_reassign_mode_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/get_vacation_rules_list_model.dart'; -import 'package:mohem_flutter_app/models/vacation_rule/respond_attributes_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/vr_item_types_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/wf_look_up_list_model.dart'; @@ -56,13 +56,33 @@ class VacationRuleApiClient { }, url, postParams); } - Future> getRespondAttributes(String pItemType, String pNotificationName) async { + Future getRespondAttributes(String pItemType, String pNotificationName) async { String url = "${ApiConsts.erpRest}GET_RESPOND_ATTRIBUTES"; Map postParams = {"P_ITEM_TYPE": pItemType, "P_NOTIFICATION_NAME": pNotificationName}; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject((json) { GenericResponseModel? responseData = GenericResponseModel.fromJson(json); - return responseData.respondAttributesList ?? []; + return responseData; + }, url, postParams); + } + + Future createVacationRule(String pBeginDate, String pEndDate, String pItemType, String pNotificationName, String pMessage, String pAction, String pReplacementUserName, + List> respondAttributeList) async { + String url = "${ApiConsts.erpRest}CREATE_VACATION_RULE"; + Map postParams = { + "P_ITEM_TYPE": pItemType, + "P_NOTIFICATION_NAME": pNotificationName, + "P_BEGIN_DATE": pBeginDate, + "P_END_DATE": pEndDate, + "P_MESSAGE": pMessage, + "P_REPLACEMENT_USER_NAME": pReplacementUserName, + "P_ACTION": pAction, + "RespondAttributeList": respondAttributeList, + }; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel? responseData = GenericResponseModel.fromJson(json); + return responseData.createVacationRuleList; }, url, postParams); } diff --git a/lib/extensions/widget_extensions.dart b/lib/extensions/widget_extensions.dart index 247cde5..c9a4b49 100644 --- a/lib/extensions/widget_extensions.dart +++ b/lib/extensions/widget_extensions.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; +import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/extensions/int_extensions.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:shimmer/shimmer.dart'; @@ -67,4 +68,28 @@ extension WidgetExtensions on Widget { ), ); } + + Widget objectContainerBorderView({String title = "", String note = ""}) { + return Container( + padding: const EdgeInsets.only(top: 15, bottom: 15, left: 14, right: 14), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + border: Border.all( + color: MyColors.lightGreyEFColor, + width: 1, + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + if (title.isNotEmpty) title.toText16(), + if (title.isNotEmpty) 12.height, + this, + if (note.isNotEmpty) note.toText11(), + ], + ), + ); + } } diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index eac063d..c37b5c8 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -32,6 +32,7 @@ abstract class LocaleKeys { static const viewAllServices = 'viewAllServices'; static const monthlyAttendance = 'monthlyAttendance'; static const vacationRule = 'vacationRule'; + static const vacationType = 'vacationType'; static const startDateT = 'startDateT'; static const endDateT = 'endDateT'; static const workFromHome = 'workFromHome'; diff --git a/lib/models/generic_response_model.dart b/lib/models/generic_response_model.dart index 1260d80..e288d38 100644 --- a/lib/models/generic_response_model.dart +++ b/lib/models/generic_response_model.dart @@ -55,18 +55,19 @@ import 'package:mohem_flutter_app/models/privilege_list_model.dart'; import 'package:mohem_flutter_app/models/profile/basic_details_cols_structions.dart'; import 'package:mohem_flutter_app/models/profile/basic_details_dff_structure.dart'; import 'package:mohem_flutter_app/models/profile/get_address_dff_structure_list.dart'; +import 'package:mohem_flutter_app/models/profile/get_contact_clos_structure_list.dart'; +import 'package:mohem_flutter_app/models/profile/get_contact_details_list.dart'; import 'package:mohem_flutter_app/models/profile/get_countries_list_model.dart'; import 'package:mohem_flutter_app/models/profile/phone_number_types_model.dart'; import 'package:mohem_flutter_app/models/profile/start_address_approval_process_model.dart'; import 'package:mohem_flutter_app/models/profile/submit_address_transaction.dart'; -import 'package:mohem_flutter_app/models/profile/get_contact_clos_structure_list.dart'; -import 'package:mohem_flutter_app/models/profile/get_contact_details_list.dart'; import 'package:mohem_flutter_app/models/profile/submit_basic_details_transaction_model.dart'; import 'package:mohem_flutter_app/models/profile/submit_contact_transaction_list_model.dart'; import 'package:mohem_flutter_app/models/start_eit_approval_process_model.dart'; import 'package:mohem_flutter_app/models/start_phone_approval_process_model.dart'; import 'package:mohem_flutter_app/models/submit_eit_transaction_list_model.dart'; import 'package:mohem_flutter_app/models/subordinates_on_leaves_model.dart'; +import 'package:mohem_flutter_app/models/vacation_rule/create_vacation_rule_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/get_item_type_notifications_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/get_notification_reassign_mode_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/get_vacation_rules_list_model.dart'; @@ -124,7 +125,7 @@ class GenericResponseModel { String? companyImageURL; String? companyMainCompany; List? countryList; - String? createVacationRuleList; + CreateVacationRuleList? createVacationRuleList; String? deleteAttachmentList; String? deleteVacationRuleList; String? disableSessionList; @@ -662,7 +663,8 @@ class GenericResponseModel { countryList!.add(new GetCountriesListModel.fromJson(v)); }); } - createVacationRuleList = json['CreateVacationRuleList']; + + createVacationRuleList = json['CreateVacationRuleList'] != null ? new CreateVacationRuleList.fromJson(json['CreateVacationRuleList']) : null; deleteAttachmentList = json['DeleteAttachmentList']; deleteVacationRuleList = json['DeleteVacationRuleList']; disableSessionList = json['DisableSessionList']; @@ -1299,7 +1301,10 @@ class GenericResponseModel { if (this.countryList != null) { data['CountryList'] = this.countryList!.map((v) => v.toJson()).toList(); } - data['CreateVacationRuleList'] = this.createVacationRuleList; + + if (this.createVacationRuleList != null) { + data['CreateVacationRuleList'] = this.createVacationRuleList!.toJson(); + } data['DeleteAttachmentList'] = this.deleteAttachmentList; data['DeleteVacationRuleList'] = this.deleteVacationRuleList; data['DisableSessionList'] = this.disableSessionList; diff --git a/lib/models/vacation_rule/create_vacation_rule_list_model.dart b/lib/models/vacation_rule/create_vacation_rule_list_model.dart new file mode 100644 index 0000000..5fd489a --- /dev/null +++ b/lib/models/vacation_rule/create_vacation_rule_list_model.dart @@ -0,0 +1,18 @@ +class CreateVacationRuleList { + String? pRETURNMSG; + String? pRETURNSTATUS; + + CreateVacationRuleList({this.pRETURNMSG, this.pRETURNSTATUS}); + + CreateVacationRuleList.fromJson(Map json) { + pRETURNMSG = json['P_RETURN_MSG']; + pRETURNSTATUS = json['P_RETURN_STATUS']; + } + + Map toJson() { + final Map data = new Map(); + data['P_RETURN_MSG'] = this.pRETURNMSG; + data['P_RETURN_STATUS'] = this.pRETURNSTATUS; + return data; + } +} \ No newline at end of file diff --git a/lib/ui/attendance/add_vacation_rule_screen.dart b/lib/ui/attendance/add_vacation_rule_screen.dart index a76e65a..51bf0d7 100644 --- a/lib/ui/attendance/add_vacation_rule_screen.dart +++ b/lib/ui/attendance/add_vacation_rule_screen.dart @@ -4,10 +4,15 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/api/vacation_rule_api_client.dart'; +import 'package:mohem_flutter_app/classes/colors.dart'; +import 'package:mohem_flutter_app/classes/date_uitl.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/extensions/int_extensions.dart'; +import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; +import 'package:mohem_flutter_app/models/generic_response_model.dart'; +import 'package:mohem_flutter_app/models/vacation_rule/create_vacation_rule_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/get_item_type_notifications_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/get_notification_reassign_mode_list_model.dart'; import 'package:mohem_flutter_app/models/vacation_rule/respond_attributes_list_model.dart'; @@ -18,6 +23,7 @@ import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; import 'package:mohem_flutter_app/widgets/bottom_sheet.dart'; import 'package:mohem_flutter_app/widgets/bottom_sheets/search_employee_bottom_sheet.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart'; +import 'package:mohem_flutter_app/widgets/dialogs/confirm_dialog.dart'; import 'package:mohem_flutter_app/widgets/dynamic_forms/dynamic_textfield_widget.dart'; import 'package:mohem_flutter_app/widgets/item_detail_view_widget.dart'; @@ -41,11 +47,18 @@ class _AddVacationRuleScreenState extends State { GetNotificationReassignModeList? notificationReassignMode; List? respondAttributesList; + List? roleList = []; List? wfLookupList; ReplacementList? selectedReplacementEmployee; + String varcharInput = ""; + String numInput = ""; + DateTime? dateInput; + WFLookUpList? wfLook; + int currentStage = 0; + String message = ""; DateTime startTime = DateTime.now(); DateTime? endTime; @@ -89,14 +102,23 @@ class _AddVacationRuleScreenState extends State { List results = await Future.wait([ VacationRuleApiClient().getNotificationReassignMode(), VacationRuleApiClient().getRespondAttributes(selectedItemType!.iTEMTYPE!, selectedItemTypeNotification!.nOTIFICATIONNAME!), - // VacationRuleApiClient().getWfLookup(P_LOOKUP_TYPE), ]); notificationReassignModeList = results[0]; + GenericResponseModel respondAttribute = results[1]; + respondAttributesList = respondAttribute.respondAttributesList; + if (respondAttributesList?.isNotEmpty ?? false) { + int index = respondAttributesList!.indexWhere((element) => element.aTTRIBUTETYPE == "LOOKUP"); + if (index > -1) { + wfLookupList = await VacationRuleApiClient().getWfLookup(respondAttributesList![index].aTTRIBUTEFORMAT!); + } + } + roleList = respondAttribute.respondRolesList; + if (selectedItemType!.iTEMTYPE != "*") { notificationReassignModeList!.add( GetNotificationReassignModeList( rADIOBUTTONLABEL: "Deliver notifications to me regardless of any general rules", - rADIOBUTTONACTION: "deliver_notification", + rADIOBUTTONACTION: "DELIVER", // ionic: DELIVER rADIOBUTTONSEQ: 1, ), ); @@ -105,13 +127,25 @@ class _AddVacationRuleScreenState extends State { notificationReassignModeList!.add( GetNotificationReassignModeList( rADIOBUTTONLABEL: "Close", - rADIOBUTTONACTION: "close", + rADIOBUTTONACTION: "CLOSE", // ionic: CLOSE + rADIOBUTTONSEQ: 1, + ), + ); + } + if (respondAttributesList!.isNotEmpty && !(selectedItemTypeNotification!.fYIFLAG == "Y")) { + notificationReassignModeList!.add( + GetNotificationReassignModeList( + rADIOBUTTONLABEL: "Respond", + rADIOBUTTONACTION: "RESPOND", // ionic: RESPOND rADIOBUTTONSEQ: 1, ), ); } - respondAttributesList = results[1]; - // wfLookupList = results[2]; + + if (notificationReassignModeList!.isNotEmpty) { + notificationReassignMode = notificationReassignModeList!.first; + } + Utils.hideLoading(context); currentStage = 3; setState(() {}); @@ -121,6 +155,111 @@ class _AddVacationRuleScreenState extends State { } } + List getDynamicWidgetList() { + List respondAttributesWidgetList = []; + for (int i = 0; i < respondAttributesList!.length; i++) { + if (respondAttributesList![i].aTTRIBUTETYPE == "VARCHAR2") { + respondAttributesWidgetList.add( + DynamicTextFieldWidget(respondAttributesList![i].aTTRIBUTEDISPLAYNAME!, respondAttributesList![i].aTTRIBUTENAME!, onChange: (message) { + varcharInput = message; + }).paddingOnly(bottom: 12), + ); + } else if (respondAttributesList![i].aTTRIBUTETYPE == "LOOKUP") { + respondAttributesWidgetList.add( + PopupMenuButton( + child: DynamicTextFieldWidget( + respondAttributesList![i].aTTRIBUTEDISPLAYNAME!, + wfLook?.lOOKUPMEANING ?? respondAttributesList![i].aTTRIBUTENAME!, + isEnable: false, + isPopup: true, + ).paddingOnly(bottom: 12), + itemBuilder: (_) => >[ + for (int i = 0; i < wfLookupList!.length; i++) PopupMenuItem(value: i, child: Text(wfLookupList![i].lOOKUPMEANING!)), + ], + onSelected: (int popupIndex) { + wfLook = wfLookupList![popupIndex]; + setState(() {}); + }, + ), + ); + } else if (respondAttributesList![i].aTTRIBUTETYPE == "DATE") { + respondAttributesWidgetList.add(DynamicTextFieldWidget( + respondAttributesList![i].aTTRIBUTEDISPLAYNAME!, + dateInput?.toString() ?? respondAttributesList![i].aTTRIBUTENAME!, + suffixIconData: Icons.calendar_today, + isEnable: false, + onTap: () async { + dateInput = await _selectDate(context); + setState(() {}); + }, + ).paddingOnly(bottom: 12)); + } else if (respondAttributesList![i].aTTRIBUTETYPE == "NUMBER") { + respondAttributesWidgetList.add( + DynamicTextFieldWidget( + respondAttributesList![i].aTTRIBUTEDISPLAYNAME!, + respondAttributesList![i].aTTRIBUTENAME!, + isInputTypeNum: true, + onChange: (input) { + numInput = input; + }, + ), + ); + } + } + return respondAttributesWidgetList; + } + + void createVacationRule(List> respondAttributeList) async { + try { + Utils.showLoading(context); + CreateVacationRuleList? createVacationRuleList = await VacationRuleApiClient().createVacationRule(DateUtil.convertDateToStringLocation(startTime), DateUtil.convertDateToStringLocation(endTime!), + selectedItemType!.iTEMTYPE!, selectedItemTypeNotification!.nOTIFICATIONNAME!, message, getPAction(), selectedReplacementEmployee!.userName!, respondAttributeList); + Utils.hideLoading(context); + Utils.showToast("Vacation rule added."); + Navigator.popUntil(context, ModalRoute.withName('AppRoutes.dashboard')); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + String getPAction() { + String pAction = ""; + switch (notificationReassignMode?.rADIOBUTTONACTION ?? "") { + case 'DELEGATE': + { + pAction = "FORWARD"; + break; + } + case 'RESPOND': + { + pAction = "RESPOND"; + break; + } + case 'CLOSE': + { + pAction = "RESPOND"; + break; + } + case 'DELIVER': + { + pAction = "NOOP"; + break; + } + case 'TRANSFER': + { + pAction = "TRANSFER"; + break; + } + default: + { + pAction = ""; + break; + } + } + return pAction; + } + @override void dispose() { super.dispose(); @@ -132,7 +271,7 @@ class _AddVacationRuleScreenState extends State { backgroundColor: Colors.white, appBar: AppBarWidget( context, - title: LocaleKeys.vacationRule.tr(), // todo @Sikander change title to 'Vacation Type' + title: LocaleKeys.vacationType.tr(), ), body: vrItemTypesList == null ? const SizedBox() @@ -233,46 +372,75 @@ class _AddVacationRuleScreenState extends State { "Message", "Write a message", lines: 2, - onChange: (message) {}, - // isEnable: false, - // isPopup: true, - ).paddingOnly(bottom: 12), - PopupMenuButton( - child: DynamicTextFieldWidget( - "Notification Reassign", - notificationReassignMode == null ? "Select Notification" : notificationReassignMode!.rADIOBUTTONLABEL ?? "", - isEnable: false, - isPopup: true, - ).paddingOnly(bottom: 12), - itemBuilder: (_) => >[ - for (int i = 0; i < notificationReassignModeList!.length; i++) PopupMenuItem(value: i, child: Text(notificationReassignModeList![i].rADIOBUTTONLABEL!)), - ], - onSelected: (int popupIndex) { - if (notificationReassignMode == notificationReassignModeList![popupIndex]) { - return; - } - notificationReassignMode = notificationReassignModeList![popupIndex]; - setState(() {}); - }), - DynamicTextFieldWidget( - "Select Employee", - selectedReplacementEmployee == null ? "Search employee for replacement" : selectedReplacementEmployee!.employeeDisplayName ?? "", - isEnable: false, - onTap: () { - showMyBottomSheet( - context, - child: SearchEmployeeBottomSheet( - title: "Search for Employee", - apiMode: "DELEGATE", - onSelectEmployee: (_selectedEmployee) { - // Navigator.pop(context); - selectedReplacementEmployee = _selectedEmployee; - setState(() {}); - }, - ), - ); + onChange: (message) { + this.message = message; }, ).paddingOnly(bottom: 12), + ListView.separated( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + padding: EdgeInsets.zero, + itemBuilder: (cxt, index) { + return Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + width: 20, + height: 20, + decoration: BoxDecoration( + color: Colors.transparent, + border: Border.all(color: MyColors.borderColor, width: 1), + borderRadius: const BorderRadius.all(Radius.circular(100)), + ), + padding: const EdgeInsets.all(4), + child: Container( + width: double.infinity, + height: double.infinity, + decoration: BoxDecoration( + color: notificationReassignModeList![index] == notificationReassignMode ? MyColors.grey3AColor : Colors.transparent, + borderRadius: BorderRadius.all(const Radius.circular(100)), + ), + ), + ), + 9.width, + (notificationReassignModeList![index].rADIOBUTTONLABEL!).toText12(color: MyColors.grey57Color).expanded + ], + ).onPress(() { + if (notificationReassignMode == notificationReassignModeList![index]) { + return; + } + notificationReassignMode = notificationReassignModeList![index]; + setState(() {}); + }); + }, + separatorBuilder: (cxt, index) => 12.height, + itemCount: notificationReassignModeList!.length) + .objectContainerBorderView(title: "Notification Reassign"), + 12.height, + if (respondAttributesList?.isNotEmpty ?? false) ...getDynamicWidgetList(), + if (roleList!.isNotEmpty && notificationReassignMode?.rADIOBUTTONACTION == 'RESPOND' || + // if (notificationReassignMode?.rADIOBUTTONACTION == 'RESPOND' || + (notificationReassignMode?.rADIOBUTTONACTION == 'DELEGATE') || + (notificationReassignMode?.rADIOBUTTONACTION == 'TRANSFER')) + DynamicTextFieldWidget( + "Select Employee", + selectedReplacementEmployee == null ? "Search employee for replacement" : selectedReplacementEmployee!.employeeDisplayName ?? "", + isEnable: false, + onTap: () { + showMyBottomSheet( + context, + child: SearchEmployeeBottomSheet( + title: "Search for Employee", + apiMode: "DELEGATE", + onSelectEmployee: (_selectedEmployee) { + // Navigator.pop(context); + selectedReplacementEmployee = _selectedEmployee; + setState(() {}); + }, + ), + ); + }, + ).paddingOnly(bottom: 12), ], ).objectContainerView(title: "Step 3") ] @@ -283,11 +451,54 @@ class _AddVacationRuleScreenState extends State { currentStage != 3 ? null : () { - if (currentStage == 1) { - getItemTypeNotificationsList(); - } else if (currentStage == 2) { - callCombineApis(); + if (endTime == null) { + Utils.showToast("Please specify End Time"); + return; + } else if (notificationReassignMode == null) { + Utils.showToast("Please select notification reassign"); + return; + } else if (selectedReplacementEmployee == null) { + Utils.showToast("Please select employee for replacement"); + return; } + + List> list = []; + + if (respondAttributesList?.isNotEmpty ?? false) { + for (int i = 0; i < respondAttributesList!.length; i++) { + if (respondAttributesList![i].aTTRIBUTETYPE == "VARCHAR2") { + list.add({"ATTRIBUTE_NAME": respondAttributesList![i].aTTRIBUTENAME, "ATTRIBUTE_TEXT_VALUE": varcharInput}); + } + if (respondAttributesList![i].aTTRIBUTETYPE == "LOOKUP") { + if (wfLook == null) { + Utils.showToast('Please select action'); + break; + } + list.add({"ATTRIBUTE_NAME": respondAttributesList![i].aTTRIBUTENAME, "ATTRIBUTE_TEXT_VALUE": wfLook!.lOOKUPCODE}); + } + if (respondAttributesList![i].aTTRIBUTETYPE == "DATE") { + if (dateInput == null) { + Utils.showToast('Please select date'); + break; + } + list.add({"ATTRIBUTE_NAME": respondAttributesList![i].aTTRIBUTENAME, "ATTRIBUTE_TEXT_VALUE": DateUtil.convertDateToStringLocation(dateInput!)}); + } + if (respondAttributesList![i].aTTRIBUTETYPE == "NUMBER") { + list.add({"ATTRIBUTE_NAME": respondAttributesList![i].aTTRIBUTENAME, "ATTRIBUTE_TEXT_VALUE": numInput}); + } + } + } + + showDialog( + context: context, + builder: (cxt) => ConfirmDialog( + message: LocaleKeys.areYouSureYouWantToSubmit.tr(), + onTap: () { + Navigator.pop(context); + createVacationRule(list); + }, + ), + ); }, ).insideContainer, ], @@ -338,4 +549,35 @@ class _AddVacationRuleScreenState extends State { if (_time == null) return "Select date and time"; return DateFormat("MM/dd/yyyy hh:mm:ss a").format(_time); } + + Future _selectDate(BuildContext context) async { + DateTime time = dateInput ?? DateTime.now(); + if (Platform.isIOS) { + await showCupertinoModalPopup( + context: context, + builder: (cxt) => Container( + height: 250, + color: Colors.white, + child: CupertinoDatePicker( + backgroundColor: Colors.white, + mode: CupertinoDatePickerMode.date, + onDateTimeChanged: (value) { + if (value != null && value != dateInput) { + time = value; + } + }, + initialDateTime: dateInput, + ), + ), + ); + } else { + final DateTime? picked = + await showDatePicker(context: context, initialDate: dateInput ?? DateTime.now(), initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101)); + if (picked != null && picked != dateInput) { + time = picked; + } + } + time = DateTime(time.year, time.month, time.day); + return time; + } } diff --git a/lib/ui/attendance/vacation_rule_screen.dart b/lib/ui/attendance/vacation_rule_screen.dart index a2aa5df..5598e05 100644 --- a/lib/ui/attendance/vacation_rule_screen.dart +++ b/lib/ui/attendance/vacation_rule_screen.dart @@ -140,7 +140,7 @@ class _VacationRuleScreenState extends State { } String getParsedTime(String time) { - DateTime date = DateFormat("mm/dd/yyyy").parse(time); + DateTime date = DateFormat("MM/dd/yyyy").parse(time); return DateFormat("d MMM yyyy").format(date); } } diff --git a/lib/widgets/dialogs/confirm_dialog.dart b/lib/widgets/dialogs/confirm_dialog.dart index 7264a9b..4c94340 100644 --- a/lib/widgets/dialogs/confirm_dialog.dart +++ b/lib/widgets/dialogs/confirm_dialog.dart @@ -1,25 +1,28 @@ import 'package:easy_localization/src/public_ext.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:mohem_flutter_app/classes/colors.dart'; +import 'package:mohem_flutter_app/extensions/int_extensions.dart'; +import 'package:mohem_flutter_app/extensions/string_extensions.dart'; +import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart'; class ConfirmDialog extends StatelessWidget { final String? title; - final String? message; + final String message; final String? okTitle; final VoidCallback? onTap; - const ConfirmDialog({Key? key, this.title, @required this.message, this.okTitle, this.onTap}) : super(key: key); + const ConfirmDialog({Key? key, this.title, required this.message, this.okTitle, this.onTap}) : super(key: key); @override Widget build(BuildContext context) { return Dialog( backgroundColor: Colors.white, - shape: RoundedRectangleBorder(), - insetPadding: EdgeInsets.only(left: 21, right: 21), + shape: const RoundedRectangleBorder(), + insetPadding: const EdgeInsets.only(left: 21, right: 21), child: Padding( - padding: EdgeInsets.only(left: 20, right: 20, top: 18, bottom: 28), + padding: const EdgeInsets.only(left: 20, right: 20, top: 18, bottom: 28), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, @@ -28,33 +31,27 @@ class ConfirmDialog extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( - child: Padding( - padding: const EdgeInsets.only(top: 16.0), - child: Text( - title ?? LocaleKeys.confirm.tr(), - style: TextStyle(fontSize: 24, fontWeight: FontWeight.w600, color: Color(0xff2B353E), height: 35 / 24, letterSpacing: -0.96), - ), - ), + child: Text( + title ?? LocaleKeys.confirm.tr(), + style: const TextStyle(fontSize: 24, fontWeight: FontWeight.w600, color: MyColors.darkTextColor, height: 35 / 24, letterSpacing: -0.96), + ).paddingOnly(top: 16), ), IconButton( padding: EdgeInsets.zero, - icon: Icon(Icons.close), - color: Color(0xff2B353E), - constraints: BoxConstraints(), + icon: const Icon(Icons.close), + color: MyColors.darkTextColor, + constraints: const BoxConstraints(), onPressed: () { Navigator.pop(context); }, ) ], ), - Text( - message ?? "", - style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff808080), letterSpacing: -0.48), - ), - SizedBox(height: 28), + message.toText16(color: MyColors.lightGrayColor), + 28.height, DefaultButton( okTitle ?? LocaleKeys.ok.tr(), - onTap == null ? () => Navigator.pop(context) : onTap, + onTap ?? () => Navigator.pop(context), textColor: Colors.white, //color: Ap.green, ),