|
|
|
|
@ -7,6 +7,7 @@ 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/config/routes.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';
|
|
|
|
|
@ -117,7 +118,7 @@ class _AddVacationRuleScreenState extends State<AddVacationRuleScreen> {
|
|
|
|
|
if (selectedItemType!.iTEMTYPE != "*") {
|
|
|
|
|
notificationReassignModeList!.add(
|
|
|
|
|
GetNotificationReassignModeList(
|
|
|
|
|
rADIOBUTTONLABEL: "Deliver notifications to me regardless of any general rules",
|
|
|
|
|
rADIOBUTTONLABEL: LocaleKeys.deliverNotificationToMeRegardless.tr(),
|
|
|
|
|
rADIOBUTTONACTION: "DELIVER", // ionic: DELIVER
|
|
|
|
|
rADIOBUTTONSEQ: 1,
|
|
|
|
|
),
|
|
|
|
|
@ -126,7 +127,7 @@ class _AddVacationRuleScreenState extends State<AddVacationRuleScreen> {
|
|
|
|
|
if (selectedItemTypeNotification!.fYIFLAG == "Y") {
|
|
|
|
|
notificationReassignModeList!.add(
|
|
|
|
|
GetNotificationReassignModeList(
|
|
|
|
|
rADIOBUTTONLABEL: "Close",
|
|
|
|
|
rADIOBUTTONLABEL: LocaleKeys.close.tr(),
|
|
|
|
|
rADIOBUTTONACTION: "CLOSE", // ionic: CLOSE
|
|
|
|
|
rADIOBUTTONSEQ: 1,
|
|
|
|
|
),
|
|
|
|
|
@ -135,7 +136,7 @@ class _AddVacationRuleScreenState extends State<AddVacationRuleScreen> {
|
|
|
|
|
if (respondAttributesList!.isNotEmpty && !(selectedItemTypeNotification!.fYIFLAG == "Y")) {
|
|
|
|
|
notificationReassignModeList!.add(
|
|
|
|
|
GetNotificationReassignModeList(
|
|
|
|
|
rADIOBUTTONLABEL: "Respond",
|
|
|
|
|
rADIOBUTTONLABEL: LocaleKeys.respond.tr(),
|
|
|
|
|
rADIOBUTTONACTION: "RESPOND", // ionic: RESPOND
|
|
|
|
|
rADIOBUTTONSEQ: 1,
|
|
|
|
|
),
|
|
|
|
|
@ -215,8 +216,8 @@ class _AddVacationRuleScreenState extends State<AddVacationRuleScreen> {
|
|
|
|
|
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'));
|
|
|
|
|
Utils.showToast("Vacation rule added");
|
|
|
|
|
Navigator.popUntil(context, ModalRoute.withName(AppRoutes.dashboard));
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
Utils.handleException(ex, context, null);
|
|
|
|
|
@ -287,7 +288,7 @@ class _AddVacationRuleScreenState extends State<AddVacationRuleScreen> {
|
|
|
|
|
PopupMenuButton(
|
|
|
|
|
child: DynamicTextFieldWidget(
|
|
|
|
|
LocaleKeys.itemType.tr(),
|
|
|
|
|
selectedItemType == null ? "Select Type" : selectedItemType!.iTEMTYPEDISPLAYNAME!,
|
|
|
|
|
selectedItemType == null ? LocaleKeys.selectType.tr() : selectedItemType!.iTEMTYPEDISPLAYNAME!,
|
|
|
|
|
isEnable: false,
|
|
|
|
|
isPopup: true,
|
|
|
|
|
).paddingOnly(bottom: 12),
|
|
|
|
|
@ -310,13 +311,13 @@ class _AddVacationRuleScreenState extends State<AddVacationRuleScreen> {
|
|
|
|
|
notificationReassignMode = null;
|
|
|
|
|
getItemTypeNotificationsList();
|
|
|
|
|
}
|
|
|
|
|
}).objectContainerView(title: "Apply for Vacation Rule\nStep 1", note: "*If All is selected, you will skip to step 3"),
|
|
|
|
|
}).objectContainerView(title: "${LocaleKeys.applyForVacationRule.tr()}\n${LocaleKeys.step1.tr()}", note: LocaleKeys.ifAllSelectedYouWillSkip.tr()),
|
|
|
|
|
if ((itemTypeNotificationsList ?? []).isNotEmpty) ...[
|
|
|
|
|
12.height,
|
|
|
|
|
PopupMenuButton(
|
|
|
|
|
child: DynamicTextFieldWidget(
|
|
|
|
|
"Notification",
|
|
|
|
|
selectedItemTypeNotification == null ? "Select Notification" : selectedItemTypeNotification!.nOTIFICATIONDISPLAYNAME!,
|
|
|
|
|
selectedItemTypeNotification == null ? LocaleKeys.selectNotification.tr() : selectedItemTypeNotification!.nOTIFICATIONDISPLAYNAME!,
|
|
|
|
|
isEnable: false,
|
|
|
|
|
isPopup: true,
|
|
|
|
|
).paddingOnly(bottom: 12),
|
|
|
|
|
@ -331,17 +332,17 @@ class _AddVacationRuleScreenState extends State<AddVacationRuleScreen> {
|
|
|
|
|
notificationReassignMode = null;
|
|
|
|
|
setState(() {});
|
|
|
|
|
callCombineApis();
|
|
|
|
|
}).objectContainerView(title: "Step 2")
|
|
|
|
|
}).objectContainerView(title: LocaleKeys.step2.tr())
|
|
|
|
|
],
|
|
|
|
|
if (selectedItemType != null && selectedItemTypeNotification != null && currentStage == 3) ...[
|
|
|
|
|
12.height,
|
|
|
|
|
Column(
|
|
|
|
|
children: [
|
|
|
|
|
ItemDetailView(LocaleKeys.itemType.tr(), selectedItemType!.iTEMTYPEDISPLAYNAME!),
|
|
|
|
|
ItemDetailView("Notification", selectedItemTypeNotification!.nOTIFICATIONDISPLAYNAME!),
|
|
|
|
|
ItemDetailView(LocaleKeys.notification.tr(), selectedItemTypeNotification!.nOTIFICATIONDISPLAYNAME!),
|
|
|
|
|
12.height,
|
|
|
|
|
DynamicTextFieldWidget(
|
|
|
|
|
"Start Date",
|
|
|
|
|
LocaleKeys.startDateT.tr(),
|
|
|
|
|
formattedDate(startTime),
|
|
|
|
|
suffixIconData: Icons.calendar_today,
|
|
|
|
|
isEnable: false,
|
|
|
|
|
@ -355,7 +356,7 @@ class _AddVacationRuleScreenState extends State<AddVacationRuleScreen> {
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
DynamicTextFieldWidget(
|
|
|
|
|
"End Date",
|
|
|
|
|
LocaleKeys.endDateT.tr(),
|
|
|
|
|
formattedDate(endTime),
|
|
|
|
|
suffixIconData: Icons.calendar_today,
|
|
|
|
|
isEnable: false,
|
|
|
|
|
@ -369,8 +370,8 @@ class _AddVacationRuleScreenState extends State<AddVacationRuleScreen> {
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
DynamicTextFieldWidget(
|
|
|
|
|
"Message",
|
|
|
|
|
"Write a message",
|
|
|
|
|
LocaleKeys.message.tr(),
|
|
|
|
|
LocaleKeys.writeAMessage.tr(),
|
|
|
|
|
lines: 2,
|
|
|
|
|
onChange: (message) {
|
|
|
|
|
this.message = message;
|
|
|
|
|
@ -415,7 +416,7 @@ class _AddVacationRuleScreenState extends State<AddVacationRuleScreen> {
|
|
|
|
|
},
|
|
|
|
|
separatorBuilder: (cxt, index) => 12.height,
|
|
|
|
|
itemCount: notificationReassignModeList!.length)
|
|
|
|
|
.objectContainerBorderView(title: "Notification Reassign"),
|
|
|
|
|
.objectContainerBorderView(title: LocaleKeys.notificationReassign.tr()),
|
|
|
|
|
12.height,
|
|
|
|
|
if (respondAttributesList?.isNotEmpty ?? false) ...getDynamicWidgetList(),
|
|
|
|
|
if (roleList!.isNotEmpty && notificationReassignMode?.rADIOBUTTONACTION == 'RESPOND' ||
|
|
|
|
|
@ -423,15 +424,15 @@ class _AddVacationRuleScreenState extends State<AddVacationRuleScreen> {
|
|
|
|
|
(notificationReassignMode?.rADIOBUTTONACTION == 'DELEGATE') ||
|
|
|
|
|
(notificationReassignMode?.rADIOBUTTONACTION == 'TRANSFER'))
|
|
|
|
|
DynamicTextFieldWidget(
|
|
|
|
|
"Select Employee",
|
|
|
|
|
selectedReplacementEmployee == null ? "Search employee for replacement" : selectedReplacementEmployee!.employeeDisplayName ?? "",
|
|
|
|
|
LocaleKeys.selectEmployee.tr(),
|
|
|
|
|
selectedReplacementEmployee == null ? LocaleKeys.searchEmployeeForReplacement.tr() : selectedReplacementEmployee!.employeeDisplayName ?? "",
|
|
|
|
|
isEnable: false,
|
|
|
|
|
onTap: () {
|
|
|
|
|
showMyBottomSheet(
|
|
|
|
|
context,
|
|
|
|
|
child: SearchEmployeeBottomSheet(
|
|
|
|
|
title: "Search for Employee",
|
|
|
|
|
apiMode: "DELEGATE",
|
|
|
|
|
title: LocaleKeys.searchForEmployee.tr(),
|
|
|
|
|
apiMode: LocaleKeys.delegate.tr(),
|
|
|
|
|
onSelectEmployee: (_selectedEmployee) {
|
|
|
|
|
// Navigator.pop(context);
|
|
|
|
|
selectedReplacementEmployee = _selectedEmployee;
|
|
|
|
|
@ -442,7 +443,7 @@ class _AddVacationRuleScreenState extends State<AddVacationRuleScreen> {
|
|
|
|
|
},
|
|
|
|
|
).paddingOnly(bottom: 12),
|
|
|
|
|
],
|
|
|
|
|
).objectContainerView(title: "Step 3")
|
|
|
|
|
).objectContainerView(title: LocaleKeys.step3.tr())
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
).expanded,
|
|
|
|
|
@ -452,18 +453,16 @@ class _AddVacationRuleScreenState extends State<AddVacationRuleScreen> {
|
|
|
|
|
? null
|
|
|
|
|
: () {
|
|
|
|
|
if (endTime == null) {
|
|
|
|
|
Utils.showToast("Please specify End Time");
|
|
|
|
|
Utils.showToast(LocaleKeys.pleaseSpecifyEndTime.tr());
|
|
|
|
|
return;
|
|
|
|
|
} else if (notificationReassignMode == null) {
|
|
|
|
|
Utils.showToast("Please select notification reassign");
|
|
|
|
|
Utils.showToast(LocaleKeys.pleaseSelectNotificationReassign.tr());
|
|
|
|
|
return;
|
|
|
|
|
} else if (selectedReplacementEmployee == null) {
|
|
|
|
|
Utils.showToast("Please select employee for replacement");
|
|
|
|
|
Utils.showToast(LocaleKeys.pleaseSelectEmployeeForReplacement.tr());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<Map<String, dynamic>> list = [];
|
|
|
|
|
|
|
|
|
|
if (respondAttributesList?.isNotEmpty ?? false) {
|
|
|
|
|
for (int i = 0; i < respondAttributesList!.length; i++) {
|
|
|
|
|
if (respondAttributesList![i].aTTRIBUTETYPE == "VARCHAR2") {
|
|
|
|
|
@ -471,14 +470,14 @@ class _AddVacationRuleScreenState extends State<AddVacationRuleScreen> {
|
|
|
|
|
}
|
|
|
|
|
if (respondAttributesList![i].aTTRIBUTETYPE == "LOOKUP") {
|
|
|
|
|
if (wfLook == null) {
|
|
|
|
|
Utils.showToast('Please select action');
|
|
|
|
|
Utils.showToast(LocaleKeys.pleaseSelectAction.tr());
|
|
|
|
|
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');
|
|
|
|
|
Utils.showToast(LocaleKeys.pleaseSelectDate.tr());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
list.add({"ATTRIBUTE_NAME": respondAttributesList![i].aTTRIBUTENAME, "ATTRIBUTE_TEXT_VALUE": DateUtil.convertDateToStringLocation(dateInput!)});
|
|
|
|
|
|