mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-24 22:11:01 -06:00
Merge pull request #390 from openclassify/dia
fix profile address in the admin panel
This commit is contained in:
commit
eec29c875b
@ -0,0 +1,64 @@
|
|||||||
|
new Promise(function (resolve, reject) {
|
||||||
|
if (parseInt(default_country)) {
|
||||||
|
getCities(parseInt(default_country));
|
||||||
|
$('select[name="country"]').val(default_country);
|
||||||
|
resolve(true);
|
||||||
|
}
|
||||||
|
}).then(function (resolve) {
|
||||||
|
if (resolve) {
|
||||||
|
if (parseInt(default_city)) {
|
||||||
|
getDistricts(parseInt(default_city));
|
||||||
|
$('select[name="city"]').val(default_city);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).then(function (resolve) {
|
||||||
|
if (resolve) {
|
||||||
|
if (parseInt(default_district)) {
|
||||||
|
getNeighborhoods(parseInt(default_district));
|
||||||
|
$('select[name="district"]').val(default_district);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function getCities(country) {
|
||||||
|
crud('id=' + country, '/ajax/getCities', 'POST', function (callback) {
|
||||||
|
cities = callback;
|
||||||
|
$('select[name="city"]').html("<option>" + pick_option + "</option>");
|
||||||
|
$.each(cities, function (index, value) {
|
||||||
|
$('select[name="city"]').append("<option value='" + value.id + "'>" + value.name + "</option>");
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDistricts(city) {
|
||||||
|
crud('id=' + city, '/ajax/getDistricts', 'POST', function (callback) {
|
||||||
|
cities = callback;
|
||||||
|
$('select[name="district"]').html("<option>" + pick_option + "</option>");
|
||||||
|
$.each(cities, function (index, value) {
|
||||||
|
$('select[name="district"]').append("<option value='" + value.id + "'>" + value.name + "</option>");
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).on('change', 'select[name="country"]', function () {
|
||||||
|
getCities($(this).val());
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('change', 'select[name="city"]', function () {
|
||||||
|
getDistricts($(this).val())
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function crud(params, url, type, callback) {
|
||||||
|
$.ajax({
|
||||||
|
type: type,
|
||||||
|
data: params,
|
||||||
|
async: false,
|
||||||
|
url: url,
|
||||||
|
success: function (response) {
|
||||||
|
callback(response);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
{% if form.options.title or form.options.description %}
|
||||||
|
<div class="card">
|
||||||
|
|
||||||
|
{% if form.options.title %}
|
||||||
|
<div class="card-block">
|
||||||
|
<h4 class="card-title">
|
||||||
|
{{ trans(form.options.title)|raw }}
|
||||||
|
|
||||||
|
{% if form.options.description %}
|
||||||
|
<small>
|
||||||
|
<br>{{ trans(form.options.description)|raw }}
|
||||||
|
</small>
|
||||||
|
{% endif %}
|
||||||
|
</h4>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var default_country = "{{ setting_value('visiosoft.module.location::default_country') }}";
|
||||||
|
var default_city = "{{ setting_value('visiosoft.module.location::default_city') }}";
|
||||||
|
var default_district = "{{ setting_value('visiosoft.module.location::default_district') }}";
|
||||||
|
var pick_option = "{{ trans('visiosoft.module.location::field.pick_option.name') }}"
|
||||||
|
</script>
|
||||||
|
{{ asset_add("scripts.js","visiosoft.module.profile::assets/js/location.js") }}
|
||||||
@ -1,7 +1,6 @@
|
|||||||
<?php namespace Visiosoft\ProfileModule\Adress\Table;
|
<?php namespace Visiosoft\ProfileModule\Adress\Table;
|
||||||
|
|
||||||
use Anomaly\Streams\Platform\Ui\Table\TableBuilder;
|
use Anomaly\Streams\Platform\Ui\Table\TableBuilder;
|
||||||
use Visiosoft\AdvsModule\Adv\Table\Filter\UserFilterQuery;
|
|
||||||
|
|
||||||
class AdressTableBuilder extends TableBuilder
|
class AdressTableBuilder extends TableBuilder
|
||||||
{
|
{
|
||||||
@ -23,7 +22,7 @@ class AdressTableBuilder extends TableBuilder
|
|||||||
'search' => [
|
'search' => [
|
||||||
'filter' => 'search',
|
'filter' => 'search',
|
||||||
'fields' => [
|
'fields' => [
|
||||||
'user',
|
'adress_name',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
@ -34,7 +33,10 @@ class AdressTableBuilder extends TableBuilder
|
|||||||
* @var array|string
|
* @var array|string
|
||||||
*/
|
*/
|
||||||
protected $columns = [
|
protected $columns = [
|
||||||
'first_name','last_name','email'
|
'first_name' => 'entry.user.first_name',
|
||||||
|
'last_name' => 'entry.user.last_name',
|
||||||
|
'adress_name',
|
||||||
|
'adress_gsm_phone'
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
<?php namespace Visiosoft\ProfileModule\Http\Controller\Admin;
|
<?php namespace Visiosoft\ProfileModule\Http\Controller\Admin;
|
||||||
|
|
||||||
|
use Anomaly\Streams\Platform\Entry\Contract\EntryInterface;
|
||||||
use Anomaly\Streams\Platform\Model\Profile\ProfileAdressEntryModel;
|
use Anomaly\Streams\Platform\Model\Profile\ProfileAdressEntryModel;
|
||||||
use Anomaly\Streams\Platform\Model\Users\UsersUsersEntryModel;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Visiosoft\LocationModule\Country\CountryModel;
|
use Visiosoft\LocationModule\City\Contract\CityRepositoryInterface;
|
||||||
use Visiosoft\ProfileModule\Adress\AdressModel;
|
|
||||||
use Visiosoft\ProfileModule\Adress\Form\AdressFormBuilder;
|
use Visiosoft\ProfileModule\Adress\Form\AdressFormBuilder;
|
||||||
use Visiosoft\ProfileModule\Adress\Table\AdressTableBuilder;
|
use Visiosoft\ProfileModule\Adress\Table\AdressTableBuilder;
|
||||||
use Anomaly\Streams\Platform\Http\Controller\AdminController;
|
use Anomaly\Streams\Platform\Http\Controller\AdminController;
|
||||||
@ -20,8 +19,14 @@ class AdressController extends AdminController
|
|||||||
*/
|
*/
|
||||||
public function index(AdressTableBuilder $table)
|
public function index(AdressTableBuilder $table)
|
||||||
{
|
{
|
||||||
$users = UsersUsersEntryModel::query()->get();
|
$table->setColumns(array_merge($table->getColumns(), [
|
||||||
$table->setTableEntries($users);
|
'city' => [
|
||||||
|
'value' => function (EntryInterface $entry, CityRepositoryInterface $cityRepository) {
|
||||||
|
return $cityRepository->find($entry->city)->name;
|
||||||
|
},
|
||||||
|
],
|
||||||
|
]));
|
||||||
|
|
||||||
return $table->render();
|
return $table->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +38,9 @@ class AdressController extends AdminController
|
|||||||
*/
|
*/
|
||||||
public function create(AdressFormBuilder $form)
|
public function create(AdressFormBuilder $form)
|
||||||
{
|
{
|
||||||
return $this->view->make('visiosoft.module.profile::admin/adress/create');
|
$form->setOption('heading', "visiosoft.module.profile::field");
|
||||||
|
|
||||||
|
return $form->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,9 +52,9 @@ class AdressController extends AdminController
|
|||||||
*/
|
*/
|
||||||
public function edit(AdressFormBuilder $form, $id)
|
public function edit(AdressFormBuilder $form, $id)
|
||||||
{
|
{
|
||||||
$adress = ProfileAdressEntryModel::query()->find($id);
|
$form->setOption('heading', "visiosoft.module.profile::field");
|
||||||
$country = CountryModel::all();
|
|
||||||
return $this->view->make('visiosoft.module.profile::admin/adress/edit',compact('adress','country'));
|
return $form->render($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function adresList(AdressTableBuilder $table, $id)
|
public function adresList(AdressTableBuilder $table, $id)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user