Development (#789)

* issue #753 swatch issue

* edit validation for swatch

* #783 product image with installer

* issue #773

* removal of view composers in shop
This commit is contained in:
rahulshukla-webkul 2019-04-03 11:37:48 +05:30 committed by Jitendra Singh
parent f2e4930e8e
commit 9314d9159c
14 changed files with 165 additions and 265 deletions

View File

@ -12,7 +12,7 @@
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="history.length > 1 ? history.go(-1) : window.location = '{{ url('/admin/dashboard') }}';"></i>
{{ __('admin::app.catalog.attributes.add-title') }}
</h1>
</div>
@ -99,7 +99,7 @@
<accordian :title="'{{ __('admin::app.catalog.attributes.options') }}'" :active="true" :id="'options'">
<div slot="body">
{!! view_render_event('bagisto.admin.catalog.attribute.create_form_accordian.options.controls.before') !!}
<option-wrapper></option-wrapper>
@ -119,7 +119,7 @@
<div slot="body">
{!! view_render_event('bagisto.admin.catalog.attribute.create_form_accordian.options.controls.before') !!}
<div class="control-group">
<label for="is_required">{{ __('admin::app.catalog.attributes.is_required') }}</label>
<select class="control" id="is_required" name="is_required">
@ -246,7 +246,7 @@
<thead>
<tr>
<th v-if="show_swatch && (swatch_type == 'color' || swatch_type == 'image')">{{ __('admin::app.catalog.attributes.swatch') }}</th>
<th>{{ __('admin::app.catalog.attributes.admin_name') }}</th>
@foreach (Webkul\Core\Models\Locale::all() as $locale)
@ -317,21 +317,26 @@
$('#options').parent().removeClass('hide')
}
})
});
var optionWrapper = Vue.component('option-wrapper', {
template: '#options-template',
Vue.component('option-wrapper', {
data: () => ({
optionRowCount: 0,
optionRows: [],
show_swatch: false,
swatch_type: ''
}),
template: '#options-template',
created () {
var this_this = this;
inject: ['$validator'],
data: () => ({
optionRowCount: 0,
optionRows: [],
show_swatch: false,
swatch_type: ''
}),
created () {
var this_this = this;
$(document).ready(function () {
$('#type').on('change', function (e) {
if (['select'].indexOf($(e.target).val()) === -1) {
this_this.show_swatch = false;
@ -339,46 +344,38 @@
this_this.show_swatch = true;
}
});
});
},
methods: {
addOptionRow () {
var rowCount = this.optionRowCount++;
var row = {'id': 'option_' + rowCount};
@foreach (Webkul\Core\Models\Locale::all() as $locale)
row['{{ $locale->code }}'] = '';
@endforeach
this.optionRows.push(row);
},
methods: {
addOptionRow () {
var rowCount = this.optionRowCount++;
var row = {'id': 'option_' + rowCount};
removeRow (row) {
var index = this.optionRows.indexOf(row)
Vue.delete(this.optionRows, index);
},
@foreach (Webkul\Core\Models\Locale::all() as $locale)
row['{{ $locale->code }}'] = '';
@endforeach
adminName (row) {
return 'options[' + row.id + '][admin_name]';
},
this.optionRows.push(row);
},
localeInputName (row, locale) {
return 'options[' + row.id + '][' + locale + '][label]';
},
removeRow (row) {
var index = this.optionRows.indexOf(row)
Vue.delete(this.optionRows, index);
},
adminName (row) {
return 'options[' + row.id + '][admin_name]';
},
localeInputName (row, locale) {
return 'options[' + row.id + '][' + locale + '][label]';
},
sortOrderName (row) {
return 'options[' + row.id + '][sort_order]';
}
sortOrderName (row) {
return 'options[' + row.id + '][sort_order]';
}
})
new Vue({
el: '#options',
components: {
optionWrapper: optionWrapper
},
})
});
}
})
</script>
@endpush

View File

@ -12,7 +12,7 @@
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="history.length > 1 ? history.go(-1) : window.location = '{{ url('/admin/dashboard') }}';"></i>
{{ __('admin::app.catalog.attributes.edit-title') }}
</h1>
</div>
@ -118,22 +118,22 @@
<accordian :title="'{{ __('admin::app.catalog.attributes.options') }}'" :active="true" :id="'options'">
<div slot="body">
{!! view_render_event('bagisto.admin.catalog.attribute.edit_form_accordian.options.controls.before', ['attribute' => $attribute]) !!}
<option-wrapper></option-wrapper>
{!! view_render_event('bagisto.admin.catalog.attribute.edit_form_accordian.options.controls.after', ['attribute' => $attribute]) !!}
</div>
</accordian>
{!! view_render_event('bagisto.admin.catalog.attribute.edit_form_accordian.options.after', ['attribute' => $attribute]) !!}
</div>
{!! view_render_event('bagisto.admin.catalog.attribute.edit_form_accordian.validations.before', ['attribute' => $attribute]) !!}
<accordian :title="'{{ __('admin::app.catalog.attributes.validations') }}'" :active="true">
<div slot="body">
@ -207,7 +207,7 @@
</select>
<input type="hidden" name="value_per_locale" value="{{ $attribute->value_per_locale }}"/>
</div>
<div class="control-group">
<label for="value_per_channel">{{ __('admin::app.catalog.attributes.value_per_channel') }}</label>
<select class="control" id="value_per_channel" name="value_per_channel" disabled>
@ -220,7 +220,7 @@
</select>
<input type="hidden" name="value_per_channel" value="{{ $attribute->value_per_channel }}"/>
</div>
<div class="control-group">
<label for="is_filterable">{{ __('admin::app.catalog.attributes.is_filterable') }}</label>
<select class="control" id="is_filterable" name="is_filterable">
@ -232,7 +232,7 @@
</option>
</select>
</div>
<div class="control-group">
<label for="is_configurable">{{ __('admin::app.catalog.attributes.is_configurable') }}</label>
<select class="control" id="is_configurable" name="is_configurable">
@ -244,7 +244,7 @@
</option>
</select>
</div>
<div class="control-group">
<label for="is_visible_on_front">{{ __('admin::app.catalog.attributes.is_visible_on_front') }}</label>
<select class="control" id="is_visible_on_front" name="is_visible_on_front">
@ -302,11 +302,11 @@
<th v-if="show_swatch && (swatch_type == 'color' || swatch_type == 'image')">{{ __('admin::app.catalog.attributes.swatch') }}</th>
<th>{{ __('admin::app.catalog.attributes.admin_name') }}</th>
@foreach (Webkul\Core\Models\Locale::all() as $locale)
<th>{{ $locale->name . ' (' . $locale->code . ')' }}</th>
@endforeach
<th>{{ __('admin::app.catalog.attributes.position') }}</th>
@ -314,7 +314,7 @@
<th></th>
</tr>
</thead>
<tbody>
<tr v-for="(row, index) in optionRows">
<td v-if="show_swatch && swatch_type == 'color'">
@ -366,7 +366,9 @@
<script>
Vue.component('option-wrapper', {
template: '#options-template',
template: '#options-template',
inject: ['$validator'],
data: () => ({
optionRowCount: 0,

View File

@ -109,14 +109,12 @@ class AddressController extends Controller
{
$addresses = $this->customer->addresses;
foreach($addresses as $address) {
if($id == $address->id) {
foreach ($addresses as $address) {
if ($id == $address->id) {
return view($this->_config['view'], compact('address'));
}
}
session()->flash('warning', trans('shop::app.security-warning'));
return redirect()->route('customer.address.index');
}

View File

@ -0,0 +1,71 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Name of route
|--------------------------------------------------------------------------
|
| Enter the routes name to enable dynamic imagecache manipulation.
| This handle will define the first part of the URI:
|
| {route}/{template}/{filename}
|
| Examples: "images", "img/cache"
|
*/
'route' => 'cache',
/*
|--------------------------------------------------------------------------
| Storage paths
|--------------------------------------------------------------------------
|
| The following paths will be searched for the image filename, submited
| by URI.
|
| Define as many directories as you like.
|
*/
'paths' => array(
storage_path('app/public'),
public_path('storage')
),
/*
|--------------------------------------------------------------------------
| Manipulation templates
|--------------------------------------------------------------------------
|
| Here you may specify your own manipulation filter templates.
| The keys of this array will define which templates
| are available in the URI:
|
| {route}/{template}/{filename}
|
| The values of this array will define which filter class
| will be applied, by its fully qualified name.
|
*/
'templates' => array(
'small' => 'Webkul\Product\CacheFilters\Small',
'medium' => 'Webkul\Product\CacheFilters\Medium',
'large' => 'Webkul\Product\CacheFilters\Large',
),
/*
|--------------------------------------------------------------------------
| Image Cache Lifetime
|--------------------------------------------------------------------------
|
| Lifetime in minutes of the images handled by the imagecache route.
|
*/
'lifetime' => 43200,
);

View File

@ -23,6 +23,10 @@ class ProductServiceProvider extends ServiceProvider
$this->app->register(ModuleServiceProvider::class);
$this->composeView();
$this->publishes([
dirname(__DIR__) . '/Config/imagecache.php' => config_path('imagecache.php'),
]);
}
/**

View File

@ -1,54 +0,0 @@
<?php
namespace Webkul\Shop\Http\ViewComposers;
use Illuminate\View\View;
use Illuminate\Support\Collection;
use Webkul\Category\Repositories\CategoryRepository as Category;
/**
* Category List Composer on Navigation Menu
*
* @author Prashant Singh <prashant.singh852@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class CategoryComposer
{
/**
* The category implementation.
*
* for shop bundle's navigation
* menu
*/
protected $category;
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function __construct(Category $category)
{
$this->category = $category;
}
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
{
$categories = [];
foreach ($this->category->getVisibleCategoryTree(core()->getCurrentChannel()->root_category_id) as $category) {
if ($category->slug)
array_push($categories, $category);
}
$view->with('categories', $categories);
}
}

View File

@ -1,47 +0,0 @@
<?php
namespace Webkul\Shop\Http\ViewComposers;
use Illuminate\View\View;
use Illuminate\Support\Collection;
use Webkul\Product\Repositories\ProductRepository as Product;
/**
* Featured Products page
*
* @author Jitendra Singh <jitendra@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class FeaturedProductListComposer
{
/**
* ProductRepository object
*
* @var array
*/
protected $product;
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function __construct(Product $product)
{
$this->product = $product;
}
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
{
$products = $this->product->getFeaturedProducts();
$view->with('products', $products);
}
}

View File

@ -1,47 +0,0 @@
<?php
namespace Webkul\Shop\Http\ViewComposers;
use Illuminate\View\View;
use Illuminate\Support\Collection;
use Webkul\Product\Repositories\ProductRepository as Product;
/**
* New Products page
*
* @author Jitendra Singh <jitendra@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class NewProductListComposer
{
/**
* ProductRepository object
*
* @var array
*/
protected $product;
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function __construct(Product $product)
{
$this->product = $product;
}
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
{
$products = $this->product->getNewProducts();
$view->with('products', $products);
}
}

View File

@ -1,41 +0,0 @@
<?php
namespace Webkul\Shop\Providers;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
use Webkul\Product\Helpers\ProductImage;
use View;
/**
* Composer service provider
*
* @author Jitendra Singh <jitendra@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class ComposerServiceProvider extends ServiceProvider
{
/**
* Register bindings in the container.
*
* @return void
*/
public function boot()
{
View::composer(
['shop::layouts.header.index', 'shop::layouts.footer.footer'],
'Webkul\Shop\Http\ViewComposers\CategoryComposer'
);
View::composer(
['shop::home.new-products'],
'Webkul\Shop\Http\ViewComposers\NewProductListComposer'
);
View::composer(
['shop::home.featured-products'],
'Webkul\Shop\Http\ViewComposers\FeaturedProductListComposer'
);
}
}

View File

@ -9,7 +9,6 @@ use Illuminate\Pagination\Paginator;
use Webkul\Shop\Http\Middleware\Locale;
use Webkul\Shop\Http\Middleware\Theme;
use Webkul\Shop\Http\Middleware\Currency;
use Webkul\Shop\Providers\ComposerServiceProvider;
use Webkul\Core\Tree;
/**
@ -41,8 +40,6 @@ class ShopServiceProvider extends ServiceProvider
$router->aliasMiddleware('theme', Theme::class);
$router->aliasMiddleware('currency', Currency::class);
$this->app->register(ComposerServiceProvider::class);
$this->composeView();
Paginator::defaultView('shop::partials.pagination');

View File

@ -1,15 +1,15 @@
@if ($products->count())
@if (app('Webkul\Product\Repositories\ProductRepository')->getFeaturedProducts()->count())
<section class="featured-products">
<div class="featured-heading">
{{ __('shop::app.home.featured-products') }}<br/>
<span class="featured-seperator" style="color:lightgrey;">_____</span>
</div>
<div class="featured-grid product-grid-4">
@foreach ($products as $productFlat)
@foreach (app('Webkul\Product\Repositories\ProductRepository')->getFeaturedProducts() as $productFlat)
@include ('shop::products.list.card', ['product' => $productFlat->product])

View File

@ -1,4 +1,4 @@
@if ($products->count())
@if (app('Webkul\Product\Repositories\ProductRepository')->getNewProducts()->count())
<section class="featured-products">
<div class="featured-heading">
@ -8,14 +8,14 @@
</div>
<div class="product-grid-4">
@foreach ($products as $productFlat)
@foreach (app('Webkul\Product\Repositories\ProductRepository')->getNewProducts() as $productFlat)
@include ('shop::products.list.card', ['product' => $productFlat->product])
@endforeach
</div>
</section>
@endif

View File

@ -2,6 +2,15 @@
<div class="footer-content">
<div class="footer-list-container">
<?php
$categories = [];
foreach (app('Webkul\Category\Repositories\CategoryRepository')->getVisibleCategoryTree(core()->getCurrentChannel()->root_category_id) as $category){
if ($category->slug)
array_push($categories, $category);
}
?>
@if (count($categories))
<div class="list-container">
<span class="list-heading">Categories</span>

View File

@ -1,5 +1,16 @@
{!! view_render_event('bagisto.shop.layout.header.category.before') !!}
<?php
$categories = [];
foreach (app('Webkul\Category\Repositories\CategoryRepository')->getVisibleCategoryTree(core()->getCurrentChannel()->root_category_id) as $category) {
if ($category->slug)
array_push($categories, $category);
}
?>
<category-nav categories='@json($categories)' url="{{url()->to('/')}}"></category-nav>
{!! view_render_event('bagisto.shop.layout.header.category.after') !!}