ExpandRowColumn Accesses

This commit is contained in:
akosse 2020-02-04 12:17:14 +03:00
parent 6630452a1e
commit b35d6fd4fa
7 changed files with 208 additions and 75 deletions

View File

@ -44,6 +44,9 @@ return [
'calendar' => [
'class' => 'backend\modules\calendar\Calendar',
],
'gridview' => [
'class' => 'kartik\grid\Module',
]
],
'components' => [
'request' => [

View File

@ -2,12 +2,14 @@
namespace app\modules\accesses\controllers;
use backend\modules\card\models\UserCardSearch;
use common\classes\Debug;
use common\models\ProjectAccesses;
use common\models\UserCardAccesses;
use Yii;
use common\models\Accesses;
use app\modules\accesses\models\AccessesSearch;
use yii\data\ActiveDataProvider;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
@ -48,12 +50,19 @@ class AccessesController extends Controller
*/
public function actionIndex()
{
$searchModel = new AccessesSearch();
$searchModel = new UserCardSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
// $query = \common\models\UserCard::find()->select(['id_user', 'fio', 'email']);
//
// $provider = new ActiveDataProvider([
// 'query' => $query,
// ]);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
//'provider' => $provider
]);
}

View File

@ -2,6 +2,7 @@
namespace app\modules\accesses\models;
use common\classes\Debug;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Accesses;
@ -11,6 +12,8 @@ use common\models\Accesses;
*/
class AccessesSearch extends Accesses
{
public $fio;
/**
* {@inheritdoc}
*/
@ -18,7 +21,7 @@ class AccessesSearch extends Accesses
{
return [
[['id'], 'integer'],
[['name', 'login', 'password', 'link', 'project', 'info'], 'safe'],
[['name', 'login', 'password', 'link', 'project', 'info', 'fio'], 'safe'],
];
}
@ -40,12 +43,16 @@ class AccessesSearch extends Accesses
*/
public function search($params)
{
$query = Accesses::find();
//Debug::dd($params);
$query = Accesses::find()
->leftJoin('user_card_accesses', 'accesses.id = user_card_accesses.accesses_id')
->leftJoin('user_card', 'user_card_accesses.user_card_id = user_card.id')
->orderBy('user_card.fio asc');
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
'query' => $query
]);
$this->load($params);

View File

@ -0,0 +1,29 @@
<?php
use yii\grid\GridView;
use yii\helpers\Html;
/* @var $searchModel app\modules\accesses\models\AccessesSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
echo GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'name',
'login',
'password',
'link',
'project',
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view} {update} {delete}',
'buttons' => [
'delete' => function ($data) {
return Html::a("<span class='glyphicon glyphicon-trash' aria-hidden='true'></span>",
['/accesses/accesses/custom-delete', 'id' => $data]);
},
],
],
]
]);

View File

@ -1,7 +1,8 @@
<?php
use app\modules\accesses\models\AccessesSearch;
use kartik\grid\GridView;
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel app\modules\accesses\models\AccessesSearch */
@ -12,48 +13,41 @@ $this->params['breadcrumbs'][] = $this->title;
?>
<div class="accesses-index">
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a('Добавить доступ', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
<?php
echo GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'pjax' => true,
'striped' => true,
'hover' => true,
'toggleDataContainer' => ['class' => 'btn-group mr-2'],
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'name',
'login',
'password',
'link',
'project',
[
'attribute' => 'userCard.fio',
'format' => 'raw',
'value' => function(\common\models\Accesses $model){
return $model->getUserCardName();
'class' => 'kartik\grid\ExpandRowColumn',
'width' => '50px',
'value' => function ($model, $key, $index, $column) {
return GridView::ROW_COLLAPSED;
},
'detail' => function ($model, $key, $index, $column) {
$searchAccesses = new AccessesSearch();
$providerAccesses = $searchAccesses->search(Yii::$app->request->queryParams);
$providerAccesses->query->andWhere(['user_card.id_user' => $model->id_user]);
return Yii::$app->controller->renderPartial('_expand-row-details', ['dataProvider' => $providerAccesses]);
},
'headerOptions' => ['class' => 'kartik-sheet-style'],
'expandOneOnly' => true
],
// [
// 'attribute' => 'projects.name',
// 'format' => 'raw',
// 'value' => function(\common\models\Accesses $model){
// return $model->getProjectName();
// },
// ],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view} {update} {delete}',
'buttons' => [
'delete' => function ($data) {
return Html::a("<span class='glyphicon glyphicon-trash' aria-hidden='true'></span>",
['/accesses/accesses/custom-delete', 'id' => $data]);
},
],
],
// ['class' => 'yii\grid\ActionColumn'],
'fio',
'email'
],
]); ?>
]);
?>
</div>

View File

@ -28,6 +28,7 @@
"mirocow/yii2-eav": "*",
"kartik-v/yii2-widget-fileinput": "^1.0",
"2amigos/yii2-file-upload-widget": "~1.0",
"kartik-v/yii2-grid": "dev-master"
},
"require-dev": {
"yiisoft/yii2-debug": "~2.0.0",

170
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "cd1fbf237e9c2dd5e5075f26ed71b815",
"content-hash": "27fb15c02f7c345930818f5f2b532cf8",
"packages": [
{
"name": "2amigos/yii2-file-upload-widget",
@ -173,14 +173,13 @@
"version": "v3.16.0",
"source": {
"type": "git",
"url": "https://github.com/blueimp/JavaScript-Canvas-to-Blob.git",
"url": "git@github.com:blueimp/JavaScript-Canvas-to-Blob.git",
"reference": "eab2845ebb03c9667ea6ade002ceadbef071c060"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/blueimp/JavaScript-Canvas-to-Blob/zipball/eab2845ebb03c9667ea6ade002ceadbef071c060",
"reference": "eab2845ebb03c9667ea6ade002ceadbef071c060",
"shasum": null
"reference": "eab2845ebb03c9667ea6ade002ceadbef071c060"
},
"type": "bower-asset"
},
@ -189,14 +188,13 @@
"version": "v9.34.0",
"source": {
"type": "git",
"url": "https://github.com/blueimp/jQuery-File-Upload.git",
"url": "git@github.com:blueimp/jQuery-File-Upload.git",
"reference": "bb52d3493d725175fcf5554da034a317aaaea0e2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/blueimp/jQuery-File-Upload/zipball/bb52d3493d725175fcf5554da034a317aaaea0e2",
"reference": "bb52d3493d725175fcf5554da034a317aaaea0e2",
"shasum": null
"reference": "bb52d3493d725175fcf5554da034a317aaaea0e2"
},
"require": {
"bower-asset/blueimp-canvas-to-blob": ">=2.1.1",
@ -214,14 +212,13 @@
"version": "v2.17.0",
"source": {
"type": "git",
"url": "https://github.com/blueimp/Gallery.git",
"url": "git@github.com:blueimp/Gallery.git",
"reference": "8336bb5934cb623608808601129db3fbf9201a09"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/blueimp/Gallery/zipball/8336bb5934cb623608808601129db3fbf9201a09",
"reference": "8336bb5934cb623608808601129db3fbf9201a09",
"shasum": null
"reference": "8336bb5934cb623608808601129db3fbf9201a09"
},
"type": "bower-asset"
},
@ -230,14 +227,13 @@
"version": "v2.24.0",
"source": {
"type": "git",
"url": "https://github.com/blueimp/JavaScript-Load-Image.git",
"url": "git@github.com:blueimp/JavaScript-Load-Image.git",
"reference": "1196b4ce3c56f01cacf90fc5527b324ecccdf3b0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/blueimp/JavaScript-Load-Image/zipball/1196b4ce3c56f01cacf90fc5527b324ecccdf3b0",
"reference": "1196b4ce3c56f01cacf90fc5527b324ecccdf3b0",
"shasum": null
"reference": "1196b4ce3c56f01cacf90fc5527b324ecccdf3b0"
},
"type": "bower-asset"
},
@ -246,14 +242,13 @@
"version": "v3.13.0",
"source": {
"type": "git",
"url": "https://github.com/blueimp/JavaScript-Templates.git",
"url": "git@github.com:blueimp/JavaScript-Templates.git",
"reference": "07b3dd455b971cf5d087fc86889fcadae48ab2fc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/blueimp/JavaScript-Templates/zipball/07b3dd455b971cf5d087fc86889fcadae48ab2fc",
"reference": "07b3dd455b971cf5d087fc86889fcadae48ab2fc",
"shasum": null
"reference": "07b3dd455b971cf5d087fc86889fcadae48ab2fc"
},
"type": "bower-asset"
},
@ -262,14 +257,13 @@
"version": "v3.4.1",
"source": {
"type": "git",
"url": "https://github.com/twbs/bootstrap.git",
"url": "git@github.com:twbs/bootstrap.git",
"reference": "68b0d231a13201eb14acd3dc84e51543d16e5f7e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twbs/bootstrap/zipball/68b0d231a13201eb14acd3dc84e51543d16e5f7e",
"reference": "68b0d231a13201eb14acd3dc84e51543d16e5f7e",
"shasum": null
"reference": "68b0d231a13201eb14acd3dc84e51543d16e5f7e"
},
"require": {
"bower-asset/jquery": ">=1.9.1,<4.0"
@ -284,14 +278,13 @@
"version": "3.3.11",
"source": {
"type": "git",
"url": "https://github.com/RobinHerbots/Inputmask.git",
"url": "git@github.com:RobinHerbots/Inputmask.git",
"reference": "5e670ad62f50c738388d4dcec78d2888505ad77b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/RobinHerbots/Inputmask/zipball/5e670ad62f50c738388d4dcec78d2888505ad77b",
"reference": "5e670ad62f50c738388d4dcec78d2888505ad77b",
"shasum": null
"reference": "5e670ad62f50c738388d4dcec78d2888505ad77b"
},
"require": {
"bower-asset/jquery": ">=1.7"
@ -306,14 +299,13 @@
"version": "3.4.1",
"source": {
"type": "git",
"url": "https://github.com/jquery/jquery-dist.git",
"url": "git@github.com:jquery/jquery-dist.git",
"reference": "15bc73803f76bc53b654b9fdbbbc096f56d7c03d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/jquery/jquery-dist/zipball/15bc73803f76bc53b654b9fdbbbc096f56d7c03d",
"reference": "15bc73803f76bc53b654b9fdbbbc096f56d7c03d",
"shasum": null
"reference": "15bc73803f76bc53b654b9fdbbbc096f56d7c03d"
},
"type": "bower-asset",
"license": [
@ -325,14 +317,13 @@
"version": "1.12.1",
"source": {
"type": "git",
"url": "git@github.com:components/jqueryui.git",
"url": "https://github.com/components/jqueryui.git",
"reference": "44ecf3794cc56b65954cc19737234a3119d036cc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/components/jqueryui/zipball/44ecf3794cc56b65954cc19737234a3119d036cc",
"reference": "44ecf3794cc56b65954cc19737234a3119d036cc",
"shasum": null
"reference": "44ecf3794cc56b65954cc19737234a3119d036cc"
},
"require": {
"bower-asset/jquery": ">=1.6"
@ -353,8 +344,7 @@
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/moment/moment/zipball/96d0d6791ab495859d09a868803d31a55c917de1",
"reference": "96d0d6791ab495859d09a868803d31a55c917de1",
"shasum": null
"reference": "96d0d6791ab495859d09a868803d31a55c917de1"
},
"type": "bower-asset",
"license": [
@ -372,8 +362,7 @@
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nkovacs/bootstrap-datetimepicker/zipball/e2cd618741a467b702cc1076c3dc07472cd226b5",
"reference": "e2cd618741a467b702cc1076c3dc07472cd226b5",
"shasum": null
"reference": "e2cd618741a467b702cc1076c3dc07472cd226b5"
},
"require": {
"bower-asset/jquery": ">=1.8.3",
@ -395,8 +384,7 @@
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/bestiejs/punycode.js/zipball/38c8d3131a82567bfef18da09f7f4db68c84f8a3",
"reference": "38c8d3131a82567bfef18da09f7f4db68c84f8a3",
"shasum": null
"reference": "38c8d3131a82567bfef18da09f7f4db68c84f8a3"
},
"type": "bower-asset"
},
@ -405,14 +393,13 @@
"version": "2.0.7.1",
"source": {
"type": "git",
"url": "git@github.com:yiisoft/jquery-pjax.git",
"url": "https://github.com/yiisoft/jquery-pjax.git",
"reference": "aef7b953107264f00234902a3880eb50dafc48be"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yiisoft/jquery-pjax/zipball/aef7b953107264f00234902a3880eb50dafc48be",
"reference": "aef7b953107264f00234902a3880eb50dafc48be",
"shasum": null
"reference": "aef7b953107264f00234902a3880eb50dafc48be"
},
"require": {
"bower-asset/jquery": ">=1.8"
@ -853,6 +840,109 @@
],
"time": "2019-09-11T18:05:56+00:00"
},
{
"name": "kartik-v/yii2-dialog",
"version": "v1.0.5",
"source": {
"type": "git",
"url": "https://github.com/kartik-v/yii2-dialog.git",
"reference": "c38616d719f52530749457c022ca6134d0ad31ce"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/kartik-v/yii2-dialog/zipball/c38616d719f52530749457c022ca6134d0ad31ce",
"reference": "c38616d719f52530749457c022ca6134d0ad31ce",
"shasum": ""
},
"require": {
"kartik-v/yii2-krajee-base": ">=2.0.0"
},
"type": "yii2-extension",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"kartik\\dialog\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Kartik Visweswaran",
"email": "kartikv2@gmail.com",
"homepage": "http://www.krajee.com/"
}
],
"description": "An asset bundle for bootstrap3-dialog for Yii 2.0 framework.",
"homepage": "https://github.com/kartik-v/yii2-dialog",
"keywords": [
"alert",
"bootstrap",
"dialog",
"extension",
"modal",
"yii2"
],
"time": "2018-10-09T08:08:51+00:00"
},
{
"name": "kartik-v/yii2-grid",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/kartik-v/yii2-grid.git",
"reference": "878da21514481b81fa2e4d989069095aa9a3f002"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/kartik-v/yii2-grid/zipball/878da21514481b81fa2e4d989069095aa9a3f002",
"reference": "878da21514481b81fa2e4d989069095aa9a3f002",
"shasum": ""
},
"require": {
"kartik-v/yii2-dialog": "~1.0"
},
"suggest": {
"kartik-v/yii2-mpdf": "For exporting grids to PDF"
},
"type": "yii2-extension",
"extra": {
"branch-alias": {
"dev-master": "3.3.x-dev"
}
},
"autoload": {
"psr-4": {
"kartik\\grid\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Kartik Visweswaran",
"email": "kartikv2@gmail.com",
"homepage": "http://www.krajee.com/"
}
],
"description": "Yii 2 GridView on steroids. Various enhancements and utilities for the Yii 2.0 GridView widget.",
"homepage": "https://github.com/kartik-v/yii2-grid",
"keywords": [
"extension",
"grid",
"widget",
"yii2"
],
"time": "2020-01-04T12:20:10+00:00"
},
{
"name": "kartik-v/yii2-krajee-base",
"version": "v2.0.5",
@ -2132,8 +2222,7 @@
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twitter/typeahead.js/zipball/588440f66559714280628a4f9799f0c4eb880a4a",
"reference": "588440f66559714280628a4f9799f0c4eb880a4a",
"shasum": null
"reference": "588440f66559714280628a4f9799f0c4eb880a4a"
},
"require": {
"bower-asset/jquery": ">=1.7"
@ -4855,7 +4944,8 @@
"stability-flags": {
"kartik-v/yii2-widget-select2": 20,
"kavalar/hhapi": 20,
"kartik-v/yii2-widget-datepicker": 20
"kartik-v/yii2-widget-datepicker": 20,
"kartik-v/yii2-grid": 20
},
"prefer-stable": false,
"prefer-lowest": false,