public static function defaultColumns() { return ['id' => ['format' => 'html', 'attribute' => 'id', 'value' => function ($model) { return Html::tag('span', $model->id, ['class' => 'bold']); }], 'object_id' => ['class' => MainColumn::class, 'filterAttribute' => 'id', 'attribute' => 'object_id'], 'backup' => ['class' => MainColumn::class, 'filterAttribute' => 'backup_like'], 'server' => ['class' => ServerColumn::class], 'account' => ['class' => AccountColumn::class], 'object' => ['format' => 'raw', 'attribute' => 'name', 'filterAttribute' => 'name_like', 'value' => function ($model) { $labelType = ObjectLabelWidget::widget(compact('model')); return $labelType . ' ' . Html::a($model->name, ["@{$model->object}/view", 'id' => $model->object_id], ['data-pjax' => 0]); }], 'name' => ['format' => 'raw', 'attribute' => 'name', 'value' => function ($model) { return Html::a($model->name, ["@{$model->object}/view", 'id' => $model->object_id], ['data-pjax' => 0]); }], 'size' => ['filter' => false, 'value' => function ($model) { return Yii::$app->formatter->asShortSize($model->size, 2); }], 'time' => ['filter' => false, 'value' => function ($model) { return Yii::$app->formatter->asDatetime($model->time); }], 'actions' => ['class' => ActionColumn::class, 'template' => '{view} {delete}'], 'inner_actions' => ['class' => ActionColumn::class, 'template' => '{deleteBackup}', 'buttons' => ['deleteBackup' => function ($url, $model, $key) { return Html::a('<i class="fa fa-trash-o"></i> ' . Yii::t('hipanel', 'Delete'), ['/hosting/backup/delete', 'id' => $model->id], ['aria-label' => Yii::t('hipanel', 'Delete'), 'class' => 'btn btn-danger btn-xs', 'data' => ['confirm' => Yii::t('hipanel', 'Are you sure you want to delete this item?'), 'method' => 'POST', 'data-pjax' => '0']]); }]]]; }
public static function defaultColumns() { $typeOptions = self::$typeOptions; return ['name' => ['class' => MainColumn::class, 'filterAttribute' => 'name_like', 'format' => 'html', 'value' => function ($model) { return Html::a($model->name, ['@' . $model->object . '/view', 'id' => $model->id], ['class' => 'bold']); }], 'main' => ['attribute' => 'name', 'filterAttribute' => 'name_like', 'format' => 'raw', 'value' => function ($model) { return Html::a($model->name, ['@backuping/view', 'id' => $model->id], ['class' => 'bold']) . ' ' . Html::a(ObjectLabelWidget::widget(compact('model')), ['@' . $model->object . '/view', 'id' => $model->id]); }], 'account' => ['attribute' => 'account_id', 'class' => AccountColumn::class], 'server' => ['attribute' => 'server_id', 'class' => ServerColumn::class], 'object' => ['filter' => false, 'format' => 'raw', 'value' => function ($model) { return ObjectLabelWidget::widget(compact('model')); }], 'backup_count' => ['filter' => false], 'type' => ['attribute' => 'type', 'format' => 'raw', 'filter' => false, 'enableSorting' => false, 'value' => function ($model) use($typeOptions) { return XEditable::widget(['model' => $model, 'attribute' => 'type', 'pluginOptions' => ['type' => 'select', 'source' => $typeOptions, 'url' => Url::to('update')]]); }], 'state_label' => ['filter' => false, 'enableSorting' => false], 'backup_last' => ['filter' => false, 'format' => 'raw', 'value' => function ($model) { return Html::tag('nobr', Yii::$app->formatter->asDate($model->backup_last)) . ' ' . Html::tag('nobr', Yii::$app->formatter->asTime($model->backup_last)); }], 'total_du' => ['filter' => false, 'format' => 'html', 'value' => function ($model) { return Yii::$app->formatter->asShortSize($model->total_du, 2); }]]; }