From 0e961b2713dc93ea6cb7e54fc04c49b7ea1f4fba Mon Sep 17 00:00:00 2001 From: YujithIsura Date: Thu, 2 Jan 2025 15:36:20 +0530 Subject: [PATCH] enrollment update and insert bug fixed --- .../lib/widgets/student_create.dart | 10 +++++----- .../lib/widgets/student_update.dart | 20 ++++++++++++------- .../enrollment/lib/widgets/students.dart | 13 ++---------- campus/mobile/.vscode/launch.json | 10 +++++++++- campus/mobile/android/app/build.gradle | 8 ++++---- .../kotlin/com/example/mobile/MainActivity.kt | 2 +- .../ios/Runner.xcodeproj/project.pbxproj | 12 +++++------ campus/mobile/linux/CMakeLists.txt | 2 +- .../macos/Runner.xcodeproj/project.pbxproj | 6 +++--- .../macos/Runner/Configs/AppInfo.xcconfig | 2 +- 10 files changed, 45 insertions(+), 40 deletions(-) diff --git a/campus/frontend/lib/avinya/enrollment/lib/widgets/student_create.dart b/campus/frontend/lib/avinya/enrollment/lib/widgets/student_create.dart index b4f434fc..72611b90 100644 --- a/campus/frontend/lib/avinya/enrollment/lib/widgets/student_create.dart +++ b/campus/frontend/lib/avinya/enrollment/lib/widgets/student_create.dart @@ -697,8 +697,7 @@ class _StudentCreateState extends State { Expanded( flex: 6, child: DropdownButtonFormField( - value: userPerson.organization?.parent_organizations?.first.id ?? - userPerson.organization_id, + value: selectedOrgId, items: [ DropdownMenuItem( value: null, // Default item for when no selection is made @@ -720,8 +719,8 @@ class _StudentCreateState extends State { classes = await fetchClasses(newValue); } setState(() { - userPerson.organization_id = - newValue; // Update the organization ID + selectedOrgId = newValue; + userPerson.organization?.id = newValue; }); }, decoration: InputDecoration( @@ -955,7 +954,8 @@ class _StudentCreateState extends State { onChanged: (value) { setState(() { selectedClassId = value; - userPerson.organization?.id = value; + userPerson.organization_id = + value; // Update the organization ID }); }, decoration: const InputDecoration( diff --git a/campus/frontend/lib/avinya/enrollment/lib/widgets/student_update.dart b/campus/frontend/lib/avinya/enrollment/lib/widgets/student_update.dart index 321c8074..591c3edc 100644 --- a/campus/frontend/lib/avinya/enrollment/lib/widgets/student_update.dart +++ b/campus/frontend/lib/avinya/enrollment/lib/widgets/student_update.dart @@ -115,7 +115,8 @@ class _StudentUpdateState extends State { } selectedOrgId = userPerson.organization?.id ?? 0; - selectedClassId = classes.isNotEmpty ? classes.first.id : 0; + selectedClassId = + (userPerson.organization != null) ? userPerson.organization!.id : 0; // Handling date of birth safely String? dob = userPerson.date_of_birth; @@ -446,8 +447,8 @@ class _StudentUpdateState extends State { return 'Phone number is required'; } final phoneRegex = RegExp(r'^[0-9]+$'); - if (!phoneRegex.hasMatch(value) || value.length < 10) { - return 'Enter a valid phone number (at least 10 digits)'; + if (!phoneRegex.hasMatch(value) || value.length < 9) { + return 'Enter a valid phone number (at least 9 digits)'; } return null; } @@ -682,6 +683,9 @@ class _StudentUpdateState extends State { ); } + // final parentOrganizationId = + // (userPerson.organization != null) ? userPerson.organization!.id : 0; + final parentOrganizationId = (userPerson.organization?.parent_organizations != null && userPerson.organization!.parent_organizations!.isNotEmpty) @@ -708,7 +712,7 @@ class _StudentUpdateState extends State { Expanded( flex: 6, child: DropdownButtonFormField( - value: validParentOrganizationId, + value: validParentOrganizationId ?? userPerson.organization_id, items: organizations .where((org) => org.avinya_type?.id == 105 || @@ -945,13 +949,15 @@ class _StudentUpdateState extends State { flex: 6, child: DropdownButtonFormField( value: isValidClass - ? selectedClassId - : null, // Validate selectedClassId + ? (userPerson.organization != null) + ? userPerson.organization!.id + : 0 + : selectedClassId, // Validate selectedClassId items: _getClassOptions(), onChanged: (value) { setState(() { selectedClassId = value; - userPerson.organization?.id = value; + userPerson.organization_id = value; }); }, decoration: const InputDecoration( diff --git a/campus/frontend/lib/avinya/enrollment/lib/widgets/students.dart b/campus/frontend/lib/avinya/enrollment/lib/widgets/students.dart index 6f1691d5..fb074206 100644 --- a/campus/frontend/lib/avinya/enrollment/lib/widgets/students.dart +++ b/campus/frontend/lib/avinya/enrollment/lib/widgets/students.dart @@ -8,13 +8,12 @@ import 'package:gallery/avinya/enrollment/lib/screens/student_create_screen.dart import 'package:gallery/avinya/enrollment/lib/screens/student_update_screen.dart'; import 'person_data_excel_report.dart'; -enum AvinyaTypeId { Empower, IT, CS, FutureEnrollees } +enum AvinyaTypeId { Empower, IT, CS } const avinyaTypeId = { AvinyaTypeId.Empower: 37, AvinyaTypeId.IT: 10, AvinyaTypeId.CS: 96, - AvinyaTypeId.FutureEnrollees: 103, }; class Students extends StatefulWidget { @@ -37,7 +36,6 @@ class _StudentsState extends State { AvinyaTypeId.Empower, AvinyaTypeId.IT, AvinyaTypeId.CS, - AvinyaTypeId.FutureEnrollees ]; List columnNames = []; @@ -75,19 +73,16 @@ class _StudentsState extends State { AvinyaTypeId.Empower, AvinyaTypeId.IT, AvinyaTypeId.CS, - AvinyaTypeId.FutureEnrollees ]; } else { filteredAvinyaTypeIdValues = [ AvinyaTypeId.Empower, - AvinyaTypeId.FutureEnrollees ]; } } else { // Default value if newValue is null or invalid filteredAvinyaTypeIdValues = [ AvinyaTypeId.Empower, - AvinyaTypeId.FutureEnrollees ]; } @@ -231,14 +226,12 @@ class _StudentsState extends State { .isBefore(DateTime.parse('2024-03-01'))) { filteredAvinyaTypeIdValues = [ AvinyaTypeId.Empower, - AvinyaTypeId.FutureEnrollees ]; } else { filteredAvinyaTypeIdValues = [ AvinyaTypeId.Empower, AvinyaTypeId.IT, AvinyaTypeId.CS, - AvinyaTypeId.FutureEnrollees ]; } @@ -308,9 +301,7 @@ class _StudentsState extends State { return DropdownMenuItem( value: typeId, child: Text( - typeId.name == 'FutureEnrollees' - ? 'FUTURE ENROLLEES' - : typeId.name.toUpperCase(), + typeId.name.toUpperCase(), ), ); }).toList(), diff --git a/campus/mobile/.vscode/launch.json b/campus/mobile/.vscode/launch.json index 54b0c04a..16bd8ad4 100644 --- a/campus/mobile/.vscode/launch.json +++ b/campus/mobile/.vscode/launch.json @@ -53,6 +53,14 @@ "request": "launch", "type": "dart", "flutterMode": "release" - } + }, + { + "name": "debug android Tab", + "request": "launch", + "type": "dart", + "flutterMode": "debug", + "deviceId": "emulator-5556", + "runTestsOnDevice": false + }, ] } \ No newline at end of file diff --git a/campus/mobile/android/app/build.gradle b/campus/mobile/android/app/build.gradle index dab5ff07..0044fdd9 100644 --- a/campus/mobile/android/app/build.gradle +++ b/campus/mobile/android/app/build.gradle @@ -31,7 +31,7 @@ if (keystorePropertiesFile.exists()) { android { - namespace "com.avinyanew.mobile" + namespace "com.avinyav2.mobile" compileSdkVersion 34 ndkVersion flutter.ndkVersion @@ -50,12 +50,12 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId "com.avinyanew.mobile" + applicationId "com.avinyav2.mobile" // You can update the following values to match your application needs. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. - minSdkVersion 20 + minSdkVersion 21 targetSdkVersion 34 - versionCode 6 + versionCode 8 versionName "1.0.2" multiDexEnabled true manifestPlaceholders += [ diff --git a/campus/mobile/android/app/src/main/kotlin/com/example/mobile/MainActivity.kt b/campus/mobile/android/app/src/main/kotlin/com/example/mobile/MainActivity.kt index 13e7318e..88acb031 100644 --- a/campus/mobile/android/app/src/main/kotlin/com/example/mobile/MainActivity.kt +++ b/campus/mobile/android/app/src/main/kotlin/com/example/mobile/MainActivity.kt @@ -1,4 +1,4 @@ -package com.avinyanew.mobile +package com.avinyav2.mobile import io.flutter.embedding.android.FlutterActivity diff --git a/campus/mobile/ios/Runner.xcodeproj/project.pbxproj b/campus/mobile/ios/Runner.xcodeproj/project.pbxproj index decbb687..d0cf11de 100644 --- a/campus/mobile/ios/Runner.xcodeproj/project.pbxproj +++ b/campus/mobile/ios/Runner.xcodeproj/project.pbxproj @@ -367,7 +367,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.avinyanew.mobile; + PRODUCT_BUNDLE_IDENTIFIER = com.avinyav2.mobile; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; @@ -384,7 +384,7 @@ CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.avinyanew.mobile; + PRODUCT_BUNDLE_IDENTIFIER = com.avinyav2.mobile; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -402,7 +402,7 @@ CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.avinyanew.mobile; + PRODUCT_BUNDLE_IDENTIFIER = com.avinyav2.mobile; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; @@ -418,7 +418,7 @@ CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.avinyanew.mobile; + PRODUCT_BUNDLE_IDENTIFIER = com.avinyav2.mobile; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; @@ -545,7 +545,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.avinyanew.mobile; + PRODUCT_BUNDLE_IDENTIFIER = com.avinyav2.mobile; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -567,7 +567,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.avinyanew.mobile; + PRODUCT_BUNDLE_IDENTIFIER = com.avinyav2.mobile; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; diff --git a/campus/mobile/linux/CMakeLists.txt b/campus/mobile/linux/CMakeLists.txt index 8f191d30..786a22a0 100644 --- a/campus/mobile/linux/CMakeLists.txt +++ b/campus/mobile/linux/CMakeLists.txt @@ -7,7 +7,7 @@ project(runner LANGUAGES CXX) set(BINARY_NAME "Avinya Apps") # The unique GTK application identifier for this application. See: # https://wiki.gnome.org/HowDoI/ChooseApplicationID -set(APPLICATION_ID "com.avinyanew.mobile") +set(APPLICATION_ID "com.avinyav2.mobile") # Explicitly opt in to modern CMake behaviors to avoid warnings with recent # versions of CMake. diff --git a/campus/mobile/macos/Runner.xcodeproj/project.pbxproj b/campus/mobile/macos/Runner.xcodeproj/project.pbxproj index 47b16cc9..67a42edd 100644 --- a/campus/mobile/macos/Runner.xcodeproj/project.pbxproj +++ b/campus/mobile/macos/Runner.xcodeproj/project.pbxproj @@ -384,7 +384,7 @@ CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.avinyanew.mobile.RunnerTests; + PRODUCT_BUNDLE_IDENTIFIER = com.avinyav2.mobile.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/mobile.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/mobile"; @@ -398,7 +398,7 @@ CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.avinyanew.mobile.RunnerTests; + PRODUCT_BUNDLE_IDENTIFIER = com.avinyav2.mobile.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/mobile.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/mobile"; @@ -412,7 +412,7 @@ CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.avinyanew.mobile.RunnerTests; + PRODUCT_BUNDLE_IDENTIFIER = com.avinyav2.mobile.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/mobile.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/mobile"; diff --git a/campus/mobile/macos/Runner/Configs/AppInfo.xcconfig b/campus/mobile/macos/Runner/Configs/AppInfo.xcconfig index 425c2a74..7f03c208 100644 --- a/campus/mobile/macos/Runner/Configs/AppInfo.xcconfig +++ b/campus/mobile/macos/Runner/Configs/AppInfo.xcconfig @@ -8,7 +8,7 @@ PRODUCT_NAME = Avinya Apps; // The application's bundle identifier -PRODUCT_BUNDLE_IDENTIFIER = com.avinyanew.mobile; +PRODUCT_BUNDLE_IDENTIFIER = com.avinyav2.mobile; // The copyright displayed in application information PRODUCT_COPYRIGHT = Copyright © 2023 com.avinya. All rights reserved.