commit for comment in pull req

This commit is contained in:
Muammer Top 2020-12-16 12:06:10 +03:00
parent d2665a951a
commit 28b67a2f49
6 changed files with 93 additions and 21 deletions

View File

@ -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('<option>'+ choose_an_option +'</option>')
$('#education_part').html('<option value="">'+ choose_an_option +'</option>')
$.each(response.data, function (key, value) {
$('#education_part').append(
'<option value="'+ value.id +'">'+ value.name +'</option>'
@ -28,14 +28,4 @@ $(() => {
}
});
})
$('#education_part').on('change', () => {
$.ajax({
url: '/api/setEducation',
data: {
info: 'education_part',
education: $('#education_part').val()
}
})
})
})

View File

@ -0,0 +1,43 @@
<?php namespace Visiosoft\ProfileModule\Http\Controller\Admin;
use Visiosoft\ProfileModule\Education\Form\EducationFormBuilder;
use Visiosoft\ProfileModule\Education\Table\EducationTableBuilder;
use Anomaly\Streams\Platform\Http\Controller\AdminController;
class EducationController extends AdminController
{
/**
* Display an index of existing entries.
*
* @param EducationTableBuilder $table
* @return \Symfony\Component\HttpFoundation\Response
*/
public function index(EducationTableBuilder $table)
{
return $table->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);
}
}

View File

@ -0,0 +1,43 @@
<?php namespace Visiosoft\ProfileModule\Http\Controller\Admin;
use Visiosoft\ProfileModule\EducationPart\Form\EducationPartFormBuilder;
use Visiosoft\ProfileModule\EducationPart\Table\EducationPartTableBuilder;
use Anomaly\Streams\Platform\Http\Controller\AdminController;
class EducationPartController extends AdminController
{
/**
* Display an index of existing entries.
*
* @param EducationPartTableBuilder $table
* @return \Symfony\Component\HttpFoundation\Response
*/
public function index(EducationPartTableBuilder $table)
{
return $table->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);
}
}

View File

@ -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);
}
}

View File

@ -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'),
]);

View File

@ -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