-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
View/Actions redone with ModalButton widget
- Loading branch information
1 parent
e6ca06d
commit befcb6c
Showing
10 changed files
with
162 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,19 @@ | ||
<?php | ||
use yii\bootstrap\Modal; | ||
use hipanel\widgets\ModalButton; | ||
use yii\helpers\Html; | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
echo Html::a('<i class="fa fa-trash-o"></i>' . Yii::t('app', 'Delete'), '#', [ | ||
'data-toggle' => 'modal', | ||
'data-target' => "#modal_{$model->id}_delete", | ||
]); | ||
|
||
echo Html::beginForm(['delete'], "POST", ['data' => ['pjax' => 1, 'pjax-push' => 0], 'class' => 'inline']); | ||
echo Html::activeHiddenInput($model, 'id'); | ||
Modal::begin([ | ||
'id' => "modal_{$model->id}_delete", | ||
'toggleButton' => false, | ||
'header' => Html::tag('h4', Yii::t('app', 'Confirm server deleting')), | ||
'headerOptions' => ['class' => 'label-danger'], | ||
'footer' => Html::button(Yii::t('app', 'Delete server'), [ | ||
'class' => 'btn btn-danger', | ||
'data-loading-text' => Yii::t('app', 'Deleting server...'), | ||
'onClick' => new \yii\web\JsExpression(" | ||
$(this).closest('form').trigger('submit'); | ||
$(this).button('loading'); | ||
") | ||
]) | ||
]); | ||
echo Yii::t('app', 'Are you sure you want to delete server {name}? You will loose everything!', ['name' => $model->name]); | ||
Modal::end(); | ||
echo Html::endForm(); | ||
|
||
|
||
//$modal = ModalButton::widget([ | ||
// 'model' => $model, | ||
// // false - не делать форму | ||
// 'formOptions' => [ | ||
// 'action' => 'delete', | ||
// 'type' => 'POST', | ||
// ], | ||
// 'button' => [ // callback | ||
// 'tag' => 'a', | ||
// 'label' => 'DELETE', | ||
// ], | ||
// 'buttonPosition' => ModalButton::BUTTON_OUTSIDE, // BUTTON_INSIDE, BUTTON_IN_MODAL | ||
// 'body' => 'Text', | ||
// 'header' => Html::tag('h4', Yii::t('app', 'Confirm server deleting')), | ||
// 'footer' => Html::button(Yii::t('app', 'Delete server'), [ | ||
// 'class' => 'btn btn-danger', | ||
// 'data-loading-text' => Yii::t('app', 'Deleting server...'), | ||
// 'onClick' => new \yii\web\JsExpression(" | ||
// $(this).closest('form').trigger('submit'); | ||
// $(this).button('loading'); | ||
// "), | ||
// ]) | ||
//]); | ||
echo ModalButton::widget([ | ||
'model' => $model, | ||
'scenario' => 'delete', | ||
'button' => ['label' => '<i class="fa fa-trash-o"></i>' . Yii::t('app', 'Delete')], | ||
'body' => Yii::t('app', 'Are you sure you want to delete server {name}? You will loose everything!', ['name' => $model->name]), | ||
'modal' => [ | ||
'header' => Html::tag('h4', Yii::t('app', 'Confirm server deleting')), | ||
'headerOptions' => ['class' => 'label-danger'], | ||
'footer' => [ | ||
'label' => Yii::t('app', 'Delete server'), | ||
'data-loading-text' => Yii::t('app', 'Deleting server...'), | ||
'class' => 'btn btn-danger', | ||
] | ||
] | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,31 @@ | ||
<?php | ||
use yii\bootstrap\Modal; | ||
use hipanel\widgets\ModalButton; | ||
use yii\helpers\Html; | ||
|
||
echo Html::beginForm(['power-off'], "POST", ['data' => ['pjax' => 1], 'class' => 'inline']); | ||
echo Html::hiddenInput('id', $model->id); | ||
Modal::begin([ | ||
'toggleButton' => [ | ||
ModalButton::begin([ | ||
'model' => $model, | ||
'scenario' => 'power-off', | ||
'button' => [ | ||
'label' => Yii::t('app', 'Power off'), | ||
'class' => 'btn btn-default', | ||
'disabled' => !$model->isOperable(), | ||
], | ||
'header' => Html::tag('h4', Yii::t('app', 'Confirm server power off')), | ||
'headerOptions' => ['class' => 'label-warning'], | ||
'footer' => Html::button(Yii::t('app', 'Power OFF'), [ | ||
'class' => 'btn btn-warning', | ||
'data-loading-text' => Yii::t('app', 'Turning power OFF...'), | ||
'onClick' => new \yii\web\JsExpression("$(this).closest('form').submit(); $(this).button('loading')") | ||
]) | ||
'modal' => [ | ||
'header' => Html::tag('h4', Yii::t('app', 'Confirm server power off')), | ||
'headerOptions' => ['class' => 'label-warning'], | ||
'footer' => [ | ||
'label' => Yii::t('app', 'Power OFF'), | ||
'data-loading-text' => Yii::t('app', 'Turning power OFF...'), | ||
'class' => 'btn btn-warning', | ||
] | ||
] | ||
]); | ||
?> | ||
<div class="callout callout-warning"> | ||
<h4><?= Yii::t('app', 'This may cause data loose!') ?></h4> | ||
|
||
<p><?= Yii::t('app', | ||
'Power off will immediately interrupt all processes on the server in a dangerous way. Always try to shoudown it, before turning off the power. Are you sure you want to power off the server?') ?></p> | ||
'Power off will immediately interrupt all processes on the server in a dangerous way. Always try to shutdown it, before turning off the power. Are you sure you want to power off the server?') ?></p> | ||
</div> | ||
<?php Modal::end(); | ||
echo Html::endForm(); | ||
|
||
<?php ModalButton::end(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
<?php | ||
use yii\bootstrap\Modal; | ||
use hipanel\widgets\ModalButton; | ||
use yii\helpers\Html; | ||
|
||
echo Html::beginForm(['power-on'], "POST", ['data' => ['pjax' => 1], 'class' => 'inline']); | ||
echo Html::hiddenInput('id', $model->id); | ||
Modal::begin([ | ||
'toggleButton' => [ | ||
echo ModalButton::widget([ | ||
'model' => $model, | ||
'scenario' => 'power-on', | ||
'button' => [ | ||
'label' => Yii::t('app', 'Power on'), | ||
'class' => 'btn btn-default', | ||
'disabled' => !$model->isOperable(), | ||
], | ||
'header' => Html::tag('h4', Yii::t('app', 'Confirm server power ON')), | ||
'footer' => Html::button(Yii::t('app', 'Power ON'), [ | ||
'class' => 'btn btn-info', | ||
'data-loading-text' => Yii::t('app', 'Turning power ON...'), | ||
'onClick' => new \yii\web\JsExpression("$(this).closest('form').submit(); $(this).button('loading')") | ||
]) | ||
]); | ||
echo Yii::t('app', 'Turn ON server power?'); | ||
Modal::end(); | ||
echo Html::endForm(); | ||
'body' => Yii::t('app', 'Turn ON server power?'), | ||
'modal' => [ | ||
'header' => Html::tag('h4', Yii::t('app', 'Confirm server power ON')), | ||
'headerOptions' => ['class' => 'label-info'], | ||
'footer' => [ | ||
'label' => Yii::t('app', 'Power ON'), | ||
'data-loading-text' => Yii::t('app', 'Turning power ON...'), | ||
'class' => 'btn btn-info', | ||
] | ||
] | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,30 @@ | ||
<?php | ||
use yii\bootstrap\Modal; | ||
use hipanel\widgets\ModalButton; | ||
use yii\helpers\Html; | ||
|
||
echo Html::beginForm(['reboot'], "POST", ['data' => ['pjax' => 1], 'class' => 'inline']); | ||
echo Html::hiddenInput('id', $model->id); | ||
Modal::begin([ | ||
'toggleButton' => [ | ||
ModalButton::begin([ | ||
'model' => $model, | ||
'scenario' => 'reboot', | ||
'button' => [ | ||
'label' => Yii::t('app', 'Reboot'), | ||
'class' => 'btn btn-default', | ||
'disabled' => !$model->isOperable(), | ||
], | ||
'header' => Html::tag('h4', Yii::t('app', 'Confirm server reboot')), | ||
'headerOptions' => ['class' => 'label-warning'], | ||
'footer' => Html::button(Yii::t('app', 'Reboot'), [ | ||
'class' => 'btn btn-warning', | ||
'data-loading-text' => Yii::t('app', 'Rebooting...'), | ||
'onClick' => new \yii\web\JsExpression("$(this).closest('form').submit();") | ||
]) | ||
'modal' => [ | ||
'header' => Html::tag('h4', Yii::t('app', 'Confirm server reboot')), | ||
'headerOptions' => ['class' => 'label-warning'], | ||
'footer' => [ | ||
'label' => Yii::t('app', 'Reboot'), | ||
'data-loading-text' => Yii::t('app', 'Rebooting...'), | ||
'class' => 'btn btn-warning', | ||
] | ||
] | ||
]); | ||
?> | ||
<div class="callout callout-warning"> | ||
<h4><?= Yii::t('app', 'This may cause data loose!') ?></h4> | ||
|
||
<p><?= Yii::t('app', 'Reboot will interrupt all processes on the server. Are you sure you want to reset the server?') ?></p> | ||
</div> | ||
<?php Modal::end(); | ||
echo Html::endForm(); | ||
|
||
<?php ModalButton::end(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,22 @@ | ||
<?php | ||
use yii\bootstrap\Modal; | ||
use yii\helpers\Html; | ||
use hipanel\widgets\ModalButton; | ||
|
||
echo Html::a('<i class="fa fa-refresh"></i>' . Yii::t('app', 'Reset root password'), '#', [ | ||
'data-toggle' => 'modal', | ||
'data-target' => "#modal_{$model->id}_reset-password", | ||
echo ModalButton::widget([ | ||
'model' => $model, | ||
'scenario' => 'reset-password', | ||
'button' => ['label' => '<i class="fa fa-refresh"></i>' . Yii::t('app', 'Reset root password')], | ||
'body' => Yii::t('app', | ||
'Are you sure you want to reset the root password on {name} server? You will get your new root password on the e-mail.', | ||
['name' => $model->name]), | ||
'modal' => [ | ||
'header' => Html::tag('h4', Yii::t('app', 'Confirm root password resetting')), | ||
'headerOptions' => ['class' => 'label-danger'], | ||
'footer' => [ | ||
'label' => Yii::t('app', 'Reset root password'), | ||
'data-loading-text' => Yii::t('app', 'Resetting...'), | ||
'class' => 'btn btn-danger', | ||
] | ||
] | ||
]); | ||
|
||
echo Html::beginForm(['reset-password'], "POST", ['data' => ['pjax' => 1, 'pjax-push' => 0], 'class' => 'inline']); | ||
echo Html::activeHiddenInput($model, 'id'); | ||
Modal::begin([ | ||
'id' => "modal_{$model->id}_reset-password", | ||
'toggleButton' => false, | ||
'header' => Html::tag('h4', Yii::t('app', 'Confirm root password resetting')), | ||
'headerOptions' => ['class' => 'label-warning'], | ||
'footer' => Html::button(Yii::t('app', 'Reset root password'), [ | ||
'class' => 'btn btn-warning', | ||
'data-loading-text' => Yii::t('app', 'Resetting...'), | ||
'onClick' => new \yii\web\JsExpression(" | ||
$(this).closest('form').trigger('submit'); | ||
$(this).button('loading'); | ||
") | ||
]) | ||
]); | ||
echo Yii::t('app', 'Are you sure you want to reset the root password on {name} server? You will get your new root password on the e-mail.', | ||
['name' => $model->name]); | ||
Modal::end(); | ||
echo Html::endForm(); |
Oops, something went wrong.