diff --git a/addons/default/visiosoft/profile-module/resources/assets/js/education.js b/addons/default/visiosoft/profile-module/resources/assets/js/education.js index 22c8f6e13..f54877dbb 100644 --- a/addons/default/visiosoft/profile-module/resources/assets/js/education.js +++ b/addons/default/visiosoft/profile-module/resources/assets/js/education.js @@ -1,6 +1,6 @@ $(() => { $.ajax({ - url: '/ajax/getEducation', + url: '/api/getEducation', success: ((res)=>{ $.each(res['education-part'], function (key, value) { var selected = "" @@ -12,14 +12,14 @@ $(() => { $('#education').on('change', () => { $.ajax({ - url: '/api/setEducation', + url: '/api/changeEducation', data: { info: 'education', education: $('#education').val() },beforeSend: function (){ $('#education_part').html(''); },success: function (response) { - $('#education_part').html('') + $('#education_part').html('') $.each(response.data, function (key, value) { $('#education_part').append( '' @@ -28,14 +28,4 @@ $(() => { } }); }) - - $('#education_part').on('change', () => { - $.ajax({ - url: '/api/setEducation', - data: { - info: 'education_part', - education: $('#education_part').val() - } - }) - }) }) \ No newline at end of file diff --git a/addons/default/visiosoft/profile-module/src/Http/Controller/Admin/EducationController.php b/addons/default/visiosoft/profile-module/src/Http/Controller/Admin/EducationController.php new file mode 100644 index 000000000..b6c61e75b --- /dev/null +++ b/addons/default/visiosoft/profile-module/src/Http/Controller/Admin/EducationController.php @@ -0,0 +1,43 @@ +render(); + } + + /** + * Create a new entry. + * + * @param EducationFormBuilder $form + * @return \Symfony\Component\HttpFoundation\Response + */ + public function create(EducationFormBuilder $form) + { + return $form->render(); + } + + /** + * Edit an existing entry. + * + * @param EducationFormBuilder $form + * @param $id + * @return \Symfony\Component\HttpFoundation\Response + */ + public function edit(EducationFormBuilder $form, $id) + { + return $form->render($id); + } +} diff --git a/addons/default/visiosoft/profile-module/src/Http/Controller/Admin/EducationPartController.php b/addons/default/visiosoft/profile-module/src/Http/Controller/Admin/EducationPartController.php new file mode 100644 index 000000000..60f997a23 --- /dev/null +++ b/addons/default/visiosoft/profile-module/src/Http/Controller/Admin/EducationPartController.php @@ -0,0 +1,43 @@ +render(); + } + + /** + * Create a new entry. + * + * @param EducationPartFormBuilder $form + * @return \Symfony\Component\HttpFoundation\Response + */ + public function create(EducationPartFormBuilder $form) + { + return $form->render(); + } + + /** + * Edit an existing entry. + * + * @param EducationPartFormBuilder $form + * @param $id + * @return \Symfony\Component\HttpFoundation\Response + */ + public function edit(EducationPartFormBuilder $form, $id) + { + return $form->render($id); + } +} diff --git a/addons/default/visiosoft/profile-module/src/Http/Controller/MyProfileController.php b/addons/default/visiosoft/profile-module/src/Http/Controller/MyProfileController.php index ed7317f64..01920904c 100644 --- a/addons/default/visiosoft/profile-module/src/Http/Controller/MyProfileController.php +++ b/addons/default/visiosoft/profile-module/src/Http/Controller/MyProfileController.php @@ -257,16 +257,11 @@ class MyProfileController extends PublicController return response()->json(['user' => $user, 'education' => $education, 'education-part' => $educationPart], 200); } - public function setEducation(Request $request) + public function changeEducation(Request $request) { - $user_id = auth()->id(); if ($request->info == 'education') { - $user = $this->userRepository->find($user_id)->update(['education' => $request->education]); $education = EducationPartModel::query()->where('education_id', $request->education)->get(); - } elseif ($request->info == 'education_part') { - $user = $this->userRepository->find($user_id)->update(['education_part' => $request->education]); - $education = EducationPartOptionModel::query()->where('education_part_id', $request->education)->get(); } - return response()->json(['messages' => $user, 'data' => $education], 200); + return response()->json(['data' => $education], 200); } } diff --git a/addons/default/visiosoft/profile-module/src/Profile/Profile/ProfileFormHandler.php b/addons/default/visiosoft/profile-module/src/Profile/Profile/ProfileFormHandler.php index ed0775c78..728e290e0 100644 --- a/addons/default/visiosoft/profile-module/src/Profile/Profile/ProfileFormHandler.php +++ b/addons/default/visiosoft/profile-module/src/Profile/Profile/ProfileFormHandler.php @@ -30,6 +30,7 @@ class ProfileFormHandler if (setting_value('visiosoft.module.profile::show_education_profession')) { $parameters = array_merge($parameters, [ 'education' => $builder->getPostValue('education'), + 'education_part' => $builder->getPostValue('education_part'), 'state_of_education' => $builder->getPostValue('state_of_education'), 'profession' => $builder->getPostValue('profession'), ]); diff --git a/addons/default/visiosoft/profile-module/src/ProfileModuleServiceProvider.php b/addons/default/visiosoft/profile-module/src/ProfileModuleServiceProvider.php index 7880c51d5..15d9efa83 100644 --- a/addons/default/visiosoft/profile-module/src/ProfileModuleServiceProvider.php +++ b/addons/default/visiosoft/profile-module/src/ProfileModuleServiceProvider.php @@ -105,7 +105,7 @@ class ProfileModuleServiceProvider extends AddonServiceProvider ], 'profile/notification' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@notification', 'ajax/update-user-info' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@updateAjaxProfile', - 'api/setEducation' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@setEducation', + 'api/changeEducation' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@changeEducation', 'api/getEducation' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@getEducation', // UserAuthenticator