Merge remote-tracking branch 'origin/master'

# Conflicts:
#	addons/default/visiosoft/advs-module/resources/views/new-ad/preview/preview.twig
This commit is contained in:
vedatakd 2021-08-11 15:35:29 +03:00
commit 0820d70dce
25 changed files with 236 additions and 44 deletions

View File

@ -261,4 +261,29 @@ label {
}
}
}
}
}
.btn-configuration {
background-color: #6E5DDB;
padding: 1rem 2rem;
font-family: 'Poppins', sans-serif;
font-size: calc(18rem / 16);
border-radius: .25rem;
border: 0;
color: #fff;
display: inline-flex;
align-items: center;
margin-bottom: 2rem;
&:hover,
&:active,
&:focus {
background-color: #6E5DDB;
color: #fff;
}
svg {
width: 1.5rem;
height: auto;
}
}

View File

@ -0,0 +1,6 @@
<svg id="Group_42321" data-name="Group 42321" xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 30 30">
<g id="Group_15874" data-name="Group 15874">
<path id="Path_10381" data-name="Path 10381" d="M15,0A15,15,0,1,1,0,15,15,15,0,0,1,15,0Z" fill="#f8f8f8"/>
<path id="close" d="M10.557.6l-.6-.6L5.278,4.675.6,0,0,.6,4.675,5.278,0,9.953l.6.6L5.278,5.882l4.675,4.675.6-.6L5.882,5.278Z" transform="translate(9.5 9.5)" fill="#c7c7c7" stroke="#c7c7c7" stroke-linecap="round" stroke-linejoin="round" stroke-width="0.7"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 570 B

View File

@ -0,0 +1,12 @@
<svg id="add_5_" data-name="add (5)" xmlns="http://www.w3.org/2000/svg" width="19.96" height="19.96" viewBox="0 0 19.96 19.96">
<g id="Group_16519" data-name="Group 16519">
<g id="Group_16518" data-name="Group 16518">
<path id="Path_10382" data-name="Path 10382" d="M9.98,0a9.98,9.98,0,1,0,9.98,9.98A9.991,9.991,0,0,0,9.98,0Zm0,18.414A8.434,8.434,0,1,1,18.414,9.98,8.444,8.444,0,0,1,9.98,18.414Z" fill="#fff"/>
</g>
</g>
<g id="Group_16521" data-name="Group 16521" transform="translate(5.342 5.272)">
<g id="Group_16520" data-name="Group 16520">
<path id="Path_10383" data-name="Path 10383" d="M145.526,139.1h-3.092v-3.092a.773.773,0,0,0-1.546,0V139.1H137.8a.773.773,0,0,0,0,1.546h3.092v3.092a.773.773,0,0,0,1.546,0v-3.092h3.092a.773.773,0,1,0,0-1.546Z" transform="translate(-137.022 -135.238)" fill="#fff"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 898 B

View File

@ -3,8 +3,6 @@ function showLoader() {
}
var filter = {};
// TODO will be unified
@ -265,4 +263,34 @@ $(document).ready(function () {
return true;
})
$('#configurationForm').submit(function (e) {
e.preventDefault();
crudAjax($(this).serialize(), '/advs/configuration/ajax/create', 'POST', function (callback) {
$('.configuration-table').append(`<tr id="configuration-${callback.id}">
<td>${callback.option_name}</td>
<td>${callback.stock}</td>
<td>${callback.currency_price}</td>
<td class="text-right">
<a href="javascript:void(0)" class="btn btn-sm remove-conf" data-id="${callback.id}"><svg id="Group_42321" data-name="Group 42321" xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 30 30">
<g id="Group_15874" data-name="Group 15874">
<path id="Path_10381" data-name="Path 10381" d="M15,0A15,15,0,1,1,0,15,15,15,0,0,1,15,0Z" fill="#f8f8f8"></path>
<path id="close" d="M10.557.6l-.6-.6L5.278,4.675.6,0,0,.6,4.675,5.278,0,9.953l.6.6L5.278,5.882l4.675,4.675.6-.6L5.882,5.278Z" transform="translate(9.5 9.5)" fill="#c7c7c7" stroke="#c7c7c7" stroke-linecap="round" stroke-linejoin="round" stroke-width="0.7"></path>
</g>
</svg>
</a>
</td>
</tr>`);
$('#configurationForm').trigger("reset");
})
});
$(document).on('click', '.remove-conf', function () {
const id = $(this).data('id');
crudAjax({id: id}, '/advs/configuration/ajax/delete', 'POST', function (callback) {
$('#configuration-' + id).remove();
})
});
});

View File

@ -1,6 +1,7 @@
<?php
return [
'add' => 'Add',
'new_adv' => 'New classified',
'new_classified' => 'New classified',
'new_category' => 'New Category',

View File

@ -1,6 +1,7 @@
<?php
return [
'add' => 'Ekle',
'new_adv' => 'Yeni ürün/ilan',
'new_classified' => 'Yeni ürün/ilan',
'new_category' => 'Yeni kategori',
@ -33,6 +34,7 @@ return [
'name' => 'Kategori Güncelle'
],
'new_option' => 'Yeni Seçenek',
'options' => 'Seçenekler',
'export' => 'Dışa aktar',
'new_productoption' => 'Yeni Üretim',
'new_productoptions_value' => 'Yeni Ürün seçeneği değeri',

View File

@ -1,9 +1,9 @@
{% if config_get('streams::locales.enabled')|length > 1 %}
<div class="btn-group px-1" style="display: inline-block;">
<div class="btn-group" style="display: inline-block;">
{% if setting_value('visiosoft.module.advs::show_input_flag') %}
{{ img('visiosoft.module.advs::images/flags/' ~ field_type.locale ~ '.svg').width(20)|raw }}
{% endif %}
<a href="#" class="btn btn-xs btn-default dropdown-toggle px-0" data-dropdown="locales" data-toggle="dropdown">
<a href="#" class="btn btn-xs btn-default dropdown-toggle px-1 mx-0" data-dropdown="locales" data-toggle="dropdown">
{{ trans('streams::locale.' ~ field_type.locale ~ '.name') }}
</a>
<div class="dropdown-menu">

View File

@ -225,7 +225,11 @@
{{ trans('visiosoft.module.advs::field.product_option.name') }}
</label>
<div class="mt-3 form-group mb-0">
{{ form.fields.product_options_value.configSet('cat1', adv.cat1).input|raw }}
<button type="button" class="btn btn-primary btn-configuration" data-toggle="modal" data-target="#configurationModal">
{{ img('visiosoft.module.advs::images/create/plus.svg').data|raw }}
&nbsp;
{{ trans('visiosoft.module.advs::button.new_options_configuration') }}
</button>
</div>
</div>
{% endif %}
@ -276,7 +280,7 @@
<h5 class="mt-5 pb-1 border-bottom">
{{ trans('visiosoft.module.advs::field.additional_fields') }}
</h5>
<div class="bg-light p-4">
<div class="bg-light p-4 row">
{{ other_fields|raw }}
</div>
{% endif %}
@ -316,6 +320,7 @@
</div>
</section>
{% include "visiosoft.module.advs::new-ad/partials/modals" %}
{% include "visiosoft.module.advs::new-ad/partials/configuration-modal" %}
{{ addBlock('new-ad/modals')|raw }}
<script>
var default_country = "{{ setting_value('visiosoft.module.location::default_country') }}";

View File

@ -0,0 +1,52 @@
<div class="modal fade" id="configurationModal" tabindex="-1" role="dialog" aria-labelledby="configurationModalLabel"
aria-hidden="true">
<div class="modal-dialog modal-xl" role="document">
<div class="modal-content rounded-0">
<div class="modal-header border-0">
<h5 class="modal-title" id="configurationModalLabel">
{{ trans('visiosoft.module.advs::stream.product_options.name') }}
</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="">
{% set configurationForm = form('configuration_form').entry(adv.id).get() %}
{{ form_open({id: 'configurationForm',class: 'd-flex justify-content-between'})|raw }}
<input type="text" name="parent_adv_id" value="{{ adv.id }}" hidden>
{{ configurationForm.fields|raw }}
<button type="submit" class="btn btn-primary btn-configuration my-auto form-control w-auto">
{{ trans('visiosoft.module.advs::button.add') }}
</button>
{{ form_close() }}
</div>
<table class="table">
<thead>
<tr>
<th scope="col">{{ trans('visiosoft.module.advs::field.options') }}</th>
<th scope="col">{{ trans('visiosoft.module.advs::field.stock.name') }}</th>
<th scope="col">{{ trans('visiosoft.module.advs::field.price.name') }}</th>
<th scope=""></th>
</tr>
</thead>
<tbody class="configuration-table">
{% for key, configuration in configurations %}
<tr id="configuration-{{ key }}">
<td>{{ configuration.name }}</td>
<td>{{ configuration.stock }}</td>
<td>{{ currency_format(configuration.price,configuration.currency) }}</td>
<td class="text-right">
<a href="javascript:void(0)" class="btn btn-sm remove-conf"
data-id="{{ key }}">{{ img('visiosoft.module.advs::images/create/close.svg').data|raw }}</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>

View File

@ -24,14 +24,6 @@
{% else %}
{% set continueLink = url_route('adv_detail_seo', [adv.slug, adv.id]) %}
{% endif %}
{% if not setting_value('visiosoft.module.advs::hide_configurations') %}
{% if setting_value('visiosoft.module.advs::detailed_product_options') %}
<a href="{{ route('visiosoft.module.advs::user.configrations.create') }}?ad={{ adv.id }}"
class="btn btn-warning shadow-sm mr-4 text-white">
{{ trans('visiosoft.module.advs::button.create_configurations') }}
</a>
{% endif %}
{% endif %}
{% if isActive('shipping') %}
<a href="{{ url_route('visiosoft.module.shipping::create_shipping',{'id':adv.id}) }}"
class="btn btn-outline-primary shadow-sm mr-4">
@ -52,13 +44,6 @@
<div class="preview-overlay position-absolute"></div>
</div>
<div class="preview-actions text-center">
{% if not setting_value('visiosoft.module.advs::hide_configurations') %}
<a href="{{ route('visiosoft.module.advs::user.configrations.create') }}?ad={{ adv.id }}"
class="btn btn-warning shadow-sm mr-4 text-white">
{{ trans('visiosoft.module.advs::button.create_configurations') }}
</a>
{% endif %}
{% if isActive('shipping') %}
<a href="{{ url_route('visiosoft.module.shipping::create_shipping',{'id':adv.id}) }}"
class="btn btn-outline-primary shadow-sm mr-4">

View File

@ -6,6 +6,7 @@ use Anomaly\Streams\Platform\Model\Advs\AdvsCustomFieldsEntryModel;
use Carbon\Carbon;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Visiosoft\AdvsModule\Adv\Contract\AdvInterface;
use Anomaly\Streams\Platform\Model\Advs\AdvsAdvsEntryModel;
use Visiosoft\AdvsModule\OptionConfiguration\OptionConfigurationModel;
@ -510,4 +511,16 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
{
return $this->created_by_id == \auth()->id() || \auth()->user()->isAdmin();
}
public function getCatsIDs()
{
$attr = $this->getAttributes();
return array_filter(
$attr,
function ($key) use ($attr) {
return Str::startsWith($key, 'cat') && $attr[$key];
},
ARRAY_FILTER_USE_KEY
);
}
}

View File

@ -11,12 +11,13 @@ class AdvsImport implements ToModel, WithHeadingRow
{
public function model(array $row)
{
$row['name'] = $row['name'] ?? $row['title'];
if ($row['name'] !== null && $row['price'] !== null && $row['currency'] !== null) {
return new AdvModel([
'name' => $row['name'],
'slug' => Str::slug($row['name']),
'advs_desc' => $row['description'] ?? null,
'standard_price' => $row['standard_price'] ?? null,
'standard_price' => $row['standard_price'] ?? 0,
'price' => $row['price'],
'currency' => $row['currency'],
'country' => $row['country'] ?? null,

View File

@ -20,6 +20,6 @@ class IsOptionsByCategory
$options_id = $option_repository->getWithCategoryId($this->cat_id)->pluck('id')->all();
return count($value_repository->getWithOptionsId($options_id));
return $value_repository->getWithOptionsId($options_id);
}
}

View File

@ -93,4 +93,6 @@ interface AdvInterface extends EntryInterface
public function changeStatus($status);
public function canEdit();
public function getCatsIDs();
}

View File

@ -19,6 +19,7 @@ use Visiosoft\AdvsModule\Listener\AddTotalSales;
use Visiosoft\AdvsModule\Option\Contract\OptionRepositoryInterface;
use Visiosoft\AdvsModule\Option\OptionRepository;
use Visiosoft\AdvsModule\OptionConfiguration\Contract\OptionConfigurationRepositoryInterface;
use Visiosoft\AdvsModule\OptionConfiguration\Form\OptionConfigurationFormBuilder;
use Visiosoft\AdvsModule\OptionConfiguration\OptionConfigurationRepository;
use Visiosoft\AdvsModule\Productoption\Contract\ProductoptionRepositoryInterface;
use Visiosoft\AdvsModule\Productoption\ProductoptionRepository;
@ -217,6 +218,16 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
'as' => 'visiosoft.module.advs::user.configrations.create',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\OptionConfigurationController@create',
],
'advs/configuration/ajax/create' => [
'middleware' => 'auth',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\OptionConfigurationController@ajaxCreate'
],
'advs/configuration/ajax/delete' => [
'middleware' => 'auth',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\OptionConfigurationController@ajaxDelete'
],
'conf/addCart' => [
'as' => 'configuration::add_cart',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\OptionConfigurationController@confAddCart',
@ -257,6 +268,7 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
AdvsAdvsEntryModel::class => AdvModel::class,
AdvsStatusEntryModel::class => StatusModel::class,
'my_form' => AdvFormBuilder::class,
'configuration_form' => OptionConfigurationFormBuilder::class,
];
protected $singletons = [

View File

@ -792,7 +792,7 @@ class AdvsController extends PublicController
$is_new_create = ($adv->slug == "") ? true : false;
//Set Old Price
$old_price = ($adv->slug == "") ? $this->request->price : $adv->price;
$old_price = $is_new_create ? $this->request->price : $adv->price;
$adv->old_price = $old_price;
@ -1007,10 +1007,11 @@ class AdvsController extends PublicController
* Added to query if there are product options.
*/
$is_options = dispatch_now(new IsOptionsByCategory($adv['cat1']));
$configurations = app(OptionConfigurationRepositoryInterface::class)->getConf($adv['id']);
return $this->view->make(
'visiosoft.module.advs::new-ad/new-create',
compact('id', 'cats_d', 'cats', 'adv', 'custom_fields', 'options', 'hidePrice','is_options')
compact('id', 'cats_d', 'cats', 'adv', 'custom_fields', 'options', 'hidePrice','is_options', 'configurations')
);
}
@ -1208,4 +1209,4 @@ class AdvsController extends PublicController
$response['maxQuantity'] = $adv->stock;
return $response;
}
}
}

View File

@ -4,6 +4,7 @@ use Anomaly\Streams\Platform\Http\Controller\PublicController;
use Visiosoft\AdvsModule\Adv\AdvModel;
use Visiosoft\AdvsModule\OptionConfiguration\Contract\OptionConfigurationRepositoryInterface;
use Visiosoft\AdvsModule\OptionConfiguration\Form\OptionConfigurationFormBuilder;
use Visiosoft\AdvsModule\Support\Command\Currency;
use Visiosoft\CartsModule\Cart\CartRepository;
use Visiosoft\CartsModule\Cart\Command\GetCart;
@ -31,6 +32,30 @@ class OptionConfigurationController extends PublicController
return $form->render();
}
public function ajaxCreate(OptionConfigurationRepositoryInterface $optionConfigurationRepository){
$parameters = $this->request->all();
$option_json = array();
foreach ($parameters as $key => $parameter_value) {
if ((strpos($key, "option-") === 0)) {
if ($parameter_value !== '') {
$option_id = substr($key, 7);
$option_json[$option_id] = $parameter_value;
}
unset($parameters[$key]);
}
}
$option_json = ['option_json' => json_encode($option_json)];
$configration = array_merge($parameters, $option_json);
$entry = $optionConfigurationRepository->create($configration);
$entry['currency_price'] = app(Currency::class)->format($entry->price, $entry->currency);
return $this->response->json($entry);
}
public function ajaxDelete(OptionConfigurationRepositoryInterface $optionConfigurationRepository){
return $optionConfigurationRepository->deleteConfig($this->request->id);
}
public function confAddCart()
{
if ($conf = $this->optionConfigurationRepository->find($this->request->configuration)) {

View File

@ -16,9 +16,11 @@ class AddTotalSales
public function handle(CreatedOrderDetail $event)
{
$item = $event->getOrderItem();
$adv = $this->advModel->find($event->getOrderItem()->item_id);
$total = $adv->total_sales + $item->piece;
$adv->total_sales = $total;
$adv->save();
if ($item->item_type === 'adv') {
$adv = $this->advModel->find($event->getOrderItem()->item_id);
$total = $adv->total_sales + $item->piece;
$adv->total_sales = $total;
$adv->save();
}
}
}
}

View File

@ -13,4 +13,6 @@ interface OptionConfigurationRepositoryInterface extends EntryRepositoryInterfac
public function deleteUnusedConfigs($adsIDs);
public function deleteAdsConfigs($adID);
public function deleteConfig($id);
}

View File

@ -4,4 +4,7 @@ use Anomaly\Streams\Platform\Ui\Form\FormBuilder;
class OptionConfigurationFormBuilder extends FormBuilder
{
protected $actions = [
'save',
];
}

View File

@ -2,32 +2,34 @@
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
use Visiosoft\AdvsModule\Productoption\Contract\ProductoptionRepositoryInterface;
use Visiosoft\AdvsModule\ProductoptionsValue\Contract\ProductoptionsValueRepositoryInterface;
class OptionConfigurationFormFields
{
public function handle(
OptionConfigurationFormBuilder $builder,
AdvRepositoryInterface $advRepository,
ProductoptionRepositoryInterface $productOptionRepository)
ProductoptionRepositoryInterface $productOptionRepository,
ProductoptionsValueRepositoryInterface $productoptionsValueRepository
)
{
if(request()->has('ad'))
if(request()->has('ad') || $builder->getEntry())
{
$ad = $advRepository->find(request('ad'));
$options = $ad->getProductOptionsValues()->groupBy('product_option_id');
$ad = $advRepository->find(request('ad') ?? $builder->getEntry());
$options = $productOptionRepository->getWithCategoryId($ad->cat1);
$options_fields = array();
foreach ($options as $option_id => $option_values)
foreach ($options as $option)
{
if($option = $productOptionRepository->find($option_id))
if($optionValue = $productoptionsValueRepository->getWithOptionsId([$option->id]))
{
$options_fields['option-'.$option->getId()] = [
'type' => 'anomaly.field_type.select',
'label' => $option->getName(),
'required' => true,
'config' => [
'options' => $option_values->pluck('name','id')->all(),
'options' => $optionValue->pluck('title','id')->all(),
]
];
}

View File

@ -1,6 +1,6 @@
<?php namespace Visiosoft\AdvsModule\OptionConfiguration;
use Anomaly\Streams\Platform\Model\Configuration\ConfigurationConfigurationEntryModel;
use Illuminate\Support\Facades\Auth;
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
use Visiosoft\AdvsModule\OptionConfiguration\Contract\OptionConfigurationRepositoryInterface;
use Anomaly\Streams\Platform\Entry\EntryRepository;
@ -93,4 +93,15 @@ class OptionConfigurationRepository extends EntryRepository implements OptionCon
{
return $this->newQuery()->where('parent_adv_id', $adID)->delete();
}
public function deleteConfig($id)
{
if ($conf = ($this->newQuery()->find($id))) {
if ($conf->created_by_id === Auth::user()->getAuthIdentifier()) {
return $conf->delete();
}
return response()->json(['status' => 'error'], 403);
}
return response()->json(['status' => 'error'], 404);
}
}

View File

@ -1,6 +1,8 @@
{% extends "theme::layouts/default" %}
{% block styles %}
<link rel="canonical" href="{{ url() }}"/>
{{ asset_style('visiosoft.theme.base::css/login.css') }}
{% endblock %}
@ -103,4 +105,4 @@
</div>
</div>
{{ asset_add('scripts.js','visiosoft.theme.base::js/login.js') }}
{% endblock %}
{% endblock %}

View File

@ -240,7 +240,7 @@
a {
background-color: unset;
border: 0;
color: #DC3545;
color: #DC3545 !important;
font-family: 'Poppins', sans-serif;
font-weight: 500;
display: inline-flex;

View File

@ -44,7 +44,7 @@
<p>{{ trans('visiosoft.module.profile::field.password.name') }}</p>
</a>
<a href="{{ url('logout') }}"
class="px-3 link-unstyled d-flex d-md-none">
class="px-3 link-unstyled">
{{ img('visiosoft.module.profile::images/logout.svg').data|raw }}
<p>{{ trans('visiosoft.theme.base::field.logout.name') }}</p>
</a>