From 14e9e47e094c2943c395bf8d4a4e13f132b866e8 Mon Sep 17 00:00:00 2001 From: Diatrex Date: Fri, 6 Nov 2020 18:32:17 +0300 Subject: [PATCH] #2594 e-madencilik add 3 fields to profile --- ...eate_profession_and_educational_fields.php | 69 +++++++++++++++++++ .../resources/assets/css/profile.scss | 4 ++ .../resources/config/settings/sections.php | 6 +- .../resources/config/settings/settings.php | 7 ++ .../resources/lang/en/field.php | 9 +++ .../resources/lang/en/setting.php | 4 ++ .../resources/views/profile/detail.twig | 27 ++++++++ .../Profile/Profile/ProfileFormBuilder.php | 3 + .../Profile/Profile/ProfileFormHandler.php | 8 +++ 9 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 addons/default/visiosoft/profile-module/migrations/2020_11_06_150519_visiosoft.module.profile__create_profession_and_educational_fields.php diff --git a/addons/default/visiosoft/profile-module/migrations/2020_11_06_150519_visiosoft.module.profile__create_profession_and_educational_fields.php b/addons/default/visiosoft/profile-module/migrations/2020_11_06_150519_visiosoft.module.profile__create_profession_and_educational_fields.php new file mode 100644 index 000000000..8aacbfd2d --- /dev/null +++ b/addons/default/visiosoft/profile-module/migrations/2020_11_06_150519_visiosoft.module.profile__create_profession_and_educational_fields.php @@ -0,0 +1,69 @@ +streams()->findBySlugAndNamespace('users', 'users')) { + $fields = [ + [ + 'name' => trans('visiosoft.module.profile::field.education.name'), + 'slug' => 'education', + ], + [ + 'name' => trans('visiosoft.module.profile::field.state_of_education.name'), + 'slug' => 'state_of_education', + ], + [ + 'name' => trans('visiosoft.module.profile::field.profession.name'), + 'slug' => 'profession', + ], + ]; + + foreach ($fields as $field) { + $exists = $this->fields() + ->newQuery() + ->where('slug', $field['slug']) + ->where('namespace', 'users') + ->first(); + + if (!$exists) { + $userField = $this->fields()->create([ + 'name' => $field['name'], + 'namespace' => 'users', + 'slug' => $field['slug'], + 'type' => 'anomaly.field_type.tags', + 'locked' => 0, + ]); + + $this->assignments()->create([ + 'stream_id' => $stream->id, + 'field_id' => $userField->id + ]); + } + } + } + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + /* + * I never go back on my word! + * That's my nindo: my ninja way! + * NARUTO + */ + } +} diff --git a/addons/default/visiosoft/profile-module/resources/assets/css/profile.scss b/addons/default/visiosoft/profile-module/resources/assets/css/profile.scss index 53e3144ce..3dafb014d 100644 --- a/addons/default/visiosoft/profile-module/resources/assets/css/profile.scss +++ b/addons/default/visiosoft/profile-module/resources/assets/css/profile.scss @@ -141,5 +141,9 @@ .birthday-field .input-group-addon { display: none; } + + .education-field > .tagify, .state_of_education-field > .tagify, .profession-field > .tagify { + height: initial; + } } } \ No newline at end of file diff --git a/addons/default/visiosoft/profile-module/resources/config/settings/sections.php b/addons/default/visiosoft/profile-module/resources/config/settings/sections.php index c13213f29..00bad9616 100644 --- a/addons/default/visiosoft/profile-module/resources/config/settings/sections.php +++ b/addons/default/visiosoft/profile-module/resources/config/settings/sections.php @@ -7,7 +7,11 @@ return [ 'general_setting' => [ 'title' => 'visiosoft.module.profile::section.general_setting', 'fields' => [ - 'show_my_ads', 'upload_avatar', 'show_tax_office', 'show_checkbox_terms_on_register' + 'show_my_ads', + 'upload_avatar', + 'show_tax_office', + 'show_checkbox_terms_on_register', + 'show_education_profession' ], ], 'recaptcha' => [ diff --git a/addons/default/visiosoft/profile-module/resources/config/settings/settings.php b/addons/default/visiosoft/profile-module/resources/config/settings/settings.php index f3f04357f..2dcdef450 100644 --- a/addons/default/visiosoft/profile-module/resources/config/settings/settings.php +++ b/addons/default/visiosoft/profile-module/resources/config/settings/settings.php @@ -41,4 +41,11 @@ return [ 'mode' => 'checkbox' ] ], + 'show_education_profession' => [ + 'type' => 'anomaly.field_type.boolean', + 'config' => [ + 'default_value' => true, + 'mode' => 'checkbox' + ] + ], ]; \ 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 e11c7c876..13b390085 100644 --- a/addons/default/visiosoft/profile-module/resources/lang/en/field.php +++ b/addons/default/visiosoft/profile-module/resources/lang/en/field.php @@ -58,6 +58,15 @@ return [ 'birthday' => [ 'name' => 'Birthday' ], + 'education' => [ + 'name' => 'Education' + ], + 'state_of_education' => [ + 'name' => 'State of Education' + ], + 'profession' => [ + 'name' => 'Profession' + ], 'identification_number' => [ 'name' => 'Identification Number' ], diff --git a/addons/default/visiosoft/profile-module/resources/lang/en/setting.php b/addons/default/visiosoft/profile-module/resources/lang/en/setting.php index 31a80386a..15cb14e7d 100644 --- a/addons/default/visiosoft/profile-module/resources/lang/en/setting.php +++ b/addons/default/visiosoft/profile-module/resources/lang/en/setting.php @@ -14,6 +14,10 @@ return [ 'name' => 'Show Checkbox Terms on Register', 'instructions' => 'Show the "Accept term", "protection law", "privacy term", "sms & emails" on the register form' ], + 'show_education_profession' => [ + 'name' => 'Show Education and Profession Fields', + 'instructions' => 'Show the "Education", "State of Education" and "Profession" on the profile edit page' + ], 'google_captcha_site_key' => [ 'name' => 'Google Captcha Site Key', ], 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 edde92e0b..9b782ebc8 100644 --- a/addons/default/visiosoft/profile-module/resources/views/profile/detail.twig +++ b/addons/default/visiosoft/profile-module/resources/views/profile/detail.twig @@ -149,6 +149,33 @@ {{ profileForm.fields.birthday.input|raw }} + + {% if setting_value('visiosoft.module.profile::show_education_profession') %} +
+
+ + {{ profileForm.fields.education.input|raw }} +
+
+
+
+ + {{ profileForm.fields.state_of_education.input|raw }} +
+
+
+
+ + {{ profileForm.fields.profession.input|raw }} +
+
+ {% endif %}