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

@ -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,9 +930,14 @@ class AdvsController extends PublicController
event(new EditedAd($before_editing, $adv)); event(new EditedAd($before_editing, $adv));
} }
if (config('adv.preview_mode')) {
return redirect(route('advs_preview', [$this->request->update_id])); 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 */
$this->request->publish_at = date('Y-m-d H:i:s'); $this->request->publish_at = date('Y-m-d H:i:s');
$all = $this->request->all(); $all = $this->request->all();
@ -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()));
}
}