bulk price imp.

This commit is contained in:
vedatakdogan 2020-12-24 19:17:38 +03:00
parent 10d3445016
commit 92ffb3fefb
8 changed files with 173 additions and 4 deletions

View File

@ -0,0 +1,22 @@
var getUrlParameter = 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 value = $(this).val(), entry_id = $(this).data('entry_id'), column = $(this).data('column');
alert(value,entry_id,column);
})
}

View File

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

View File

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

View File

@ -0,0 +1,87 @@
{{ 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>

View File

@ -19,6 +19,11 @@ class AdvTableBuilder extends TableBuilder
'slug' => 'all',
'text' => 'streams::view.all',
],
'advanced' => [
'view' => All::class,
'slug' => 'advanced',
'text' => 'module::view.advanced',
],
'trash',
'unfinished' => [
'view' => unfinished::class
@ -74,6 +79,7 @@ class AdvTableBuilder extends TableBuilder
'order_by' => [
'id' => 'DESC',
],
'table_view' => 'visiosoft.module.advs::admin/table/table'
];
/**
@ -81,6 +87,10 @@ class AdvTableBuilder extends TableBuilder
*
* @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;
use Anomaly\Streams\Platform\Entry\Contract\EntryInterface;
use Anomaly\Streams\Platform\Entry\EntryModel;
use Visiosoft\CatsModule\Category\CategoryModel;
class AdvTableColumns
@ -8,11 +9,11 @@ class AdvTableColumns
public function handle(AdvTableBuilder $builder)
{
$builder->setColumns([
$columns = [
'cover_photo' => [
'value' => function (EntryInterface $entry) {
return "<img width='80px' src='" . $entry->AddAdsDefaultCoverImage($entry)->cover_photo . "' >";
},
}
],
'name' => [
@ -59,7 +60,18 @@ class AdvTableColumns
'created_by' => [
'value' => 'entry.created_by.name',
],
]);
];
if ($builder->isActiveView('advanced')) {
$columns['price']['attributes'] = [
'html' => function (EntryModel $entry) {
return '<input style="min-width:120px" type="text" 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

@ -204,4 +204,19 @@ class AdvsController extends AdminController
{
return Excel::download(new AdvsExport(), 'advs-' . time() . '.xlsx');
}
public function advancedEdit()
{
$available_colmuns
if()
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();
}
}
}
}