This commit is contained in:
vedatakd 2020-12-30 13:06:00 +03:00
commit 4156476756
18 changed files with 271 additions and 11 deletions

View File

@ -46,4 +46,9 @@ return [
'write', 'write',
'delete', 'delete',
], ],
'status' => [
'read',
'write',
'delete',
],
]; ];

View File

@ -0,0 +1,32 @@
function getUrlParameter(sParam) {
var sPageURL = window.location.search.substring(1),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
}
}
};
if (getUrlParameter('view') === "advanced") {
$('.fast-update').on('change', function () {
var advanced_value = $(this).val(), advanced_entry_id = $(this).data('entry_id'),
advanced_column = $(this).data('column'), advanced_type = $(this).attr('type');
if (advanced_type === "checkbox") {
advanced_value = ($(this).prop('checked')) ? 1 : 0;
}
crudAjax({
'advanced_column': advanced_column,
'advanced_entry_id': advanced_entry_id,
'advanced_value': advanced_value
}, advanced_update_url, 'POST')
})
}

View File

@ -43,4 +43,5 @@ return [
'fast_create' => 'Fast create', 'fast_create' => 'Fast create',
'publish' => 'Publish', 'publish' => 'Publish',
'import' => 'Import', 'import' => 'Import',
'new_status' => 'New Status',
]; ];

View File

@ -97,4 +97,12 @@ return [
'delete' => 'Can delete option configuration?', 'delete' => 'Can delete option configuration?',
], ],
], ],
'status' => [
'name' => 'Status',
'option' => [
'read' => 'Can read status?',
'write' => 'Can create/edit status?',
'delete' => 'Can delete status?',
],
],
]; ];

View File

@ -56,4 +56,7 @@ return [
'title' => 'Configuration', 'title' => 'Configuration',
], ],
'translations' => 'Translations', 'translations' => 'Translations',
'status' => [
'title' => 'Status',
],
]; ];

View File

@ -31,4 +31,7 @@ return [
'option_configuration' => [ 'option_configuration' => [
'name' => 'Configuration', 'name' => 'Configuration',
], ],
'status' => [
'name' => 'Status',
],
]; ];

View File

@ -2,4 +2,5 @@
return [ return [
'unfinished' => 'Unfinished', 'unfinished' => 'Unfinished',
'advanced' => 'Advanced',
]; ];

View File

@ -2,4 +2,5 @@
return [ return [
'unfinished' => 'Bitmemiş', 'unfinished' => 'Bitmemiş',
'advanced' => 'Gelişmiş',
]; ];

View File

@ -0,0 +1,90 @@
{{ asset_add("scripts.js", "streams::js/table/table.js") }}
{% if not actions.empty() %}
{{ asset_add("scripts.js", "streams::js/table/actions.js") }}
{% endif %}
{% if table.options.sortable %}
{{ asset_add("scripts.js", "streams::js/table/sortable.js") }}
{% endif %}
<div class="{{ table.options.container_class ?: 'container-fluid' }}">
{{ view("streams::table/partials/filters", {'table': table}) }}
{{ view("streams::table/partials/views", {'table': table}) }}
{{ view(table.options.heading ?: "streams::table/partials/heading", {'table': table}) }}
{% if not table.rows.empty() %}
{% block card %}
<div class="card">
{{ form_open({ 'url': url_full() }) }}
<div class="table-stack">
<table
class="
{{ table.options.class ?: 'table' }}
{{ table.options.sortable ? 'table--sortable' }}
"
{{ table.options.sortable ? 'data-sortable' }}
{{ html_attributes(table.options.attributes) }}>
{{ view("streams::table/partials/header", {'table': table}) }}
{% block body %}
<tbody>
{% for row in table.rows %}
<tr id="{{ loop.index }}" class="{{ row.class }}">
{% if table.options.sortable %}
<td>
{{ icon('fa fa-arrows handle') }}
<input type="hidden" name="{{ row.table.options.prefix }}order[]" value="{{ row.key }}"/>
</td>
{% endif %}
{% if not table.actions.empty() %}
<td>
<input type="checkbox" data-toggle="action" name="{{ row.table.options.prefix }}id[]" value="{{ row.key }}"/>
</td>
{% endif %}
{% for column in row.columns %}
<td data-title="{{ trans(column.heading) }}"
class="{{ column.class }}" {{ html_attributes(column.attributes) }}>
{{ (column.attributes.html) ? column.attributes.html|raw : column.value|raw }}
</td>
{% endfor %}
<td class="text-lg-right">
<nobr>{{ buttons(row.buttons)|raw }}</nobr>
</td>
</tr>
{% endfor %}
</tbody>
{% endblock %}
{{ view("streams::table/partials/footer", {'table': table}) }}
</table>
</div>
{{ form_close() }}
</div>
{% endblock %}
{% else %}
{% block no_results %}
<div class="card">
<div class="card-block card-body">
{{ trans(table.options.get('no_results_message', 'streams::message.no_results')) }}
</div>
</div>
{% endblock %}
{% endif %}
</div>
<script>
var advanced_update_url = "{{ url_route('visiosoft.module.advs::ajax_advanced_update') }}";
</script>

View File

@ -1,8 +1,29 @@
<?php namespace Visiosoft\AdvsModule\Adv; <?php namespace Visiosoft\AdvsModule\Adv;
use Anomaly\Streams\Platform\Entry\EntryCollection; use Anomaly\Streams\Platform\Entry\EntryCollection;
use Illuminate\Container\Container;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\Paginator;
class AdvCollection extends EntryCollection class AdvCollection extends EntryCollection
{ {
public function paginate($pageSize = null)
{
$pageSize = $pageSize ?: setting_value('streams::per_page');
$page = Paginator::resolveCurrentPage('page');
$total = $this->count();
return self::paginator($this->forPage($page, $pageSize), $total, $pageSize, $page, [
'path' => Paginator::resolveCurrentPath(),
'pageName' => 'page',
]);
}
protected static function paginator($items, $total, $perPage, $currentPage, $options)
{
return Container::getInstance()->makeWith(LengthAwarePaginator::class, compact(
'items', 'total', 'perPage', 'currentPage', 'options'
));
}
} }

View File

@ -11,6 +11,7 @@ use Anomaly\Streams\Platform\Entry\EntryRepository;
use Visiosoft\CatsModule\Category\CategoryModel; use Visiosoft\CatsModule\Category\CategoryModel;
use Visiosoft\LocationModule\City\CityModel; use Visiosoft\LocationModule\City\CityModel;
use Visiosoft\LocationModule\Country\CountryModel; use Visiosoft\LocationModule\Country\CountryModel;
use Visiosoft\LocationModule\District\DistrictModel;
class AdvRepository extends EntryRepository implements AdvRepositoryInterface class AdvRepository extends EntryRepository implements AdvRepositoryInterface
{ {
@ -215,12 +216,16 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
{ {
$country = CountryModel::query()->where('location_countries.id', $adv->country_id)->first(); $country = CountryModel::query()->where('location_countries.id', $adv->country_id)->first();
$city = CityModel::query()->where('location_cities.id', $adv->city)->first(); $city = CityModel::query()->where('location_cities.id', $adv->city)->first();
$district = DistrictModel::query()->where('location_districts.id', $adv->district)->first();
if ($country != null) { if ($country != null) {
$adv->setAttribute('country_name', $country->name); $adv->setAttribute('country_name', $country->name);
} }
if ($city != null) { if ($city != null) {
$adv->setAttribute('city_name', $city->name); $adv->setAttribute('city_name', $city->name);
} }
if ($district != null) {
$adv->setAttribute('district_name', $district->name);
}
return $adv; return $adv;
} }
@ -460,14 +465,22 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
return $advs->update(['finish_at' => $newDate]); return $advs->update(['finish_at' => $newDate]);
} }
public function getByUsersIDs($usersIDs) public function getByUsersIDs($usersIDs, $status = 'approved', $withDraft = false)
{ {
return $this $ads = $this
->newQuery() ->newQuery()
->whereIn('advs_advs.created_by_id', $usersIDs) ->whereIn('advs_advs.created_by_id', $usersIDs)
->where('advs_advs.slug', '!=', "")
->where('advs_advs.status', 'approved')
->where('advs_advs.finish_at', '>', date('Y-m-d H:i:s')); ->where('advs_advs.finish_at', '>', date('Y-m-d H:i:s'));
if ($status) {
$ads = $ads->where('advs_advs.status', 'approved');
}
if (!$withDraft) {
$ads = $ads->where('advs_advs.slug', '!=', "");
}
return $ads;
} }
public function getPopular() public function getPopular()

View File

@ -45,7 +45,7 @@ interface AdvRepositoryInterface extends EntryRepositoryInterface
public function extendAds($allAds, $isAdmin = false); public function extendAds($allAds, $isAdmin = false);
public function getByUsersIDs($usersIDs); public function getByUsersIDs($usersIDs, $status = 'approved', $withDraft = false);
public function getPopular(); public function getPopular();

View File

@ -19,6 +19,11 @@ class AdvTableBuilder extends TableBuilder
'slug' => 'all', 'slug' => 'all',
'text' => 'streams::view.all', 'text' => 'streams::view.all',
], ],
'advanced' => [
'view' => All::class,
'slug' => 'advanced',
'text' => 'module::view.advanced',
],
'trash', 'trash',
'unfinished' => [ 'unfinished' => [
'view' => unfinished::class 'view' => unfinished::class
@ -74,6 +79,7 @@ class AdvTableBuilder extends TableBuilder
'order_by' => [ 'order_by' => [
'id' => 'DESC', 'id' => 'DESC',
], ],
'table_view' => 'visiosoft.module.advs::admin/table/table'
]; ];
/** /**
@ -81,6 +87,10 @@ class AdvTableBuilder extends TableBuilder
* *
* @var array * @var array
*/ */
protected $assets = []; protected $assets = [
'scripts.js' => [
'visiosoft.module.advs::js/admin/advanced.js'
],
];
} }

View File

@ -1,6 +1,7 @@
<?php namespace Visiosoft\AdvsModule\Adv\Table; <?php namespace Visiosoft\AdvsModule\Adv\Table;
use Anomaly\Streams\Platform\Entry\Contract\EntryInterface; use Anomaly\Streams\Platform\Entry\Contract\EntryInterface;
use Anomaly\Streams\Platform\Entry\EntryModel;
use Visiosoft\CatsModule\Category\CategoryModel; use Visiosoft\CatsModule\Category\CategoryModel;
class AdvTableColumns class AdvTableColumns
@ -8,11 +9,11 @@ class AdvTableColumns
public function handle(AdvTableBuilder $builder) public function handle(AdvTableBuilder $builder)
{ {
$builder->setColumns([ $columns = [
'cover_photo' => [ 'cover_photo' => [
'value' => function (EntryInterface $entry) { 'value' => function (EntryInterface $entry) {
return "<img width='80px' src='" . $entry->AddAdsDefaultCoverImage($entry)->cover_photo . "' >"; return "<img width='80px' src='" . $entry->AddAdsDefaultCoverImage($entry)->cover_photo . "' >";
}, }
], ],
'name' => [ 'name' => [
@ -59,7 +60,36 @@ class AdvTableColumns
'created_by' => [ 'created_by' => [
'value' => 'entry.created_by.name', 'value' => 'entry.created_by.name',
], ],
]); ];
if ($builder->isActiveView('advanced')) {
unset($columns['created_by'], $columns['country']);
$columns['is_get_adv'] = [
'attributes' => [
'html' => function (EntryModel $entry) {
$checked = ($entry->is_get_adv) ? 'checked' : '';
return '<input style="min-width:120px" type="checkbox" class="form-control fast-update" ' . $checked . ' data-column="is_get_adv" data-entry_id="' . $entry->getId() . '">';
}
],
'class' => 'advs-price',
];
$columns['standard_price'] = [
'attributes' => [
'html' => function (EntryModel $entry) {
return '<input style="min-width:120px" type="number" min="0" class="form-control fast-update" value="' . $entry->standard_price . '" data-column="standard_price" data-entry_id="' . $entry->getId() . '">';
}
],
'class' => 'advs-price',
];
$columns['price']['attributes'] = [
'html' => function (EntryModel $entry) {
return '<input style="min-width:120px" type="number" min="0" class="form-control fast-update" value="' . $entry->price . '" data-column="price" data-entry_id="' . $entry->getId() . '">';
}
];
}
$builder->setColumns($columns);
} }
} }

View File

@ -0,0 +1,21 @@
<?php namespace Visiosoft\AdvsModule\Adv\Table\Views;
use Anomaly\Streams\Platform\Ui\Table\Component\View\Query\AllQuery;
use Anomaly\Streams\Platform\Ui\Table\Component\View\View;
use Illuminate\Database\Eloquent\Builder;
class Advanced extends View
{
protected $slug = 'advanced';
protected $text = 'visiosoft.module.advs::view.advanced';
protected $query = AllQuery::class;
public function onQuerying(Builder $query)
{
$query->where('slug', "");
}
}

View File

@ -46,6 +46,10 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
'uses' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@assetsClear', 'uses' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@assetsClear',
], ],
'admin/advs-users/choose/{advId}' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@choose', 'admin/advs-users/choose/{advId}' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@choose',
'admin/advs/ajax/advanced/advanced-update' => [
'as' => 'visiosoft.module.advs::ajax_advanced_update',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@advancedUpdate',
],
'admin/class/actions/{id}/{type}' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@actions', 'admin/class/actions/{id}/{type}' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@actions',

View File

@ -204,4 +204,17 @@ class AdvsController extends AdminController
{ {
return Excel::download(new AdvsExport(), 'advs-' . time() . '.xlsx'); return Excel::download(new AdvsExport(), 'advs-' . time() . '.xlsx');
} }
public function advancedUpdate()
{
if ($this->request->has('advanced_column') and $this->request->has('advanced_entry_id') and $this->request->has('advanced_value')) {
$entry_id = $this->request->get('advanced_entry_id');
$column = $this->request->get('advanced_column');
$value = $this->request->get('advanced_value');
if ($entry = $this->advRepository->find($entry_id)) {
$entry->setAttribute($column, $value);
$entry->save();
}
}
}
} }

View File

@ -11,8 +11,12 @@ class EnableMaintenanceMode
{ {
$builder = $event->getBuilder(); $builder = $event->getBuilder();
if (get_class($builder->getRepository()) === SettingFormRepository::class) { if (get_class($builder->getRepository()) === SettingFormRepository::class) {
if ($builder->getFormValues()->has('maintenance') and $builder->getFormValues()->get('maintenance')) { if ($builder->getFormValues()->has('maintenance')) {
Artisan::call('down'); if ($builder->getFormValues()->get('maintenance')) {
Artisan::call('down');
} elseif (config('streams::maintenance.enabled')) {
Artisan::call('up');
}
} }
} }
} }