Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Backend. Список задач
  • Loading branch information
sabian committed Dec 14, 2015
1 parent 6330d8a commit f4d2019
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 1 deletion.
2 changes: 1 addition & 1 deletion TodoModule.php
Expand Up @@ -2,7 +2,7 @@
/**
* ToDo module
*
* @package yupe.modules.payler
* @package yupe.modules.todo
* @author Oleg Filimonov <olegsabian@gmail.com>
* @license BSD http://ru.wikipedia.org/wiki/%D0%9B%D0%B8%D1%86%D0%B5%D0%BD%D0%B7%D0%B8%D1%8F_BSD
* @version 0.1
Expand Down
22 changes: 22 additions & 0 deletions controllers/TodoBackendController.php
@@ -0,0 +1,22 @@
<?php
use yupe\components\controllers\BackController;

/**
* Class TodoBackendController
*/
class TodoBackendController extends BackController
{
public function actionIndex()
{
$model = new Todo('search');
$query = Yii::app()->getRequest()->getQuery('Todo');

$model->unsetAttributes();

if ($query) {
$model->setAttributes($query);
}

$this->render('index', ['model' => $model]);
}
}
19 changes: 19 additions & 0 deletions models/Todo.php
Expand Up @@ -28,6 +28,7 @@ public function rules()
['description', 'required'],
['description', 'length', 'max' => 255],
['status, sort', 'numerical', 'integerOnly' => true],
['description, sort', 'safe', 'on' => 'search'],
];
}

Expand All @@ -42,4 +43,22 @@ public function attributeLabels()
'sort' => 'Сортировка',
];
}

/**
* @return CActiveDataProvider
*/
public function search()
{
$criteria = new CDbCriteria;

$criteria->compare('description', $this->description, true);
$criteria->compare('status', $this->status);

return new CActiveDataProvider(get_class($this), [
'criteria' => $criteria,
'sort' => [
'defaultOrder' => 'sort'
]
]);
}
}
32 changes: 32 additions & 0 deletions views/todoBackend/index.php
@@ -0,0 +1,32 @@
<?php
/**
* @var $this TodoBackendController
* @var $model Todo
*/

$this->pageTitle = 'ToDo - Список';

$this->breadcrumbs = [ $this->pageTitle ];


?>
<div class="page-header">
<h1><?= $this->pageTitle ?></h1>
</div>

<?php $this->widget('yupe\widgets\CustomGridView', [
'id' => 'todo-grid',
'type' => 'condensed',
'dataProvider' => $model->search(),
'filter' => $model,
'columns' => [
'id',
'description',
'status',
[
'class' => 'yupe\widgets\CustomButtonColumn',
'template' => '{update} {delete}'
],
],
]
); ?>

0 comments on commit f4d2019

Please sign in to comment.