Skip to content

Commit

Permalink
Refactor to new ActionBox
Browse files Browse the repository at this point in the history
  • Loading branch information
tafid committed Aug 4, 2015
1 parent 024ee18 commit 7c7ed71
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 64 deletions.
48 changes: 19 additions & 29 deletions src/views/server/_search.php
Original file line number Diff line number Diff line change
@@ -1,38 +1,28 @@
<?php

use hipanel\modules\client\widgets\combo\ClientCombo;
use hipanel\widgets\AdvancedSearch;
use hiqdev\combo\StaticCombo;
use kartik\widgets\DatePicker;
use yii\helpers\Html;

?>
<div class="col-md-4">
<?= $search->field('name_like') ?>
<?= $search->field('note') ?>
</div>

<?php $form = AdvancedSearch::begin(compact('model')) ?>
<div class="col-md-4">
<?= $form->field('name_like') ?>
<?= $form->field('note') ?>
</div>

<div class="col-md-4">
<?= $form->field('client_id')->widget(ClientCombo::classname()) ?>
<?= $form->field('seller_id')->widget(ClientCombo::classname()) ?>
</div>

<div class="col-md-4">
<?= $form->field('state')->widget(StaticCombo::classname(), [
'data' => $state_data,
'hasId' => true,
'pluginOptions' => [
'select2Options' => [
'multiple' => true,
]
],
]) ?>
</div>

<div class="col-md-12">
<?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?>
</div>
<div class="col-md-4">
<?= $search->field('client_id')->widget(ClientCombo::classname()) ?>
<?= $search->field('seller_id')->widget(ClientCombo::classname()) ?>
</div>

<?php $form::end() ?>
<div class="col-md-4">
<?= $search->field('state')->widget(StaticCombo::classname(), [
'data' => $states,
'hasId' => true,
'pluginOptions' => [
'select2Options' => [
'multiple' => true,
]
],
]) ?>
</div>
63 changes: 28 additions & 35 deletions src/views/server/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
/**
* @var View $this
*/

$this->title = Yii::t('app', 'Servers');
$this->subtitle = Yii::t('app', Yii::$app->request->queryParams ? 'filtered list' : 'full list');
$this->breadcrumbs->setItems([
Expand All @@ -29,7 +28,7 @@

<?php $box = ActionBox::begin(['model' => $model, 'bulk' => true, 'options' => ['class' => 'box-info']]) ?>
<?php $box->beginActions() ?>
<?= Html::a(Yii::t('app', 'Advanced search'), '#', ['class' => 'btn btn-info search-button']) ?>
<?= $box->renderSearchButton() ?>
<?= LinkSorter::widget([
'show' => true,
'sort' => $dataProvider->getSort(),
Expand All @@ -40,43 +39,37 @@
]) ?>
<?php $box->endActions() ?>

<?php $box->beginBulkActions() ?>
<?= BulkButtons::widget([
'model' => Yii::$app->controller->newModel(),
'items' => [
ButtonDropdown::widget([
'label' => Yii::t('app', 'Lock'),
'dropdown' => [
'options' => ['class' => 'pull-right'],
'items' => [
[
'label' => Yii::t('app', 'Enable lock'),
'url' => '#',
'linkOptions' => [
'class' => 'bulk-action',
'data-attribute' => 'is_secured',
'data-value' => '1',
'data-url' => 'set-lock'
]
],
[
'label' => Yii::t('app', 'Disable lock'),
'url' => '#',
'linkOptions' => [
'class' => 'bulk-action',
'data-attribute' => 'is_secured',
'data-value' => '0',
'data-url' => 'set-lock'
]
<?php $box->renderBulkActions([
'items' => ButtonDropdown::widget([
'label' => Yii::t('app', 'Lock'),
'dropdown' => [
'options' => ['class' => 'pull-right'],
'items' => [
[
'label' => Yii::t('app', 'Enable lock'),
'url' => '#',
'linkOptions' => [
'class' => 'bulk-action',
'data-attribute' => 'is_secured',
'data-value' => '1',
'data-url' => 'set-lock'
]
],
[
'label' => Yii::t('app', 'Disable lock'),
'url' => '#',
'linkOptions' => [
'class' => 'bulk-action',
'data-attribute' => 'is_secured',
'data-value' => '0',
'data-url' => 'set-lock'
]
]
]
]),
],
]
]),
]) ?>

<?php $box->endBulkActions() ?>
<?= $this->render('_search', compact('model')) ?>
<?= $box->renderSearchForm(compact('states')) ?>
<?php $box::end() ?>

<?= ServerGridView::widget([
Expand Down

0 comments on commit 7c7ed71

Please sign in to comment.