Merge pull request #394 from prashant-webkul/Prashant

Prashant -> fixes for #392 #319 #304 #378, #379 #373 #369
This commit is contained in:
Prashant Singh 2018-12-22 18:10:22 +05:30 committed by GitHub
commit c939a57303
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 159 additions and 36 deletions

View File

@ -150,22 +150,22 @@ class AttributeDataGrid
'type' => 'string',
'label' => 'Type',
], [
'name' => 'is_required',
'column' => 'is_required',
'alias' => 'attributeIsRequired',
'type' => 'boolean',
'label' => 'Required',
], [
'name' => 'is_unique',
'column' => 'is_unique',
'alias' => 'attributeIsUnique',
'type' => 'boolean',
'label' => 'Unique',
], [
'name' => 'value_per_locale',
'column' => 'value_per_locale',
'alias' => 'attributeValuePerLocale',
'type' => 'boolean',
'label' => 'Locale based',
], [
'name' => 'value_per_channel',
'column' => 'value_per_channel',
'alias' => 'attributeValuePerChannel',
'type' => 'boolean',
'label' => 'Channel based',

View File

@ -123,7 +123,7 @@ class ProductDataGrid
'type' => 'string',
'label' => 'Product Quantity',
'sortable' => true,
],
]
],
'filterable' => [
@ -149,7 +149,7 @@ class ProductDataGrid
'type' => 'string',
'label' => 'Product Type',
], [
'name' => 'prods.status',
'column' => 'prods.status',
'alias' => 'ProductStatus',
'type' => 'boolean',
'label' => 'Status'

View File

@ -324,6 +324,10 @@ Route::group(['middleware' => ['web']], function () {
//delete backend user
Route::get('/users/delete/{id}', 'Webkul\User\Http\Controllers\UserController@destroy')->name('admin.users.delete');
Route::post('/confirm/destroy', 'Webkul\User\Http\Controllers\UserController@destroySelf')->defaults('_config', [
'redirect' => 'admin.users.index'
])->name('admin.users.confirm.destroy');
// User Role Routes
Route::get('/roles', 'Webkul\User\Http\Controllers\RoleController@index')->defaults('_config', [
'view' => 'admin::users.roles.index'

View File

@ -73,24 +73,29 @@ class Product {
$variants = [];
$this->productGrid->create($gridObject);
$found = $this->productGrid->findOneByField('product_id', $product->id);
if($product->type == 'configurable') {
$variants = $product->variants()->get();
//extra measure to stop duplicate entries
if($found == null) {
$this->productGrid->create($gridObject);
foreach($variants as $variant) {
$variantObj = [
'product_id' => $variant->id,
'sku' => $variant->sku,
'type' => $variant->type,
'attribute_family_name' => $variant->toArray()['attribute_family']['name'],
'name' => $variant->name,
'quantity' => 0,
'status' => $variant->status,
'price' => $variant->price,
];
if($product->type == 'configurable') {
$variants = $product->variants()->get();
$this->productGrid->create($variantObj);
foreach($variants as $variant) {
$variantObj = [
'product_id' => $variant->id,
'sku' => $variant->sku,
'type' => $variant->type,
'attribute_family_name' => $variant->toArray()['attribute_family']['name'],
'name' => $variant->name,
'quantity' => 0,
'status' => $variant->status,
'price' => $variant->price,
];
$this->productGrid->create($variantObj);
}
}
}
@ -268,6 +273,13 @@ class Product {
$gridObject = [];
}
$this->findRepeated();
return true;
}
public function findRepeated() {
}
}

View File

@ -50,6 +50,7 @@ return [
'change-password' => 'Change Account Password',
'current-password' => 'Current Password'
],
'users' => [
'forget-password' => [
'title' => 'Forget Password',
@ -60,6 +61,7 @@ return [
'back-link-title' => 'Back to Sign In',
'submit-btn-title' => 'Email Password Reset Link'
],
'reset-password' => [
'title' => 'Reset Password',
'title' => 'Reset Password',
@ -69,6 +71,7 @@ return [
'back-link-title' => 'Back to Sign In',
'submit-btn-title' => 'Reset Password'
],
'roles' => [
'title' => 'Roles',
'add-role-title' => 'Add Role',
@ -82,6 +85,7 @@ return [
'custom' => 'Custom',
'all' => 'All'
],
'users' => [
'title' => 'User',
'add-user-title' => 'Add User',
@ -95,8 +99,15 @@ return [
'status-and-role' => 'Status and Role',
'role' => 'Role',
'status' => 'Status',
'account-is-active' => 'Account is Active'
'account-is-active' => 'Account is Active',
'current-password' => 'Enter Current Password',
'confirm-delete' => 'Confirm Delete This Account',
'confirm-delete-title' => 'Confirm password before delete',
'delete-last' => 'At least one admin is required.',
'delete-success' => 'Success! User deleted',
'incorrect-password' => 'The password you entered is incorrect'
],
'sessions' => [
'title' => 'Sign In',
'email' => 'Email',
@ -106,6 +117,7 @@ return [
'submit-btn-title' => 'Sign In'
]
],
'sales' => [
'orders' => [
'title' => 'Orders',
@ -157,6 +169,7 @@ return [
'total-due' => 'Total Due',
'cancel-confirm-msg' => 'Are you sure you want to cancel this order ?'
],
'invoices' => [
'title' => 'Invoices',
'id' => 'Id',
@ -178,6 +191,7 @@ return [
'print' => 'Print',
'order-date' => 'Order Date'
],
'shipments' => [
'title' => 'Shipments',
'id' => 'Id',
@ -196,6 +210,7 @@ return [
'view-title' => 'Shipment #:shipment_id',
]
],
'catalog' => [
'products' => [
'title' => 'Products',
@ -227,8 +242,10 @@ return [
'add-variant-title' => 'Add Variant',
'variant-already-exist-message' => 'Variant with same attribute options already exists.',
'add-image-btn-title' => 'Add Image',
'mass-delete-success' => 'All the selected index of products have been deleted successfully'
'mass-delete-success' => 'All the selected index of products have been deleted successfully',
'mass-update-success' => 'All the selected index of products have been updated successfully'
],
'attributes' => [
'title' => 'Attributes',
'add-title' => 'Add Attribute',

View File

@ -0,0 +1,37 @@
@extends('admin::layouts.content')
@section('page_title')
{{ __('admin::app.customers.customers.title') }}
@stop
@section('content')
<div class="content">
<div class="page-header">
<div class="page-title">
<h1>{{ __('admin::app.users.users.confirm-delete-title') }}</h1>
</div>
<div class="page-action">
</div>
</div>
<div class="page-content">
<form action="{{ route('admin.users.confirm.destroy') }}" method="POST" @submit.prevent="onSubmit">
@csrf
<div class="control-group" :class="[errors.has('password') ? 'has-error' : '']">
<label for="password" class="required">
{{ __('admin::app.users.users.current-password') }}
</label>
<input type="password" v-validate="'required'" class="control" id="password" name="password" data-vv-as="&quot;{{ __('admin::app.users.users.password') }}&quot;"/>
<span class="control-error" v-if="errors.has('password')">
@{{ errors.first('password') }}
</span>
</div>
<input type="submit" class="btn btn-md btn-primary" value="{{ __('admin::app.users.users.confirm-delete') }}">
</form>
</div>
</div>
@endsection

View File

@ -30,6 +30,9 @@
<div class="dropdown-container">
<label>Account</label>
<ul>
<li>
<a href="{{ route('shop.home.index') }}" target="_blank">Visit Shop</a>
</li>
<li>
<a href="{{ route('admin.account.edit') }}">My Account</a>
</li>

View File

@ -142,7 +142,6 @@ class ProductController extends Controller
'sku' => ['required', 'unique:products,sku', new \Webkul\Core\Contracts\Validations\Slug]
]);
//before store of the product
Event::fire('catalog.product.create.before');
@ -268,7 +267,7 @@ class ProductController extends Controller
Event::fire('catelog.product.update.after', $product);
} else if($data['update-options'] == 1 && $data['selected-option-text'] == 'Active') {
Event::fire('catelog.product.update.before', $productId);
$result = $this->product->updateAttribute($product, $attribute, $data['update-options']);
if($result)
@ -277,7 +276,7 @@ class ProductController extends Controller
}
}
session()->flash('success', trans('admin::app.catalog.products.mass-delete-success'));
session()->flash('success', trans('admin::app.catalog.products.mass-update-success'));
return redirect()->route($this->_config['redirect']);
}

View File

@ -456,7 +456,11 @@ input {
}
.product-card:hover {
box-shadow: 1px 1px 10px #ccc;
outline: 1px solid #eaeaec;
box-shadow: 0 1px 2px rgba(0,0,0,0.05);
-webkit-box-shadow: 0px 2px 16px 4px rgba(40, 44, 63, 0.07);
-moz-box-shadow: 0px 2px 16px 4px rgba(40, 44, 63, 0.07);
box-shadow: 0px 2px 16px 4px rgba(40, 44, 63, 0.07);
}
@media only screen and (max-width: 580px) {

View File

@ -567,7 +567,10 @@ class DataGrid
if ($this->aliased) { //aliasing is expected in this case or it will be changed to presence of join bag
foreach ($parsed as $key=>$value) {
if ($key=="sort") {
$column_name = $this->findAlias($key);
$column_type = $this->findType($key);
if ($key == "sort") {
//resolve the case with the column helper class
if(substr_count($key,'_') >= 1)
$column_name = $this->findAlias($key);
@ -603,18 +606,26 @@ class DataGrid
}
} else {
foreach ($value as $condition => $filter_value) {
$this->query->where(
$column_name,
$this->operators[$condition],
$filter_value
);
if($column_type == 'datetime') {
$this->query->whereDate(
$column_name,
$this->operators[$condition],
$filter_value
);
} else {
$this->query->where(
$column_name,
$this->operators[$condition],
$filter_value
);
}
}
}
}
}
} else {
//this is the case for the non aliasing.
foreach ($parsed as $key=>$value) {
foreach ($parsed as $key => $value) {
if ($key=="sort") {
@ -631,7 +642,6 @@ class DataGrid
throw new \Exception('Multiple Sort keys Found, Please Resolve the URL Manually.');
}
} elseif ($key=="search") {
$count_keys = count(array_keys($value));
if($count_keys==1)
$this->query->where(function ($query) use ($parsed) {

View File

@ -8,6 +8,7 @@ use Illuminate\Support\Facades\Event;
use Webkul\User\Repositories\AdminRepository as Admin;
use Webkul\User\Repositories\RoleRepository as Role;
use Webkul\User\Http\Requests\UserForm;
use Hash;
/**
* Admin user controller
@ -94,7 +95,7 @@ class UserController extends Controller
$data['password'] = bcrypt($data['password']);
Event::fire('user.admin.create.before');
$admin = $this->admin->create($data);
Event::fire('user.admin.delete.after', $admin);
@ -165,6 +166,10 @@ class UserController extends Controller
} else {
Event::fire('user.admin.delete.before', $id);
if (auth()->guard('admin')->user()->id == $id) {
return view('admin::customers.confirm-password');
}
$this->admin->delete($id);
Event::fire('user.admin.delete.after', $id);
@ -174,4 +179,36 @@ class UserController extends Controller
return redirect()->back();
}
/**
* destroy current after confirming
*
* @return mixed
*/
public function destroySelf()
{
$password = request()->input('password');
if(Hash::check($password, auth()->guard('admin')->user()->password)) {
if($this->admin->count() == 1) {
session()->flash('error', trans('admin::app.users.users.delete-last'));
} else {
$id = auth()->guard('admin')->user()->id;
Event::fire('user.admin.delete.before', $id);
$this->admin->delete($id);
Event::fire('user.admin.delete.after', $id);
session()->flash('success', trans('admin::app.users.users.delete-success'));
return redirect()->route('admin.session.create');
}
} else {
session()->flash('warning', trans('admin::app.users.users.incorrect-password'));
return redirect()->route($this->_config['redirect']);
}
}
}