From 7a7cacf515eb4735f7035ff1876296e5ab21ad12 Mon Sep 17 00:00:00 2001 From: prashant-webkul Date: Thu, 2 Aug 2018 20:28:12 +0530 Subject: [PATCH] fixes and style changes --- .gitignore | 1 + .../Http/Controllers/DataGridController.php | 113 ++++++------------ .../Shop/src/Resources/assets/js/app.js | 50 ++------ .../assets/js/components/category-nav.vue | 3 +- .../Shop/src/Resources/assets/sass/app.scss | 8 +- .../views/store/header/index.blade.php | 44 ++++++- packages/Webkul/Ui/src/DataGrid/DataGrid.php | 57 ++++----- .../Webkul/Ui/src/DataGrid/Helpers/Column.php | 12 +- .../Ui/src/Resources/assets/sass/app.scss | 10 +- 9 files changed, 121 insertions(+), 177 deletions(-) diff --git a/.gitignore b/.gitignore index a8b6a79d2..b8f14e562 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ Homestead.yaml npm-debug.log yarn-error.log .env +/ignorables/* \ No newline at end of file diff --git a/packages/Webkul/Admin/src/Http/Controllers/DataGridController.php b/packages/Webkul/Admin/src/Http/Controllers/DataGridController.php index be8676840..ef0a5c080 100644 --- a/packages/Webkul/Admin/src/Http/Controllers/DataGridController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/DataGridController.php @@ -22,120 +22,72 @@ class DataGridController extends Controller */ public function index() { - // $select_verbs = [ - // 0 => "aggregate", - // 1 => "columns", - // 2 => "from", - // 3 => "joins", - // 4 => "wheres", - // 5 => "groups", - // 6 => "havings", - // 7 => "orders", - // 8 => "limit", - // 9 => "offset", - // 10 => "lock" - // ]; - // $bindings = [ - // "select" => [], - // "from" => [], - // "join" => [], - // "where" => [], - // "having" => [], - // "order" => [], - // "union" => [], - // ]; - // $operators = [ - // 'eq' => "=", - // 'lt' => "<", - // 'gt' => ">", - // 'lte' => "<=", - // 'gte' => ">=", - // 'neqs' => "<>", - // 'neqn' => "!=", - // 'ceq' => "<=>", - // 'like' => "like", - // 'likebin' => "like binary", - // 'ntlike' => "not like", - // 'ilike' => "ilike", - // 'regex' => "regexp", - // 'notregex' => "not regexp", - // 'simto' => "similar to", - // 'nsimto' => "not similar to", - // 'nilike' => "not ilike", - // ]; DataGrid::make([ - 'name' => 'authors', - 'table' => 'authors as a', - 'select' => 'a.id', + 'name' => 'Admin Datagrid', + 'table' => 'admins as u', + 'select' => 'u.id', 'aliased' => true , //boolean to validate aliasing on the basis of this. 'filterable' => [ [ - 'column' => 'a.id', + 'column' => 'u.id', 'type' => 'integer', 'label' => 'Admin ID' ], [ - 'column' => 'a.email', + 'column' => 'u.email', 'type' => 'string', 'label' => 'Admin E-Mail', ], [ - 'column' => 'a.first_name', + 'column' => 'u.name', 'type' => 'string', 'label' => 'Admin Name', ] ], 'searchables' =>[ [ - 'name' => 'a.id', + 'name' => 'u.id', 'label' => 'ID', 'label' => 'Admin ID', ], [ - 'name' => 'a.name', + 'name' => 'u.name', 'label' => 'Name', 'label' => 'Admin Name', ] ], 'join' => [ - // [ - // 'join' => 'leftjoin', - // 'table' => 'posts as p', - // 'primaryKey' => 'a.id', - // 'condition' => '=', - // 'secondaryKey' => 'p.author_id', - // ] + [ + 'join' => 'leftjoin', + 'table' => 'roles as r', + 'primaryKey' => 'u.role_id', + 'condition' => '=', + 'secondaryKey' => 'r.id', + ] ], 'columns' => [ [ - 'name' => 'a.id', + 'name' => 'u.id', 'type' => 'string', 'label' => 'Admin ID', 'sortable' => true, 'filterable' => true ], [ - 'name' => 'a.email', + 'name' => 'u.email', 'type' => 'string', 'label' => 'Admin E-Mail', 'sortable' => true, 'filterable' => true ], - // [ - // 'name' => 'p.content as pp', - // 'type' => 'string', - // 'label' => 'Content', - // 'sortable' => true, - // 'filterable' => false, - // ], [ - 'name' => 'a.first_name', + 'name' => 'u.name', 'type' => 'string', 'label' => 'Admin Name', 'sortable' => true, 'filterable' => true, // will create on run time query // 'filter' => [ - // 'function' => 'where', // orwhere - // 'condition' => ['name', '=', 'Admin'] // multiarray + // 'function' => 'orwhere', // orwhere + // 'condition' => ['name', 'like', 'u'] // multiarray // ], 'attributes' => [ 'class' => 'class-a class-b', @@ -143,10 +95,23 @@ class DataGridController extends Controller 'onclick' => "window.alert('alert from datagrid column')" ], 'wrapper' => function ($value, $object) { - return '' . $object->first_name . ''; + return '' . $object->name . ''; }, ], - + [ + 'name' => 'r.name as x', + 'type' => 'string', + 'label' => 'Admin\'s Role', + 'sortable' => true, + 'filterable' => true, + ], + [ + 'name' => 'r.id as xx', + 'type' => 'integer', + 'label' => 'Role ID', + 'sortable' => false, + 'filterable' => false + ], ], 'operators' => [ @@ -174,13 +139,6 @@ class DataGridController extends Controller ]); $result = DataGrid::render(); return $result; - // $prepareMassAction = DataGrid::massAction(); - // if ($prepareMassAction) { - // $result = DataGrid::render(); - // return $result; - // } else { - // throw new \Exception('Mass Actions Attributes Have Some Unknown Problems'); - // } } //for performing mass actions @@ -213,7 +171,6 @@ class DataGridController extends Controller ] ]; $result = DataGrid::makeMassAction($make); - // return $result; } public function massDelete(Request $r) diff --git a/packages/Webkul/Shop/src/Resources/assets/js/app.js b/packages/Webkul/Shop/src/Resources/assets/js/app.js index 84547dd7b..8b1427874 100644 --- a/packages/Webkul/Shop/src/Resources/assets/js/app.js +++ b/packages/Webkul/Shop/src/Resources/assets/js/app.js @@ -10,54 +10,18 @@ Vue.component("category-nav", require("./components/category-nav.vue")); Vue.component("category-item", require("./components/category-item.vue")); Vue.component("image-slider", require("./components/imageSlider.vue")); -$(window).resize(function() { - var w = $(document).width(); - var window = {}; - window.width = $(document).width(); - window.height = $(document).height(); - if (window.width < 785) { - $(".header").css("margin-bottom", "0"); - $(".header-top").css("margin-bottom", "0"); - $("ul.search-container").css("display", "none"); - $(".header-bottom").css("display", "none"); - $("div.right-content").css("display", "none"); - $(".right-responsive").css("display", "inherit"); - } else if (window.width > 785) { - $(".header").css("margin-bottom", "21px"); - $(".header-top").css("margin-bottom", "16px"); - $("ul.search-container").css("display", "inherit"); - $(".header-bottom").css("display", "block"); - $("div.right-content").css("display", "inherit"); - $(".right-responsive").css("display", "none"); - } -}); - -$(document).ready(function() { - /* Responsiveness script goes here */ - var w = $(document).width(); - var window = {}; - window.width = $(document).width(); - window.height = $(document).height(); - if (window.width < 785) { - $(".header").css("margin-bottom", "0"); - $(".header-top").css("margin-bottom", "0"); - $("ul.search-container").css("display", "none"); - $(".header-bottom").css("display", "none"); - $("div.right-content").css("display", "none"); - $(".right-responsive").css("display", "inherit"); - } - /* Responsiveness script ends here */ +$(document).ready(function () { const app = new Vue({ el: "#app", - mounted: function() { + mounted: function () { this.addServerErrors(); this.addFlashMessages(); }, methods: { - onSubmit: function(e) { + onSubmit: function (e) { this.$validator.validateAll().then(result => { if (result) { e.target.submit(); @@ -65,7 +29,7 @@ $(document).ready(function() { }); }, - addServerErrors: function() { + addServerErrors: function () { var scope = null; for (var key in serverErrors) { const field = this.$validator.fields.find({ @@ -83,14 +47,14 @@ $(document).ready(function() { } }, - addFlashMessages: function() { + addFlashMessages: function () { const flashes = this.$refs.flashes; - flashMessages.forEach(function(flash) { + flashMessages.forEach(function (flash) { flashes.addFlash(flash); }, this); }, - responsiveHeader: function() {} + responsiveHeader: function () { } } }); }); diff --git a/packages/Webkul/Shop/src/Resources/assets/js/components/category-nav.vue b/packages/Webkul/Shop/src/Resources/assets/js/components/category-nav.vue index 6f6f22704..6bbcda3bd 100644 --- a/packages/Webkul/Shop/src/Resources/assets/js/components/category-nav.vue +++ b/packages/Webkul/Shop/src/Resources/assets/js/components/category-nav.vue @@ -8,7 +8,8 @@ :item="item">
  • - Offer Zone + + Offer Zone
  • diff --git a/packages/Webkul/Shop/src/Resources/assets/sass/app.scss b/packages/Webkul/Shop/src/Resources/assets/sass/app.scss index 8e3f9a74c..103144b48 100644 --- a/packages/Webkul/Shop/src/Resources/assets/sass/app.scss +++ b/packages/Webkul/Shop/src/Resources/assets/sass/app.scss @@ -194,6 +194,7 @@ body { // color: $offer-color; // } // } + ul.nav { display: block; font-size:16px; @@ -240,8 +241,13 @@ body { } .nav > li:last-child { + display:flex; align-items:center; border-radius: 0 0 4px 0; - margin-right: 0; + float:right; + + img { + margin-right:6px; + } } .nav > li:last-child > a { diff --git a/packages/Webkul/Shop/src/Resources/views/store/header/index.blade.php b/packages/Webkul/Shop/src/Resources/views/store/header/index.blade.php index 367bc1af2..9e78eb5b1 100644 --- a/packages/Webkul/Shop/src/Resources/views/store/header/index.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/store/header/index.blade.php @@ -74,4 +74,46 @@
    @include('shop::store.header.nav-menu.navmenu')
    - \ No newline at end of file + +@section('javascript') + +@endsection \ No newline at end of file diff --git a/packages/Webkul/Ui/src/DataGrid/DataGrid.php b/packages/Webkul/Ui/src/DataGrid/DataGrid.php index c0296aa32..a468040ec 100644 --- a/packages/Webkul/Ui/src/DataGrid/DataGrid.php +++ b/packages/Webkul/Ui/src/DataGrid/DataGrid.php @@ -10,6 +10,7 @@ use Webkul\Ui\DataGrid\Helpers\Column; use Webkul\Ui\DataGrid\Helpers\Pagination; use Webkul\Ui\DataGrid\Helpers\Css; use Webkul\Ui\DataGrid\Helpers\MassAction; +use URL; class DataGrid { @@ -385,39 +386,6 @@ class DataGrid return $this; } - /** - * Parse the URL - * and get it ready - * to be used. - */ - - // private function parse() - // { - // //parse the url here - // if (isset($_SERVER['QUERY_STRING'])) { - // $qr = $_SERVER['QUERY_STRING']; - // parse_str($qr, $parsed); - // foreach ($parsed as $k=>$v) { - // parse_str($v, $parsed[$k]); - // } - // return $parsed; - // } else { - // return $parsed = []; - // } - // } - - private function parse() - { - $parsed = []; - $unparsed = $_SERVER['QUERY_STRING']; - if (isset($unparsed)) { - parse_str($unparsed, $parsed); - return $parsed; - } else { - return $parsed; - } - } - /** * Used for selecting * the columns got in @@ -436,6 +404,25 @@ class DataGrid } } + /** + * Parse the URL + * and get it ready + * to be used. + */ + + private function parse() + { + $parsed = []; + $unparsed = url()->full(); + if (count(explode('?', $unparsed))>1) { + $to_be_parsed = explode('?', $unparsed)[1]; + parse_str($to_be_parsed, $parsed); + return $parsed; + } else { + return $parsed; + } + } + /** * ->join('contacts', 'users.id', '=', 'contacts.user_id') * @return $this->query @@ -452,6 +439,7 @@ class DataGrid { foreach ($this->columns as $column) { if ($column->filter) { // if the filter bag in array exists then these will be applied. + dd($column); if (count($column->filter['condition']) == count($column->filter['condition'], COUNT_RECURSIVE)) { $this->query->{$column->filter['function']}(...$column->filter['condition']); } else { @@ -651,14 +639,13 @@ class DataGrid foreach ($this->join as $join) { $name = strtolower($join['join']); //Allow joins i.e left or right - if ($name=='leftjoin' || $name=='left join' || $name=='rightjoin' || $name=='right join') { + if ($name=='leftjoin' || $name=='rightjoin') { //check if the aliasing on the primary table and primaryKey in join is also the same $primary_key_alias = trim(explode('.', $join['primaryKey'])[0]); if ($primary_key_alias == $table_alias) { $join_table_alias = explode('as', $join['table']); - if (isset($join_table_alias)) { $alias1 = trim($join_table_alias[1]); //important!!!!! diff --git a/packages/Webkul/Ui/src/DataGrid/Helpers/Column.php b/packages/Webkul/Ui/src/DataGrid/Helpers/Column.php index 6bf15cbee..cad3cba73 100644 --- a/packages/Webkul/Ui/src/DataGrid/Helpers/Column.php +++ b/packages/Webkul/Ui/src/DataGrid/Helpers/Column.php @@ -13,17 +13,6 @@ class Column extends AbstractFillable private $readableName = false; private $value = false; private $sortHtml = '%s'; - // private $sortHtml = '%s'; - - // protected $name; - // protected $type; - // protected $label; - // protected $filterable; - // protected $sortable; - // protected $attributes; - // protected $wrapper; - // protected $callback; - /** * Without Array it will treat it like string @@ -53,6 +42,7 @@ class Column extends AbstractFillable 'type', 'label', 'sortable', + 'searchable', 'filterable', 'filter' => [ 'allowed' => 'array', diff --git a/packages/Webkul/Ui/src/Resources/assets/sass/app.scss b/packages/Webkul/Ui/src/Resources/assets/sass/app.scss index 31333f828..8ef12dc69 100644 --- a/packages/Webkul/Ui/src/Resources/assets/sass/app.scss +++ b/packages/Webkul/Ui/src/Resources/assets/sass/app.scss @@ -213,10 +213,9 @@ h2 { } tbody td { - padding: 12px 10px; + padding: 10px; border-bottom: solid 1px #d3d3d3; color: #3a3a3a; - vertical-align: top; &.actions { text-align: right; @@ -616,8 +615,6 @@ h2 { } .grid-container { - margin-top: 30px; - .filter-wrapper { display: block; box-sizing: border-box; @@ -932,9 +929,8 @@ h2 { } } - .label { - background: #E7E7E7; + background: #e7e7e7; border-radius: 2px; padding: 8px; color: #000311; @@ -955,4 +951,4 @@ h2 { &.label-xl { padding: 14px; } -} \ No newline at end of file +}