diff --git a/addons/default/visiosoft/profile-module/migrations/2020_12_14_161536_visiosoft.module.profile__create_education_part_option_stream.php b/addons/default/visiosoft/profile-module/migrations/2020_12_14_161536_visiosoft.module.profile__create_education_part_option_stream.php deleted file mode 100644 index a6d14710e..000000000 --- a/addons/default/visiosoft/profile-module/migrations/2020_12_14_161536_visiosoft.module.profile__create_education_part_option_stream.php +++ /dev/null @@ -1,60 +0,0 @@ - 'education_part_option', - 'title_column' => 'name', - 'translatable' => true, - 'versionable' => false, - 'trashable' => false, - 'searchable' => false, - 'sortable' => false, - ]; - - /** - * The stream assignments. - * - * @var array - */ - protected $assignments = [ - 'education_part' => [ - 'required' => true, - ], - 'name' => [ - 'translatable' => true, - 'required' => true, - ], - 'slug' => [ - 'unique' => true, - 'required' => true, - ], - ]; - - protected $fields = [ - 'education_part' => [ - 'type' => 'anomaly.field_type.relationship', - 'config' => [ - 'related' => EducationPartModel::class, - ] - ] - ]; - -} diff --git a/addons/default/visiosoft/profile-module/resources/assets/js/education.js b/addons/default/visiosoft/profile-module/resources/assets/js/education.js new file mode 100644 index 000000000..78dc044bb --- /dev/null +++ b/addons/default/visiosoft/profile-module/resources/assets/js/education.js @@ -0,0 +1,45 @@ +$(() => { + $.ajax({ + url: '/ajax/getEducation', + success: ((res)=>{ + $.each(res['education-part'], function (key, value) { + var selected = "" + if (res.user.education_part == value.id){ selected = 'selected'; } + $('#education_part').append('') + }) + }) + }) + + $('#education').on('change', () => { + $.ajax({ + url: '/ajax/setEducation', + data: { + info: 'education', + education: $('#education').val() + },beforeSend: function (){ + $('#education_part').html(''); + },success: function (response) { + $('#education_part').html('') + $.each(response.data, function (key, value) { + $('#education_part').append( + '' + ) + }) + } + }); + }) + + $('#education_part').on('change', () => { + $.ajax({ + url: '/ajax/setEducation', + data: { + info: 'education_part', + education: $('#education_part').val() + }, beforeSend: function (){ + $('#education_part_option').html(''); + }, success: function (response) { + + } + }) + }) +}) \ No newline at end of file diff --git a/addons/default/visiosoft/profile-module/resources/lang/en/field.php b/addons/default/visiosoft/profile-module/resources/lang/en/field.php index 5ac8fe1d6..90e22a8eb 100644 --- a/addons/default/visiosoft/profile-module/resources/lang/en/field.php +++ b/addons/default/visiosoft/profile-module/resources/lang/en/field.php @@ -121,6 +121,9 @@ return [ 'user' => [ 'name' => 'User' ], + 'name' => [ + 'name' => 'Name' + ], /*Menu Button*/ 'profile' => [ @@ -476,4 +479,8 @@ return [ 'personal' => [ 'name' => 'Personal' ], + + 'education_part' => [ + 'name' => 'State of Education' + ], ]; diff --git a/addons/default/visiosoft/profile-module/resources/views/profile/detail.twig b/addons/default/visiosoft/profile-module/resources/views/profile/detail.twig index d0f656ba1..60017932a 100644 --- a/addons/default/visiosoft/profile-module/resources/views/profile/detail.twig +++ b/addons/default/visiosoft/profile-module/resources/views/profile/detail.twig @@ -175,7 +175,7 @@
-
+
@@ -221,6 +221,7 @@
{{ profileForm.close()|raw }}
+
+ {% endblock %} {% endembed %} - + {{ asset_script("visiosoft.module.profile::assets/js/education.js") }} {{ asset_add("scripts.js", "visiosoft.module.profile::assets/js/profile.js") }} {% endblock %} \ No newline at end of file diff --git a/addons/default/visiosoft/profile-module/src/EducationPartOption/Contract/EducationPartOptionInterface.php b/addons/default/visiosoft/profile-module/src/EducationPartOption/Contract/EducationPartOptionInterface.php deleted file mode 100644 index 278c5a01d..000000000 --- a/addons/default/visiosoft/profile-module/src/EducationPartOption/Contract/EducationPartOptionInterface.php +++ /dev/null @@ -1,8 +0,0 @@ -model = $model; - } -} diff --git a/addons/default/visiosoft/profile-module/src/EducationPartOption/EducationPartOptionRouter.php b/addons/default/visiosoft/profile-module/src/EducationPartOption/EducationPartOptionRouter.php deleted file mode 100644 index 414126e89..000000000 --- a/addons/default/visiosoft/profile-module/src/EducationPartOption/EducationPartOptionRouter.php +++ /dev/null @@ -1,8 +0,0 @@ -userRepository->find(auth()->user()->getAuthIdentifier()); $education = EducationModel::all(); - $educationPart = EducationPartModel::all(); + $educationPart = EducationPartModel::query()->where('education_id', $user->education)->get(); return response()->json(['user' => $user, 'education' => $education, 'education-part' => $educationPart], 200); } public function setEducation(Request $request) { - $user = $this->userRepository->find(auth()->user()->getAuthIdentifier())->update(['education' => $request->education]); - $education_part = EducationPartModel::query()->where('education_id', $request->education)->get(); - return response()->json(['messages' => $user, 'data' => $education_part], 200); + $user_id = auth()->user()->getAuthIdentifier(); + 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); } } diff --git a/addons/default/visiosoft/profile-module/src/ProfileModule.php b/addons/default/visiosoft/profile-module/src/ProfileModule.php index 81f00785b..a6ad6ee88 100644 --- a/addons/default/visiosoft/profile-module/src/ProfileModule.php +++ b/addons/default/visiosoft/profile-module/src/ProfileModule.php @@ -40,11 +40,6 @@ class ProfileModule extends Module 'new_education', ] ], - 'education_part_option' => [ - 'buttons' => [ - 'new_education', - ] - ] ]; } diff --git a/addons/default/visiosoft/profile-module/src/Seed/UsersFieldsSeeder.php b/addons/default/visiosoft/profile-module/src/Seed/UsersFieldsSeeder.php index 1d0301bbc..4b7f734ed 100644 --- a/addons/default/visiosoft/profile-module/src/Seed/UsersFieldsSeeder.php +++ b/addons/default/visiosoft/profile-module/src/Seed/UsersFieldsSeeder.php @@ -124,6 +124,31 @@ class UsersFieldsSeeder extends Seeder "picker" => true, ] ], + [ + 'name' => trans('visiosoft.module.profile::field.education.name'), + 'slug' => 'education', + 'type' => 'anomaly.field_type.text', + ], + [ + 'name' => trans('visiosoft.module.profile::field.state_of_education.name'), + 'slug' => 'state_of_education', + 'type' => 'anomaly.field_type.text', + ], + [ + 'name' => trans('visiosoft.module.profile::field.profession.name'), + 'slug' => 'profession', + 'type' => 'anomaly.field_type.select', + ], + [ + 'name' => trans('visiosoft.module.profile::field.education_part.name'), + 'slug' => 'education_part', + 'type' => 'anomaly.field_type.select', + ], + [ + 'name' => trans('visiosoft.module.profile::field.education_part_option.name'), + 'slug' => 'education_part_option', + 'type' => 'anomaly.field_type.select', + ], [ 'name' => trans('visiosoft.module.profile::field.facebook_address.name'), 'slug' => 'facebook_address',