Skip to content

Commit f4d2019

Browse files
committed
Backend. Список задач
1 parent 6330d8a commit f4d2019

4 files changed

Lines changed: 74 additions & 1 deletion

File tree

TodoModule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* ToDo module
44
*
5-
* @package yupe.modules.payler
5+
* @package yupe.modules.todo
66
* @author Oleg Filimonov <olegsabian@gmail.com>
77
* @license BSD http://ru.wikipedia.org/wiki/%D0%9B%D0%B8%D1%86%D0%B5%D0%BD%D0%B7%D0%B8%D1%8F_BSD
88
* @version 0.1
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
use yupe\components\controllers\BackController;
3+
4+
/**
5+
* Class TodoBackendController
6+
*/
7+
class TodoBackendController extends BackController
8+
{
9+
public function actionIndex()
10+
{
11+
$model = new Todo('search');
12+
$query = Yii::app()->getRequest()->getQuery('Todo');
13+
14+
$model->unsetAttributes();
15+
16+
if ($query) {
17+
$model->setAttributes($query);
18+
}
19+
20+
$this->render('index', ['model' => $model]);
21+
}
22+
}

models/Todo.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public function rules()
2828
['description', 'required'],
2929
['description', 'length', 'max' => 255],
3030
['status, sort', 'numerical', 'integerOnly' => true],
31+
['description, sort', 'safe', 'on' => 'search'],
3132
];
3233
}
3334

@@ -42,4 +43,22 @@ public function attributeLabels()
4243
'sort' => 'Сортировка',
4344
];
4445
}
46+
47+
/**
48+
* @return CActiveDataProvider
49+
*/
50+
public function search()
51+
{
52+
$criteria = new CDbCriteria;
53+
54+
$criteria->compare('description', $this->description, true);
55+
$criteria->compare('status', $this->status);
56+
57+
return new CActiveDataProvider(get_class($this), [
58+
'criteria' => $criteria,
59+
'sort' => [
60+
'defaultOrder' => 'sort'
61+
]
62+
]);
63+
}
4564
}

views/todoBackend/index.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* @var $this TodoBackendController
4+
* @var $model Todo
5+
*/
6+
7+
$this->pageTitle = 'ToDo - Список';
8+
9+
$this->breadcrumbs = [ $this->pageTitle ];
10+
11+
12+
?>
13+
<div class="page-header">
14+
<h1><?= $this->pageTitle ?></h1>
15+
</div>
16+
17+
<?php $this->widget('yupe\widgets\CustomGridView', [
18+
'id' => 'todo-grid',
19+
'type' => 'condensed',
20+
'dataProvider' => $model->search(),
21+
'filter' => $model,
22+
'columns' => [
23+
'id',
24+
'description',
25+
'status',
26+
[
27+
'class' => 'yupe\widgets\CustomButtonColumn',
28+
'template' => '{update} {delete}'
29+
],
30+
],
31+
]
32+
); ?>

0 commit comments

Comments
 (0)