exceptional modal
This commit is contained in:
parent
77e0ba054c
commit
eee3182898
@ -423,6 +423,7 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
|||||||
bool hasAction = true;
|
bool hasAction = true;
|
||||||
bool hasSoNumber = false;
|
bool hasSoNumber = false;
|
||||||
bool hasExceptionalClass = false;
|
bool hasExceptionalClass = false;
|
||||||
|
bool hasExceptionalClassInUpdate = false;
|
||||||
|
|
||||||
late Map<String, String> costCenterMap;
|
late Map<String, String> costCenterMap;
|
||||||
List<String> costCenterIds = [];
|
List<String> costCenterIds = [];
|
||||||
@ -587,6 +588,9 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
|||||||
fetchCostCenter();
|
fetchCostCenter();
|
||||||
fetchCountryList();
|
fetchCountryList();
|
||||||
|
|
||||||
|
print("hasExceptionalClass - $hasExceptionalClass");
|
||||||
|
print("hasExceptionalClassInUpdate - $hasExceptionalClassInUpdate");
|
||||||
|
|
||||||
// _tripTitleFocusNode.addListener(() {
|
// _tripTitleFocusNode.addListener(() {
|
||||||
// setState(() {
|
// setState(() {
|
||||||
// _isTripTitleFocused = _tripTitleFocusNode.hasFocus;
|
// _isTripTitleFocused = _tripTitleFocusNode.hasFocus;
|
||||||
@ -678,8 +682,11 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
|||||||
_excepntldescriptionController.text =
|
_excepntldescriptionController.text =
|
||||||
widget.selectedPlanData['exceptional_plan_reason'] ?? '';
|
widget.selectedPlanData['exceptional_plan_reason'] ?? '';
|
||||||
|
|
||||||
if (_excepntldescriptionController.text != "") {
|
if (_excepntldescriptionController.text != "" &&
|
||||||
hasExceptionalClass = true;
|
_excepntldescriptionController.text != null) {
|
||||||
|
hasExceptionalClassInUpdate = true;
|
||||||
|
print("hasExceptionalClass1 - $hasExceptionalClass");
|
||||||
|
print("hasExceptionalClassInUpdate1 - $hasExceptionalClassInUpdate");
|
||||||
}
|
}
|
||||||
|
|
||||||
_selectedTripType = widget.selectedPlanData['trip_type'];
|
_selectedTripType = widget.selectedPlanData['trip_type'];
|
||||||
@ -1166,9 +1173,9 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
|||||||
"cost_center_id": selectedCostCenterId,
|
"cost_center_id": selectedCostCenterId,
|
||||||
"functional_department": selectedFuncDept,
|
"functional_department": selectedFuncDept,
|
||||||
"purpose_of_travel": selectedPurpose,
|
"purpose_of_travel": selectedPurpose,
|
||||||
|
|
||||||
if (hasExceptionalClass)
|
if (hasExceptionalClass)
|
||||||
"exceptional_plan_reason": _excepntldescriptionController.text,
|
"exceptional_plan_reason": _excepntldescriptionController.text,
|
||||||
|
|
||||||
if (hasSoNumber) "so_number": _soNumberController.text,
|
if (hasSoNumber) "so_number": _soNumberController.text,
|
||||||
};
|
};
|
||||||
print("validateForm.....3");
|
print("validateForm.....3");
|
||||||
@ -1337,8 +1344,12 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
|||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
hasExceptionalClass = exceptionalCount >= 1;
|
hasExceptionalClass = exceptionalCount >= 1;
|
||||||
|
if (hasExceptionalClass &&
|
||||||
|
_excepntldescriptionController.text.trim().isEmpty) {
|
||||||
|
_showExceptionalReasonModal(context);
|
||||||
|
}
|
||||||
if (!hasExceptionalClass) {
|
if (!hasExceptionalClass) {
|
||||||
_excepntldescriptionController.text = '';
|
_excepntldescriptionController.text = "";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1774,7 +1785,10 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
|||||||
//
|
//
|
||||||
_buildDescriptionColumn(isDesktop),
|
_buildDescriptionColumn(isDesktop),
|
||||||
SizedBox(width: 25),
|
SizedBox(width: 25),
|
||||||
if (hasExceptionalClass) _buildNonDescriptionColumn(),
|
|
||||||
|
if (hasExceptionalClassInUpdate ||
|
||||||
|
_excepntldescriptionController.text != "")
|
||||||
|
_buildNonDescriptionColumn(),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: Column(
|
: Column(
|
||||||
@ -1782,7 +1796,8 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
|||||||
children: [
|
children: [
|
||||||
_buildDescriptionColumn(isDesktop),
|
_buildDescriptionColumn(isDesktop),
|
||||||
SizedBox(height: 15),
|
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() {
|
Widget _buildNonDescriptionColumn() {
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
@ -3430,6 +3544,9 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
|||||||
controller: _excepntldescriptionController,
|
controller: _excepntldescriptionController,
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
keyboardType: TextInputType.multiline,
|
keyboardType: TextInputType.multiline,
|
||||||
|
onChanged: (value) {
|
||||||
|
validationErrors.remove("exceptional_plan_reason");
|
||||||
|
},
|
||||||
style: TextStyle(fontSize: 12),
|
style: TextStyle(fontSize: 12),
|
||||||
enabled: !widget.isViewMode,
|
enabled: !widget.isViewMode,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import 'dart:convert';
|
|||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
// import 'package:flutter/rendering.dart';
|
||||||
import 'dart:html' as html;
|
import 'dart:html' as html;
|
||||||
import 'package:frontend/config/apiUrl.dart'; // 1 newly added
|
import 'package:frontend/config/apiUrl.dart'; // 1 newly added
|
||||||
import 'package:frontend/services/apiService.dart';
|
import 'package:frontend/services/apiService.dart';
|
||||||
@ -31,7 +31,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
SemanticsBinding.instance.ensureSemantics(); // ✅ Safe here
|
// SemanticsBinding.instance.ensureSemantics(); // ✅ Safe here
|
||||||
if (kIsWeb) {
|
if (kIsWeb) {
|
||||||
final uri = Uri.parse(html.window.location.href);
|
final uri = Uri.parse(html.window.location.href);
|
||||||
print("URI - $uri");
|
print("URI - $uri");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user