Permalink
Browse files

Изменение статусов

  • Loading branch information...
sabian committed Jan 16, 2016
1 parent 2157ef2 commit 3f4478ab1e79f704ec59f9316573a0fb8eed1745
@@ -17,6 +17,19 @@ public function filters()
);
}
public function actions()
{
return [
'inline' => [
'class' => 'yupe\components\actions\YInLineEditAction',
'model' => 'Todo',
'validAttributes' => [
'status',
]
],
];
}
public function actionIndex()
{
$model = new Todo('search');
@@ -0,0 +1,51 @@
<?php
class TodoStatusHelper
{
const STATUS_CANCELLED = 0;
const STATUS_DEFAULT = 1;
const STATUS_URGENT = 2;
const STATUS_DONE = 3;
/**
* Return a list of statuses
*
* @return array
*/
public static function getList()
{
return [
self::STATUS_CANCELLED => 'Отменена',
self::STATUS_DEFAULT => 'Обычная',
self::STATUS_URGENT => 'Срочная',
self::STATUS_DONE => 'Выполнена',
];
}
/**
* Get css class names list
*
* @return array
*/
public static function getStylesList()
{
return [
self::STATUS_CANCELLED => ['class' => 'label-danger'],
self::STATUS_DEFAULT => ['class' => 'label-default'],
self::STATUS_URGENT => ['class' => 'label-primary'],
self::STATUS_DONE => ['class' => 'label-success'],
];
}
/**
* Get status label by id
*
* @param int $id
* @return string
*/
public static function getLabel($id)
{
$list = self::getList();
return $list[$id];
}
}
@@ -3,4 +3,7 @@
'module' => [
'class' => 'application.modules.todo.TodoModule',
],
'import' => [
'application.modules.todo.helpers.*',
],
];
@@ -16,9 +16,16 @@
<?= $form->errorSummary($model); ?>
<div class="row">
<div class="col-sm-12">
<div class="col-sm-8">
<?= $form->textFieldGroup($model, 'description'); ?>
</div>
<div class="col-sm-4">
<?= $form->dropDownListGroup($model, 'status', [
'widgetOptions' => [
'data' => TodoStatusHelper::getList(),
],
]); ?>
</div>
</div>
<?php $this->widget('bootstrap.widgets.TbButton', [
@@ -25,7 +25,18 @@
'columns' => [
'id',
'description',
'status',
[
'name' => 'status',
'class' => 'yupe\widgets\EditableStatusColumn',
'url' => $this->createUrl('/todo/todoBackend/inline'),
'source' => TodoStatusHelper::getList(),
'options' => TodoStatusHelper::getStylesList(),
'filter' => CHtml::activeDropDownList($model, 'status', TodoStatusHelper::getList(), [
'encode' => false,
'empty' => '',
'class' => 'form-control',
]),
],
[
'class' => 'yupe\widgets\CustomButtonColumn',
'template' => '{update} {delete}'

0 comments on commit 3f4478a

Please sign in to comment.