GithubHelp home page GithubHelp logo

yii2tech / admin Goto Github PK

View Code? Open in Web Editor NEW
103.0 15.0 19.0 193 KB

Admin pack (actions, widgets, etc) for Yii2

License: Other

PHP 100.00%
yii yii2 yii2-extension admin-crud admin administration

admin's People

Contributors

anatolyrugalev avatar faryshta avatar gugoan avatar klimov-paul avatar maxxer avatar ryadnov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

admin's Issues

Add @see phpDoc annotation in generated views

It would be very useful for IDE users if generated views contained corresponding controller actions, like following

<?php

// Corresponding controller and action
/** @see \app\modules\admin\feedback\controllers\DefaultController corresponding controller*/
/** @see \yii2tech\admin\actions\Index corresponding action */

use yii\grid\GridView;
use yii2tech\admin\grid\ActionColumn;

/* @var $this yii\web\View */
/* @var $searchModel app\models\search\FeedbackSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Feedbacks';
$this->params['breadcrumbs'][] = $this->title;
$this->params['contextMenuItems'] = [
    ['create']
];
?>

<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'columns' => [
        ['class' => 'yii\grid\SerialColumn'],
        'id',
        'title',
        'phone',
        'email:email',
        'body:ntext',
        [
            'class' => ActionColumn::className(),
        ],
    ],
]); ?>

It might be too much for some users so this feature could be configurable via checkbox or something like that.

Add ability to setup flash messages for the Update and Create classes.

Update and create actions often requires a flash message being set. For example as in the Delete class. Can you add setup flash messages to this classes?

And it would be great to update the README as it is outdated. For example the modelClass property in actions does not exists.

Thanks for great extension.

CrudController + findModel at the moment when behaviors are attaching

I want to pass model as roleParams item by accessRules() method to check permission. Each CrudController has findModel method via ModelControlBehavior. But it exists after the behavior attached. But accessRules is invoking before.

let me show code to better understand:

namespace app\modules\dashboard\controllers;

use app\controllers\CrudTrait;
use app\models\Transport;
use Yii;
use yii2tech\admin\CrudController;

/**
 * Class TransportController
 * @package app\modules\dashboard\controllers
 */
class TransportController extends CrudController
{
    use CrudTrait;
    /**
     * @var string
     */
    public $modelClass = 'app\models\Transport';
    /**
     * @var string
     */
    public $searchModelClass = 'app\modules\dashboard\models\TransportSearch';

    /**
     * {@inheritdoc}
     */
    public function accessRules()
    {
        $id = Yii::$app->request->get('id');
        $model = Transport::findOne($id); // i want $model = $this->findModel($id)

        return [
            [
                'allow' => true,
                'actions' => ['index'],
                'roles' => ['transporter'],
            ],
            [
                'allow' => true,
                'actions' => ['create'],
                'roles' => ['transportCreate'],
            ],
            [
                'allow' => true,
                'actions' => ['read'],
                'roles' => ['transportRead'],
                'roleParams' => ['model' => $model],
            ],
            [
                'allow' => true,
                'actions' => ['update'],
                'roles' => ['transportUpdate'],
                'roleParams' => ['model' => $model],
            ],
            [
                'allow' => true,
                'actions' => ['delete'],
                'roles' => ['transportDelete'],
                'roleParams' => ['model' => $model],
            ],
        ];
    }
}

The question is to get your advice how to do it clear. I don't want to make double $model = Transport::findOne($id) (i have to find or throw 404 exception, so to copy-past ModelControlBehavior::findModel ) Ofcourse i can implement my own method findModel in the controller but it would duplicate the behavior's code. What do you advice?

Extract `CrudController::accessRules()`

It is better to extract CrudController::accessRules() method, which should return rules for AccessControl filter.
In this way it will be much more easier to customize access rules for particualr admin section, instead of overriding entire behaviors() methods.

Enhance `Alert` widget to select type using wildcard match

At the present state Alert widget determines alert type (CSS class) using direct match of flash name:

[
        'error' => 'alert-danger',
        'danger' => 'alert-danger',
        'success' => 'alert-success',
        'info' => 'alert-info',
        'warning' => 'alert-warning'
    ]

Thus in case flash message named in non standard way, e.g. 'emailSendSuccess' or 'configUpdateError', they do not pickup any alert style.

Behavior should be changed allowing configuration via wildcards, e.g. 'Success', '*Error' and so on.

Upgrade code to PHP 5.6

There is no sense supporting PHP 5.4 or 5.5 anymore.
Requirements should be raised up to PHP 5.6 along with code adjustments.
This in particular allows removal of BaseObject::className() method usage in favor to native ::class construction.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.