traf form validation added.

design_3.0_asset_inventory_module
Sikander Saleem 2 months ago
parent e54167b9b0
commit 3d2e908613

@ -165,6 +165,10 @@ class _CreateTRAFRequestPageState extends State<CreateTRAFRequestPage> {
AppTextFormField(
initialValue: "",
labelText: "How would the requested technology solve the current situation and/or serve the purpose?",
validator: (value) {
if ((value ?? "").isEmpty) return "Mandatory";
return null;
},
backgroundColor: AppColor.fieldBgColor(context),
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
floatingLabelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
@ -178,6 +182,10 @@ class _CreateTRAFRequestPageState extends State<CreateTRAFRequestPage> {
AppTextFormField(
initialValue: "",
labelText: "What is the current practice?",
validator: (value) {
if ((value ?? "").isEmpty) return "Mandatory";
return null;
},
backgroundColor: AppColor.fieldBgColor(context),
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
showShadow: false,
@ -191,6 +199,10 @@ class _CreateTRAFRequestPageState extends State<CreateTRAFRequestPage> {
initialValue: "",
makeMultiLinesNull: true,
labelText: "Census Q1",
validator: (value) {
if ((value ?? "").isEmpty) return "Mandatory";
return null;
},
backgroundColor: AppColor.fieldBgColor(context),
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
showShadow: false,
@ -204,6 +216,10 @@ class _CreateTRAFRequestPageState extends State<CreateTRAFRequestPage> {
initialValue: "",
makeMultiLinesNull: true,
labelText: "Census Q2",
validator: (value) {
if ((value ?? "").isEmpty) return "Mandatory";
return null;
},
backgroundColor: AppColor.fieldBgColor(context),
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
showShadow: false,
@ -217,6 +233,10 @@ class _CreateTRAFRequestPageState extends State<CreateTRAFRequestPage> {
initialValue: "",
makeMultiLinesNull: true,
labelText: "Census Q3",
validator: (value) {
if ((value ?? "").isEmpty) return "Mandatory";
return null;
},
backgroundColor: AppColor.fieldBgColor(context),
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
showShadow: false,
@ -230,6 +250,10 @@ class _CreateTRAFRequestPageState extends State<CreateTRAFRequestPage> {
initialValue: "",
makeMultiLinesNull: true,
labelText: "Census Q4",
validator: (value) {
if ((value ?? "").isEmpty) return "Mandatory";
return null;
},
backgroundColor: AppColor.fieldBgColor(context),
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
showShadow: false,
@ -347,6 +371,10 @@ class _CreateTRAFRequestPageState extends State<CreateTRAFRequestPage> {
textInputType: TextInputType.multiline,
alignLabelWithHint: true,
node: otherServicesEffectsNode,
validator: (value) {
if ((value ?? "").isEmpty) return "Mandatory";
return null;
},
labelText: "List down these services and stat how would it be effected",
backgroundColor: AppColor.fieldBgColor(context),
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
@ -384,6 +412,10 @@ class _CreateTRAFRequestPageState extends State<CreateTRAFRequestPage> {
textInputType: TextInputType.multiline,
alignLabelWithHint: true,
node: useInCombinationNode,
validator: (value) {
if ((value ?? "").isEmpty) return "Mandatory";
return null;
},
labelText: "kindly describe in detail",
backgroundColor: AppColor.fieldBgColor(context),
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
@ -430,11 +462,32 @@ class _CreateTRAFRequestPageState extends State<CreateTRAFRequestPage> {
}
void _verifyAndSubmit() async {
if (requestType == null) {
"Select request type".showToast;
return;
} else if (requestType?.value == 1 && trafRequest?.assetNDId == null) {
"Oracle Code missing".showToast;
return;
} else if (requestType?.value == 2 && trafRequest?.assetId == null) {
"Pick asset".showToast;
return;
}
if (!_formKey.currentState!.validate()) return;
trafRequest?.employeeId = context.userProvider.user?.userID;
trafRequest?.siteId = context.userProvider.user?.clientId;
trafRequest?.trafContacts = [];
trafRequest?.trafContacts = userBasedOnSearch.map((item) => TrafContacts(id: 0, trafId: 0, name: item.userName, userId: item.userId)).toList();
if ((trafRequest?.trafContacts ?? []).isEmpty) {
"Please specify users going to use technology".showToast;
return;
}
if (isUsedSolelyOrShared?.value == 1 && (trafRequest?.trafDepartments ?? []).isEmpty) {
"Please specify departments and relations".showToast;
return;
}
Utils.showLoading(context);
bool isSuccess = await Provider.of<TrafRequestProvider>(context, listen: false).addTraf(trafRequest!.toJson());
Utils.hideLoading(context);

Loading…
Cancel
Save