From 819764a012b7217e26d5774e80034b07513d7cda Mon Sep 17 00:00:00 2001 From: vedatakd Date: Tue, 26 Oct 2021 18:37:33 +0300 Subject: [PATCH] optional preview && dynamic profile fields --- .../resources/config/settings/sections.php | 1 + .../resources/config/settings/settings.php | 7 +++++ .../advs-module/resources/lang/en/setting.php | 14 ++++++--- .../resources/views/new-ad/new-create.twig | 4 +-- .../src/Http/Controller/AdvsController.php | 9 ++++-- .../Profile/Profile/ProfileFormBuilder.php | 19 ------------ .../src/Profile/Profile/ProfileFormFields.php | 31 +++++++++++++++++++ 7 files changed, 57 insertions(+), 28 deletions(-) create mode 100644 addons/default/visiosoft/profile-module/src/Profile/Profile/ProfileFormFields.php diff --git a/addons/default/visiosoft/advs-module/resources/config/settings/sections.php b/addons/default/visiosoft/advs-module/resources/config/settings/sections.php index 0c9081ea4..0958d149d 100644 --- a/addons/default/visiosoft/advs-module/resources/config/settings/sections.php +++ b/addons/default/visiosoft/advs-module/resources/config/settings/sections.php @@ -23,6 +23,7 @@ return [ 'ads' => [ 'title' => 'visiosoft.module.advs::section.ads', 'fields' => [ + 'preview_mode', 'show_finish_and_publish_date', 'latest-limit', 'popular_ads_limit', diff --git a/addons/default/visiosoft/advs-module/resources/config/settings/settings.php b/addons/default/visiosoft/advs-module/resources/config/settings/settings.php index 3c1cf4ab6..7f280bd56 100644 --- a/addons/default/visiosoft/advs-module/resources/config/settings/settings.php +++ b/addons/default/visiosoft/advs-module/resources/config/settings/settings.php @@ -485,4 +485,11 @@ return [ 'default_value' => false, ] ], + 'preview_mode' => [ + 'type' => 'anomaly.field_type.boolean', + 'bind' => 'adv.preview_mode', + 'config' => [ + 'default_value' => true, + ], + ], ]; diff --git a/addons/default/visiosoft/advs-module/resources/lang/en/setting.php b/addons/default/visiosoft/advs-module/resources/lang/en/setting.php index 038d85f07..9582000ef 100644 --- a/addons/default/visiosoft/advs-module/resources/lang/en/setting.php +++ b/addons/default/visiosoft/advs-module/resources/lang/en/setting.php @@ -133,7 +133,7 @@ return [ ], 'market_place' => [ 'name' => 'Market Place', - 'instructions' => 'If the marketplace is down, your site will act as ecommerce. For example, + 'instructions' => 'If the marketplace is down, your site will act as ecommerce. For example, some fields in the profile such as ads, dopings, messages, sale, packages and store are not visible and removes corporate membership.' ], @@ -280,9 +280,9 @@ return [ 'name' => 'Show Tax Field', 'instructions' => 'When this option is enabled, you can set the tax rate on the ad creation page.' ], - 'hide_contact_created_at' => [ - 'name' => 'Hide Contact Fields For in Create New Ad' - ], + 'hide_contact_created_at' => [ + 'name' => 'Hide Contact Fields For in Create New Ad' + ], 'show_input_flag' => [ 'name' => 'Show Flags on Input', 'instructions' => 'Show flag and description on translatable inputs' @@ -293,5 +293,9 @@ return [ ], 'only_email_login' => [ 'name' => 'Only Email Login' - ] + ], + 'preview_mode' => [ + 'name' => 'Preview Mode', + 'instructions' => 'When this mode is enabled, the ad is previewed by the user.' + ], ]; diff --git a/addons/default/visiosoft/advs-module/resources/views/new-ad/new-create.twig b/addons/default/visiosoft/advs-module/resources/views/new-ad/new-create.twig index 59c5044cf..e91f19c60 100644 --- a/addons/default/visiosoft/advs-module/resources/views/new-ad/new-create.twig +++ b/addons/default/visiosoft/advs-module/resources/views/new-ad/new-create.twig @@ -107,7 +107,7 @@
- {% set HideStandardPrice = setting_value('visiosoft.module.advs::hide_standard_price_field') or setting_value('visiosoft.module.advs::market_place') != true ? ' d-none' %} + {% set HideStandardPrice = setting_value('visiosoft.module.advs::hide_standard_price_field') or setting_value('visiosoft.module.advs::market_place') != true ? ' d-none' : '' %}
-
+
{% set standardPriceValue = form.fields.standard_price.value|split('.') %} request->update_id])); + if (config('adv.preview_mode')) { + return redirect(route('advs_preview', [$this->request->update_id])); + } + + return redirect(route('adv_detail_seo', [$adv->slug, $adv->id])); + } /* New Create Adv */ @@ -1013,7 +1018,7 @@ class AdvsController extends PublicController 'visiosoft.module.advs::new-ad/new-create', compact( 'id', 'cats_d', 'cats', 'adv', 'custom_fields', 'options', - 'hidePrice','is_options', 'configurations', 'rawClassified' + 'hidePrice', 'is_options', 'configurations', 'rawClassified' ) ); } diff --git a/addons/default/visiosoft/profile-module/src/Profile/Profile/ProfileFormBuilder.php b/addons/default/visiosoft/profile-module/src/Profile/Profile/ProfileFormBuilder.php index edbb101ea..c0b0328ad 100644 --- a/addons/default/visiosoft/profile-module/src/Profile/Profile/ProfileFormBuilder.php +++ b/addons/default/visiosoft/profile-module/src/Profile/Profile/ProfileFormBuilder.php @@ -7,25 +7,6 @@ class ProfileFormBuilder extends FormBuilder { protected $model = UserModel::class; - protected $fields = [ - 'gsm_phone', - 'office_phone', - 'land_phone', - 'identification_number', - 'education' => [ - 'type' => 'anomaly.field_type.select', - 'config' => [ - 'handler' => 'Visiosoft\ProfileModule\OptionHandler\EducationOptions@handle', - ] - ], - 'education_part' => 'anomaly.field_type.select', - 'profession', - 'birthday', - 'register_type', - 'facebook_address', - 'google_address', - ]; - protected $actions = [ 'update' => [ 'text' => 'visiosoft.module.profile::button.update_profile' diff --git a/addons/default/visiosoft/profile-module/src/Profile/Profile/ProfileFormFields.php b/addons/default/visiosoft/profile-module/src/Profile/Profile/ProfileFormFields.php new file mode 100644 index 000000000..0434084fc --- /dev/null +++ b/addons/default/visiosoft/profile-module/src/Profile/Profile/ProfileFormFields.php @@ -0,0 +1,31 @@ + [ + 'type' => 'anomaly.field_type.select', + 'config' => [ + 'handler' => 'Visiosoft\ProfileModule\OptionHandler\EducationOptions@handle', + ] + ], + 'education_part' => 'anomaly.field_type.select', + 'profession', + 'birthday', + 'register_type', + 'facebook_address', + 'google_address', + ]; + + $assignments = $model->getAssignments(); + $builder->setFields(array_merge($fields, $assignments->notLocked()->fieldSlugs())); + } +}