Merge pull request #863 from openclassify/muammertop

profile education form edit
This commit is contained in:
spektra2147 2020-12-16 12:44:06 +03:00 committed by GitHub
commit 73f25cf317
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
45 changed files with 662 additions and 47 deletions

View File

@ -0,0 +1,8 @@
$("input[data-type='currency']").on('blur', function() {
const value = this.value.replace(/,/g, '');
this.value = parseFloat(value).toLocaleString('en-US', {
style: 'decimal',
maximumFractionDigits: 2,
minimumFractionDigits: 2
});
});

View File

@ -19,12 +19,14 @@
<input type="number" class="price-input form-control w-100"
value="{{ app.request.get('min_price') }}"
name="min_price" min="0"
data-type="currency"
placeholder="{{ trans('visiosoft.module.advs::field.min.name') }}">
</div>
<div class="col-md-4 p-1 pr-0 m-0">
<input class="price-input form-control w-100" type="number"
value="{{ app.request.get('max_price') }}"
name="max_price"
data-type="currency"
placeholder="{{ trans('visiosoft.module.advs::field.max.name') }}">
</div>
@ -41,4 +43,5 @@
</div>
</div>
</div>
{{ asset_script('visiosoft.module.advs::js/currency_format.js') }}
{% endif %}

View File

@ -0,0 +1,46 @@
<?php
use Anomaly\Streams\Platform\Database\Migration\Migration;
class VisiosoftModuleProfileCreateEducationStream extends Migration
{
/**
* This migration creates the stream.
* It should be deleted on rollback.
*
* @var bool
*/
protected $delete = true;
/**
* The stream definition.
*
* @var array
*/
protected $stream = [
'slug' => 'education',
'title_column' => 'name',
'translatable' => true,
'versionable' => false,
'trashable' => false,
'searchable' => false,
'sortable' => false,
];
/**
* The stream assignments.
*
* @var array
*/
protected $assignments = [
'name' => [
'translatable' => true,
'required' => true,
],
'slug' => [
'unique' => true,
'required' => true,
],
];
}

View File

@ -0,0 +1,59 @@
<?php
use Anomaly\Streams\Platform\Database\Migration\Migration;
use Visiosoft\ProfileModule\Education\EducationModel;
class VisiosoftModuleProfileCreateEducationPartStream extends Migration
{
/**
* This migration creates the stream.
* It should be deleted on rollback.
*
* @var bool
*/
protected $delete = true;
/**
* The stream definition.
*
* @var array
*/
protected $stream = [
'slug' => 'education_part',
'title_column' => 'name',
'translatable' => true,
'versionable' => false,
'trashable' => false,
'searchable' => false,
'sortable' => false,
];
/**
* The stream assignments.
*
* @var array
*/
protected $assignments = [
'education' => [
'required' => true,
],
'name' => [
'translatable' => true,
'required' => true,
],
'slug' => [
'unique' => true,
'required' => true,
],
];
protected $fields = [
'education' => [
'type' => 'anomaly.field_type.relationship',
'config' => [
'related' => EducationModel::class,
]
]
];
}

View File

@ -0,0 +1,31 @@
$(() => {
$.ajax({
url: '/api/getEducation',
success: ((res)=>{
$.each(res['education-part'], function (key, value) {
var selected = ""
if (res.user.education_part == value.id){ selected = 'selected'; }
$('#education_part').append('<option '+ selected +' value="'+ value.id +'">' + value.name + '</option>')
})
})
})
$('#education').on('change', () => {
$.ajax({
url: '/api/changeEducation',
data: {
info: 'education',
education: $('#education').val()
},beforeSend: function (){
$('#education_part').html('');
},success: function (response) {
$('#education_part').html('<option value="">'+ choose_an_option +'</option>')
$.each(response.data, function (key, value) {
$('#education_part').append(
'<option value="'+ value.id +'">'+ value.name +'</option>'
)
})
}
});
})
})

View File

@ -6,4 +6,14 @@ return [
'write',
'delete',
],
'education' => [
'read',
'write',
'delete',
],
'education_part' => [
'read',
'write',
'delete',
],
];

View File

@ -15,4 +15,6 @@ return [
'personal' => 'Personal',
'corporate' => 'Corporate',
'export' => 'Export',
'new_education' => 'New Education',
'new_education_part' => 'New Education part',
];

View File

@ -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'
],
];

View File

@ -17,4 +17,20 @@ return [
'delete' => 'Can delete adress?',
],
],
'education' => [
'name' => 'Education',
'option' => [
'read' => 'Can read education?',
'write' => 'Can create/edit education?',
'delete' => 'Can delete education?',
],
],
'education_part' => [
'name' => 'Education part',
'option' => [
'read' => 'Can read education part?',
'write' => 'Can create/edit education part?',
'delete' => 'Can delete education part?',
],
],
];

View File

@ -9,4 +9,10 @@ return [
],
'general_setting' => 'General Settings',
'recaptcha' => 'reCAPTCHA',
'education' => [
'title' => 'Education',
],
'education_part' => [
'title' => 'Education part',
],
];

View File

@ -7,4 +7,10 @@ return [
'adress' => [
'name' => 'Address',
],
'education' => [
'name' => 'Education',
],
'education_part' => [
'name' => 'Education part',
],
];

View File

@ -171,40 +171,15 @@
<label class="control-label font-weight-bold">
{{ trans("visiosoft.module.profile::field.education.name") }}
</label>
{{ profileForm.fields.education.value.input|raw }}
<select name="education" class="custom-select form-control"
data-field="education" data-field_name="education"
data-provides="anomaly.field_type.select" id="education">
<option value="">
{{ trans('visiosoft.module.profile::field.choose_an_option') }}
</option>
{% for education in setting_value('visiosoft.module.profile::education') %}
<option value="{{ education }}"
{{ profileForm.fields.education.value == education ? 'selected' }}>
{{ education }}
</option>
{% endfor %}
</select>
{{ profileForm.fields.education.setPlaceholder(trans('visiosoft.module.profile::field.choose_an_option')).input|raw }}
</div>
</div>
<div class="col-md-12">
<div class="form-group state_of_education-field">
<div class="form-group education-part-field">
<label class="control-label font-weight-bold">
{{ trans("visiosoft.module.profile::field.state_of_education.name") }}
{{ trans("visiosoft.module.profile::field.education_part.name") }}
</label>
<select name="state_of_education" class="custom-select form-control"
data-field="state_of_education" data-field_name="state_of_education"
data-provides="anomaly.field_type.select" id="state_of_education">
<option value="">
{{ trans('visiosoft.module.profile::field.choose_an_option') }}
</option>
{% for state_of_education in setting_value('visiosoft.module.profile::state_of_education') %}
<option value="{{ state_of_education }}"
{{ profileForm.fields.state_of_education.value == state_of_education ? 'selected' }}>
{{ state_of_education }}
</option>
{% endfor %}
</select>
{{ profileForm.fields.education_part.setPlaceholder(trans('visiosoft.module.profile::field.choose_an_option')).input|raw }}
</div>
</div>
<div class="col-md-12">
@ -246,6 +221,7 @@
</div>
{{ profileForm.close()|raw }}
</div>
</div>
<div class="tab-pane fade" id="nav-password" role="tabpanel" aria-labelledby="nav-password-tab">
{% set passwordForm = form('updatePassword').get() %}
@ -280,8 +256,12 @@
<!-- User Profile Form Section-->
</div>
</div>
<script>
var choose_an_option = "{{ trans('visiosoft.module.profile::field.choose_an_option') }}"
</script>
{% endblock %}
{% endembed %}
{{ asset_script("visiosoft.module.profile::assets/js/education.js") }}
{{ asset_add("scripts.js", "visiosoft.module.profile::assets/js/profile.js") }}
{% endblock %}

View File

@ -0,0 +1,8 @@
<?php namespace Visiosoft\ProfileModule\Education\Contract;
use Anomaly\Streams\Platform\Entry\Contract\EntryInterface;
interface EducationInterface extends EntryInterface
{
}

View File

@ -0,0 +1,8 @@
<?php namespace Visiosoft\ProfileModule\Education\Contract;
use Anomaly\Streams\Platform\Entry\Contract\EntryRepositoryInterface;
interface EducationRepositoryInterface extends EntryRepositoryInterface
{
}

View File

@ -0,0 +1,8 @@
<?php namespace Visiosoft\ProfileModule\Education;
use Anomaly\Streams\Platform\Entry\EntryCollection;
class EducationCollection extends EntryCollection
{
}

View File

@ -0,0 +1,8 @@
<?php namespace Visiosoft\ProfileModule\Education;
use Anomaly\Streams\Platform\Entry\EntryCriteria;
class EducationCriteria extends EntryCriteria
{
}

View File

@ -0,0 +1,9 @@
<?php namespace Visiosoft\ProfileModule\Education;
use Visiosoft\ProfileModule\Education\Contract\EducationInterface;
use Anomaly\Streams\Platform\Model\Profile\ProfileEducationEntryModel;
class EducationModel extends ProfileEducationEntryModel implements EducationInterface
{
}

View File

@ -0,0 +1,8 @@
<?php namespace Visiosoft\ProfileModule\Education;
use Anomaly\Streams\Platform\Entry\EntryObserver;
class EducationObserver extends EntryObserver
{
}

View File

@ -0,0 +1,8 @@
<?php namespace Visiosoft\ProfileModule\Education;
use Anomaly\Streams\Platform\Entry\EntryPresenter;
class EducationPresenter extends EntryPresenter
{
}

View File

@ -0,0 +1,25 @@
<?php namespace Visiosoft\ProfileModule\Education;
use Visiosoft\ProfileModule\Education\Contract\EducationRepositoryInterface;
use Anomaly\Streams\Platform\Entry\EntryRepository;
class EducationRepository extends EntryRepository implements EducationRepositoryInterface
{
/**
* The entry model.
*
* @var EducationModel
*/
protected $model;
/**
* Create a new EducationRepository instance.
*
* @param EducationModel $model
*/
public function __construct(EducationModel $model)
{
$this->model = $model;
}
}

View File

@ -0,0 +1,8 @@
<?php namespace Visiosoft\ProfileModule\Education;
use Anomaly\Streams\Platform\Entry\EntryRouter;
class EducationRouter extends EntryRouter
{
}

View File

@ -0,0 +1,15 @@
<?php namespace Visiosoft\ProfileModule\Education;
use Anomaly\Streams\Platform\Database\Seeder\Seeder;
class EducationSeeder extends Seeder
{
/**
* Run the seeder.
*/
public function run()
{
//
}
}

View File

@ -0,0 +1,15 @@
<?php namespace Visiosoft\ProfileModule\Education\Form;
use Anomaly\Streams\Platform\Ui\Form\FormBuilder;
class EducationFormBuilder extends FormBuilder
{
/**
* The form buttons.
*
* @var array|string
*/
protected $buttons = [
'cancel',
];
}

View File

@ -0,0 +1,24 @@
<?php namespace Visiosoft\ProfileModule\Education\Table;
use Anomaly\Streams\Platform\Ui\Table\TableBuilder;
class EducationTableBuilder extends TableBuilder
{
/**
* The table buttons.
*
* @var array|string
*/
protected $buttons = [
'edit'
];
/**
* The table actions.
*
* @var array|string
*/
protected $actions = [
'delete'
];
}

View File

@ -0,0 +1,8 @@
<?php namespace Visiosoft\ProfileModule\EducationPart\Contract;
use Anomaly\Streams\Platform\Entry\Contract\EntryInterface;
interface EducationPartInterface extends EntryInterface
{
}

View File

@ -0,0 +1,8 @@
<?php namespace Visiosoft\ProfileModule\EducationPart\Contract;
use Anomaly\Streams\Platform\Entry\Contract\EntryRepositoryInterface;
interface EducationPartRepositoryInterface extends EntryRepositoryInterface
{
}

View File

@ -0,0 +1,8 @@
<?php namespace Visiosoft\ProfileModule\EducationPart;
use Anomaly\Streams\Platform\Entry\EntryCollection;
class EducationPartCollection extends EntryCollection
{
}

View File

@ -0,0 +1,8 @@
<?php namespace Visiosoft\ProfileModule\EducationPart;
use Anomaly\Streams\Platform\Entry\EntryCriteria;
class EducationPartCriteria extends EntryCriteria
{
}

View File

@ -0,0 +1,9 @@
<?php namespace Visiosoft\ProfileModule\EducationPart;
use Visiosoft\ProfileModule\EducationPart\Contract\EducationPartInterface;
use Anomaly\Streams\Platform\Model\Profile\ProfileEducationPartEntryModel;
class EducationPartModel extends ProfileEducationPartEntryModel implements EducationPartInterface
{
}

View File

@ -0,0 +1,8 @@
<?php namespace Visiosoft\ProfileModule\EducationPart;
use Anomaly\Streams\Platform\Entry\EntryObserver;
class EducationPartObserver extends EntryObserver
{
}

View File

@ -0,0 +1,8 @@
<?php namespace Visiosoft\ProfileModule\EducationPart;
use Anomaly\Streams\Platform\Entry\EntryPresenter;
class EducationPartPresenter extends EntryPresenter
{
}

View File

@ -0,0 +1,25 @@
<?php namespace Visiosoft\ProfileModule\EducationPart;
use Visiosoft\ProfileModule\EducationPart\Contract\EducationPartRepositoryInterface;
use Anomaly\Streams\Platform\Entry\EntryRepository;
class EducationPartRepository extends EntryRepository implements EducationPartRepositoryInterface
{
/**
* The entry model.
*
* @var EducationPartModel
*/
protected $model;
/**
* Create a new EducationPartRepository instance.
*
* @param EducationPartModel $model
*/
public function __construct(EducationPartModel $model)
{
$this->model = $model;
}
}

View File

@ -0,0 +1,8 @@
<?php namespace Visiosoft\ProfileModule\EducationPart;
use Anomaly\Streams\Platform\Entry\EntryRouter;
class EducationPartRouter extends EntryRouter
{
}

View File

@ -0,0 +1,15 @@
<?php namespace Visiosoft\ProfileModule\EducationPart;
use Anomaly\Streams\Platform\Database\Seeder\Seeder;
class EducationPartSeeder extends Seeder
{
/**
* Run the seeder.
*/
public function run()
{
//
}
}

View File

@ -0,0 +1,15 @@
<?php namespace Visiosoft\ProfileModule\EducationPart\Form;
use Anomaly\Streams\Platform\Ui\Form\FormBuilder;
class EducationPartFormBuilder extends FormBuilder
{
/**
* The form buttons.
*
* @var array|string
*/
protected $buttons = [
'cancel',
];
}

View File

@ -0,0 +1,24 @@
<?php namespace Visiosoft\ProfileModule\EducationPart\Table;
use Anomaly\Streams\Platform\Ui\Table\TableBuilder;
class EducationPartTableBuilder extends TableBuilder
{
/**
* The table buttons.
*
* @var array|string
*/
protected $buttons = [
'edit'
];
/**
* The table actions.
*
* @var array|string
*/
protected $actions = [
'delete'
];
}

View File

@ -0,0 +1,43 @@
<?php namespace Visiosoft\ProfileModule\Http\Controller\Admin;
use Visiosoft\ProfileModule\Education\Form\EducationFormBuilder;
use Visiosoft\ProfileModule\Education\Table\EducationTableBuilder;
use Anomaly\Streams\Platform\Http\Controller\AdminController;
class EducationController extends AdminController
{
/**
* Display an index of existing entries.
*
* @param EducationTableBuilder $table
* @return \Symfony\Component\HttpFoundation\Response
*/
public function index(EducationTableBuilder $table)
{
return $table->render();
}
/**
* Create a new entry.
*
* @param EducationFormBuilder $form
* @return \Symfony\Component\HttpFoundation\Response
*/
public function create(EducationFormBuilder $form)
{
return $form->render();
}
/**
* Edit an existing entry.
*
* @param EducationFormBuilder $form
* @param $id
* @return \Symfony\Component\HttpFoundation\Response
*/
public function edit(EducationFormBuilder $form, $id)
{
return $form->render($id);
}
}

View File

@ -0,0 +1,43 @@
<?php namespace Visiosoft\ProfileModule\Http\Controller\Admin;
use Visiosoft\ProfileModule\EducationPart\Form\EducationPartFormBuilder;
use Visiosoft\ProfileModule\EducationPart\Table\EducationPartTableBuilder;
use Anomaly\Streams\Platform\Http\Controller\AdminController;
class EducationPartController extends AdminController
{
/**
* Display an index of existing entries.
*
* @param EducationPartTableBuilder $table
* @return \Symfony\Component\HttpFoundation\Response
*/
public function index(EducationPartTableBuilder $table)
{
return $table->render();
}
/**
* Create a new entry.
*
* @param EducationPartFormBuilder $form
* @return \Symfony\Component\HttpFoundation\Response
*/
public function create(EducationPartFormBuilder $form)
{
return $form->render();
}
/**
* Edit an existing entry.
*
* @param EducationPartFormBuilder $form
* @param $id
* @return \Symfony\Component\HttpFoundation\Response
*/
public function edit(EducationPartFormBuilder $form, $id)
{
return $form->render($id);
}
}

View File

@ -24,6 +24,9 @@ use Visiosoft\PackagesModule\User\UserModel;
use Visiosoft\ProfileModule\Adress\AdressModel;
use Visiosoft\ProfileModule\Adress\Contract\AdressRepositoryInterface;
use Visiosoft\ProfileModule\Adress\Form\AdressFormBuilder;
use Visiosoft\ProfileModule\Education\EducationModel;
use Visiosoft\ProfileModule\EducationPart\EducationPartModel;
use Visiosoft\ProfileModule\EducationPartOption\EducationPartOptionModel;
use Visiosoft\ProfileModule\Profile\Form\ProfileFormBuilder;
use Illuminate\Contracts\Events\Dispatcher;
@ -246,4 +249,19 @@ class MyProfileController extends PublicController
return response()->json(['status' => 'success', 'data' => $profile]);
}
public function getEducation(Request $request)
{
$user = $this->userRepository->find(auth()->id());
$education = EducationModel::all();
$educationPart = EducationPartModel::query()->where('education_id', $user->education)->get();
return response()->json(['user' => $user, 'education' => $education, 'education-part' => $educationPart], 200);
}
public function changeEducation(Request $request)
{
if ($request->info == 'education') {
$education = EducationPartModel::query()->where('education_id', $request->education)->get();
}
return response()->json(['data' => $education], 200);
}
}

View File

@ -0,0 +1,21 @@
<?php namespace Visiosoft\ProfileModule\OptionHandler;
use Anomaly\SelectFieldType\SelectFieldType;
use Visiosoft\ProfileModule\Education\Contract\EducationRepositoryInterface;
class EducationOptions
{
private $educationRepository;
public function __construct(EducationRepositoryInterface $repository)
{
$this->educationRepository = $repository;
}
public function handle(SelectFieldType $fieldType)
{
$educations = $this->educationRepository->all();
$options = $educations->pluck('name', 'id')->all();
$fieldType->setOptions($options);
}
}

View File

@ -13,8 +13,13 @@ class ProfileFormBuilder extends FormBuilder
'office_phone',
'land_phone',
'identification_number',
'education',
'state_of_education',
'education' => [
'type' => 'anomaly.field_type.select',
'config' => [
'handler' => 'Visiosoft\ProfileModule\OptionHandler\EducationOptions@handle',
]
],
'education_part' => 'anomaly.field_type.select',
'profession',
'birthday',
'register_type',

View File

@ -30,7 +30,7 @@ class ProfileFormHandler
if (setting_value('visiosoft.module.profile::show_education_profession')) {
$parameters = array_merge($parameters, [
'education' => $builder->getPostValue('education'),
'state_of_education' => $builder->getPostValue('state_of_education'),
'education_part' => $builder->getPostValue('education_part'),
'profession' => $builder->getPostValue('profession'),
]);
}

View File

@ -30,6 +30,16 @@ class ProfileModule extends Module
'new_adress',
],
],
'education' => [
'buttons' => [
'new_education',
]
],
'education_part' => [
'buttons' => [
'new_education_part',
]
],
];
}

View File

@ -2,6 +2,7 @@
use Anomaly\Streams\Platform\Addon\AddonCollection;
use Anomaly\Streams\Platform\Addon\AddonServiceProvider;
use Anomaly\Streams\Platform\Model\Profile\ProfileEducationEntryModel;
use Maatwebsite\Excel\ExcelServiceProvider;
use Maatwebsite\Excel\Facades\Excel;
use Visiosoft\ProfileModule\Adress\Contract\AdressRepositoryInterface;
@ -10,6 +11,9 @@ use Anomaly\Streams\Platform\Model\Profile\ProfileAdressEntryModel;
use Visiosoft\ProfileModule\Adress\AdressModel;
use Visiosoft\ProfileModule\Adress\Form\AdressFormBuilder;
use Visiosoft\ProfileModule\Adress\FormCompany\AddressCompanyFormBuilder;
use Visiosoft\ProfileModule\Education\Contract\EducationRepositoryInterface;
use Visiosoft\ProfileModule\Education\EducationModel;
use Visiosoft\ProfileModule\Education\EducationRepository;
use Visiosoft\ProfileModule\Http\Middleware\authCheck;
use Visiosoft\ProfileModule\Profile\Password\ForgotPassFormBuilder;
use Visiosoft\ProfileModule\Profile\Password\PasswordFormBuilder;
@ -101,6 +105,8 @@ class ProfileModuleServiceProvider extends AddonServiceProvider
],
'profile/notification' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@notification',
'ajax/update-user-info' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@updateAjaxProfile',
'api/changeEducation' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@changeEducation',
'api/getEducation' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@getEducation',
// UserAuthenticator
'login-in' => 'Visiosoft\ProfileModule\Http\Controller\UserAuthenticator@attempt',
@ -201,6 +207,7 @@ class ProfileModuleServiceProvider extends AddonServiceProvider
'address' => AdressFormBuilder::class,
'addressCompany' => AddressCompanyFormBuilder::class,
ProfileAdressEntryModel::class => AdressModel::class,
ProfileEducationEntryModel::class => EducationModel::class,
];
/**
@ -210,6 +217,7 @@ class ProfileModuleServiceProvider extends AddonServiceProvider
*/
protected $singletons = [
AdressRepositoryInterface::class => AdressRepository::class,
EducationRepositoryInterface::class => EducationRepository::class,
'register2' => Register2FormBuilder::class,
'sites' => SitesFormBuilder::class,
'forgot_pass' => ForgotPassFormBuilder::class,

View File

@ -124,21 +124,26 @@ 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.text',
],
[
'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.facebook_address.name'),
'slug' => 'facebook_address',