Merge pull request #1213 from openclassify/vedat

optional preview && dynamic profile fields
This commit is contained in:
Fatih Alp 2021-10-26 18:41:36 +03:00 committed by GitHub
commit 602fa815de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 57 additions and 28 deletions

View File

@ -24,6 +24,7 @@ return [
'ads' => [ 'ads' => [
'title' => 'visiosoft.module.advs::section.ads', 'title' => 'visiosoft.module.advs::section.ads',
'fields' => [ 'fields' => [
'preview_mode',
'show_finish_and_publish_date', 'show_finish_and_publish_date',
'latest-limit', 'latest-limit',
'popular_ads_limit', 'popular_ads_limit',

View File

@ -493,4 +493,11 @@ return [
'default_value' => false, 'default_value' => false,
] ]
], ],
'preview_mode' => [
'type' => 'anomaly.field_type.boolean',
'bind' => 'adv.preview_mode',
'config' => [
'default_value' => true,
],
],
]; ];

View File

@ -136,7 +136,7 @@ return [
], ],
'market_place' => [ 'market_place' => [
'name' => '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 some fields in the profile such as ads, dopings, messages, sale, packages and store are not visible and
removes corporate membership.' removes corporate membership.'
], ],
@ -283,9 +283,9 @@ return [
'name' => 'Show Tax Field', 'name' => 'Show Tax Field',
'instructions' => 'When this option is enabled, you can set the tax rate on the ad creation page.' 'instructions' => 'When this option is enabled, you can set the tax rate on the ad creation page.'
], ],
'hide_contact_created_at' => [ 'hide_contact_created_at' => [
'name' => 'Hide Contact Fields For in Create New Ad' 'name' => 'Hide Contact Fields For in Create New Ad'
], ],
'show_input_flag' => [ 'show_input_flag' => [
'name' => 'Show Flags on Input', 'name' => 'Show Flags on Input',
'instructions' => 'Show flag and description on translatable inputs' 'instructions' => 'Show flag and description on translatable inputs'
@ -296,5 +296,9 @@ return [
], ],
'only_email_login' => [ 'only_email_login' => [
'name' => '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.'
],
]; ];

View File

@ -107,7 +107,7 @@
</div> </div>
</div> </div>
<div class="select-price"> <div class="select-price">
{% 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' : '' %}
<label> <label>
<span class="{{ HideStandardPrice }}"> <span class="{{ HideStandardPrice }}">
@ -123,7 +123,7 @@
</div> </div>
<div class="d-flex"> <div class="d-flex">
<div class="d-flex flex-fill {{ HideStandardPrice }}"> <div class=" flex-fill {{ (HideStandardPrice) ? HideStandardPrice : 'd-flex' }}">
{% set standardPriceValue = form.fields.standard_price.value|split('.') %} {% set standardPriceValue = form.fields.standard_price.value|split('.') %}
<input class="mt-3 border-0 text-right standard-price-field whole-price flex-fill" <input class="mt-3 border-0 text-right standard-price-field whole-price flex-fill"
placeholder="0" value="{{ standardPriceValue|first }}" placeholder="0" value="{{ standardPriceValue|first }}"

View File

@ -930,7 +930,12 @@ class AdvsController extends PublicController
event(new EditedAd($before_editing, $adv)); event(new EditedAd($before_editing, $adv));
} }
return redirect(route('advs_preview', [$this->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 */ /* New Create Adv */
@ -1017,7 +1022,7 @@ class AdvsController extends PublicController
'visiosoft.module.advs::new-ad/new-create', 'visiosoft.module.advs::new-ad/new-create',
compact( compact(
'id', 'cats_d', 'cats', 'adv', 'custom_fields', 'options', 'id', 'cats_d', 'cats', 'adv', 'custom_fields', 'options',
'hidePrice','is_options', 'configurations', 'rawClassified' 'hidePrice', 'is_options', 'configurations', 'rawClassified'
) )
); );
} }

View File

@ -7,25 +7,6 @@ class ProfileFormBuilder extends FormBuilder
{ {
protected $model = UserModel::class; 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 = [ protected $actions = [
'update' => [ 'update' => [
'text' => 'visiosoft.module.profile::button.update_profile' 'text' => 'visiosoft.module.profile::button.update_profile'

View File

@ -0,0 +1,31 @@
<?php namespace Visiosoft\ProfileModule\Profile\Profile;
use Anomaly\UsersModule\User\UserModel;
class ProfileFormFields
{
public function handle(ProfileFormBuilder $builder, UserModel $model)
{
$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',
];
$assignments = $model->getAssignments();
$builder->setFields(array_merge($fields, $assignments->notLocked()->fieldSlugs()));
}
}