exceptional modal
This commit is contained in:
parent
77e0ba054c
commit
eee3182898
@ -423,6 +423,7 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
||||
bool hasAction = true;
|
||||
bool hasSoNumber = false;
|
||||
bool hasExceptionalClass = false;
|
||||
bool hasExceptionalClassInUpdate = false;
|
||||
|
||||
late Map<String, String> costCenterMap;
|
||||
List<String> costCenterIds = [];
|
||||
@ -587,6 +588,9 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
||||
fetchCostCenter();
|
||||
fetchCountryList();
|
||||
|
||||
print("hasExceptionalClass - $hasExceptionalClass");
|
||||
print("hasExceptionalClassInUpdate - $hasExceptionalClassInUpdate");
|
||||
|
||||
// _tripTitleFocusNode.addListener(() {
|
||||
// setState(() {
|
||||
// _isTripTitleFocused = _tripTitleFocusNode.hasFocus;
|
||||
@ -678,8 +682,11 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
||||
_excepntldescriptionController.text =
|
||||
widget.selectedPlanData['exceptional_plan_reason'] ?? '';
|
||||
|
||||
if (_excepntldescriptionController.text != "") {
|
||||
hasExceptionalClass = true;
|
||||
if (_excepntldescriptionController.text != "" &&
|
||||
_excepntldescriptionController.text != null) {
|
||||
hasExceptionalClassInUpdate = true;
|
||||
print("hasExceptionalClass1 - $hasExceptionalClass");
|
||||
print("hasExceptionalClassInUpdate1 - $hasExceptionalClassInUpdate");
|
||||
}
|
||||
|
||||
_selectedTripType = widget.selectedPlanData['trip_type'];
|
||||
@ -1166,9 +1173,9 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
||||
"cost_center_id": selectedCostCenterId,
|
||||
"functional_department": selectedFuncDept,
|
||||
"purpose_of_travel": selectedPurpose,
|
||||
|
||||
if (hasExceptionalClass)
|
||||
"exceptional_plan_reason": _excepntldescriptionController.text,
|
||||
|
||||
if (hasSoNumber) "so_number": _soNumberController.text,
|
||||
};
|
||||
print("validateForm.....3");
|
||||
@ -1337,8 +1344,12 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
||||
|
||||
setState(() {
|
||||
hasExceptionalClass = exceptionalCount >= 1;
|
||||
if (hasExceptionalClass &&
|
||||
_excepntldescriptionController.text.trim().isEmpty) {
|
||||
_showExceptionalReasonModal(context);
|
||||
}
|
||||
if (!hasExceptionalClass) {
|
||||
_excepntldescriptionController.text = '';
|
||||
_excepntldescriptionController.text = "";
|
||||
}
|
||||
});
|
||||
|
||||
@ -1774,7 +1785,10 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
||||
//
|
||||
_buildDescriptionColumn(isDesktop),
|
||||
SizedBox(width: 25),
|
||||
if (hasExceptionalClass) _buildNonDescriptionColumn(),
|
||||
|
||||
if (hasExceptionalClassInUpdate ||
|
||||
_excepntldescriptionController.text != "")
|
||||
_buildNonDescriptionColumn(),
|
||||
],
|
||||
)
|
||||
: Column(
|
||||
@ -1782,7 +1796,8 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
||||
children: [
|
||||
_buildDescriptionColumn(isDesktop),
|
||||
SizedBox(height: 15),
|
||||
if (hasExceptionalClass) _buildNonDescriptionColumn(),
|
||||
if (hasExceptionalClassInUpdate)
|
||||
_buildNonDescriptionColumn(),
|
||||
],
|
||||
),
|
||||
|
||||
@ -3396,6 +3411,105 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
||||
];
|
||||
}
|
||||
|
||||
void _showExceptionalReasonModal(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false, // prevent closing by tapping outside
|
||||
builder: (context) {
|
||||
return Dialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
// decoration: BoxDecoration(
|
||||
// border: Border.all(
|
||||
// color: Colors.grey, // or any color you prefer
|
||||
// width: 1.0,
|
||||
// ),
|
||||
// borderRadius: BorderRadius.circular(10),
|
||||
// ),
|
||||
color: Colors.white,
|
||||
width: 400,
|
||||
// width: MediaQuery.of(context).size.width * 0.5,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
"Reason for travel policy exception",
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
controller: _excepntldescriptionController,
|
||||
maxLines: 3,
|
||||
decoration: InputDecoration(
|
||||
hintText: "Enter reason...",
|
||||
hintStyle: GoogleFonts.poppins(fontSize: 10),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
10,
|
||||
), // 👈 Rounded border
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderSide: BorderSide(color: layoutColor!), // optional
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderSide: BorderSide(color: layoutColor!), // optional
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(); // Cancel
|
||||
},
|
||||
child: Text(
|
||||
"Cancel",
|
||||
style: GoogleFonts.poppins(fontSize: 12),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
// Use the entered text
|
||||
String reason =
|
||||
_excepntldescriptionController.text.trim();
|
||||
if (reason.isNotEmpty) {
|
||||
print("Reason entered: $reason");
|
||||
setState(() {
|
||||
hasExceptionalClassInUpdate = true;
|
||||
validationErrors.remove("exceptional_plan_reason");
|
||||
});
|
||||
|
||||
Navigator.of(context).pop(); // Close dialog
|
||||
} else {
|
||||
// Optional: show a validation message
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
"OK",
|
||||
style: GoogleFonts.poppins(fontSize: 12),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildNonDescriptionColumn() {
|
||||
return Column(
|
||||
children: [
|
||||
@ -3430,6 +3544,9 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
||||
controller: _excepntldescriptionController,
|
||||
maxLines: 2,
|
||||
keyboardType: TextInputType.multiline,
|
||||
onChanged: (value) {
|
||||
validationErrors.remove("exceptional_plan_reason");
|
||||
},
|
||||
style: TextStyle(fontSize: 12),
|
||||
enabled: !widget.isViewMode,
|
||||
decoration: InputDecoration(
|
||||
|
||||
@ -2,7 +2,7 @@ import 'dart:convert';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
// import 'package:flutter/rendering.dart';
|
||||
import 'dart:html' as html;
|
||||
import 'package:frontend/config/apiUrl.dart'; // 1 newly added
|
||||
import 'package:frontend/services/apiService.dart';
|
||||
@ -31,7 +31,7 @@ class _MyAppState extends State<MyApp> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
SemanticsBinding.instance.ensureSemantics(); // ✅ Safe here
|
||||
// SemanticsBinding.instance.ensureSemantics(); // ✅ Safe here
|
||||
if (kIsWeb) {
|
||||
final uri = Uri.parse(html.window.location.href);
|
||||
print("URI - $uri");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user