@@ -42,22 +42,22 @@
]);
print $form->field($model, "[$i]vhost_id")->widget(VhostCombo::className(), ['formElementSelector' => '.form-instance']);
- print Html::label(Yii::t('app', 'Domain')
- . '
' . Html::radio("[$i]vhost_type", true, [
+ $model->alias_type = 'subdomain';
+ print $form->field($model, "[$i]alias_type")->radio([
'value' => 'subdomain',
- 'class' => 'vhost-type',
- 'label' => Yii::t('app', 'Subdomain of existing domain')
- ])
- . '
' . Html::radio("[$i]vhost_type", false, [
+ 'class' => 'alias-type',
+ 'label' => Yii::t('app', 'Subdomain of existing domain'),
+ ]);
+ print $form->field($model, "[$i]alias_type")->radio([
+ 'id' => $model->formName() . '-' . $i . '-alias_type-new',
'value' => 'new',
- 'class' => 'vhost-type',
+ 'class' => 'alias-type',
'label' => Yii::t('app', 'New domain')
- ])
- );
+ ]);
?>
-
- = $form->field($model, "[$i]sub")->input('text', ['data-field' => 'sub'])->label(false) ?>
+
+ = $form->field($model, "[$i]subdomain")->input('text', ['data-field' => 'subdomain'])->label(false) ?>
= Html::tag('span', '.') ?>
= $form->field($model, "[$i]dns_hdomain_id")->widget(HdomainCombo::className(), [
'formElementSelector' => '.form-instance',
@@ -71,10 +71,17 @@
")
]
])->label(false) ?>
- = $form->field($model, "[$i]domain")->hiddenInput(['data-field' => 'sub-with-domain'])->label(false) ?>
+ = $form->field($model, "[$i]domain")->hiddenInput([
+ 'id' => $model->formName() . '-' . $i . '-domain-sub',
+ 'data-field' => 'sub-with-domain'
+ ])->label(false) ?>
-
- = $form->field($model, "[$i]domain")->input('text', ['data-field' => 'domain', 'disabled' => true, 'class' => 'form-control collapse'])->label(false) ?>
+
+ = $form->field($model, "[$i]domain")->input('text', [
+ 'data-field' => 'domain',
+ 'disabled' => true,
+ 'class' => 'form-control collapse'
+ ])->label(false) ?>
= $form->field($model, "[$i]with_www")->checkbox() ?>
@@ -90,11 +97,11 @@
registerJs(<<<'JS'
- $(this).on('change', '.vhost-type', function (e) {
+ $(this).on('change', '.alias-type', function (e) {
var $form = $(this).closest('.form-instance');
- var $sub_inputs = $form.find('.vhost-subdomain, input[data-field="sub"], input[data-field="sub-with-domain"]');
- var $new_inputs = $form.find('.vhost-newdomain, input[data-field="domain"]');
+ var $sub_inputs = $form.find('.alias-subdomain, input[data-field="subdomain"], input[data-field="sub-with-domain"]');
+ var $new_inputs = $form.find('.alias-newdomain, input[data-field="domain"]');
if ($(this).attr('value') == 'subdomain') {
$sub_inputs.show().prop('disabled', false);
@@ -107,17 +114,17 @@
$('#dynamic-form').on('update', 'input[data-field="sub-with-domain"]', function (event) {
var $form = $(this).closest('.form-instance');
- var sub = $form.find('input[data-field="sub"]').val();
+ var subdomain = $form.find('input[data-field="subdomain"]').val();
var domain = $form.find('input[data-field="dns_hdomain_id"]').select2('data');
var value = '';
if (domain && domain.text) {
- value = sub + '.' + domain.text;
+ value = (subdomain.length > 0 ? (subdomain + '.') : '') + domain.text;
}
$(this).val(value).trigger('change');
});
- $('#dynamic-form').on('change', 'input[data-field="sub"]', function () {
+ $('#dynamic-form').on('change', 'input[data-field="subdomain"]', function () {
var $form = $(this).closest('.form-instance');
$form.find('input[data-field="sub-with-domain"]').trigger('update');
});
diff --git a/src/views/hdomain/view.php b/src/views/hdomain/view.php
index a2c76cf9..a1da953e 100644
--- a/src/views/hdomain/view.php
+++ b/src/views/hdomain/view.php
@@ -1,9 +1,11 @@
title = $model->domain;
$this->subtitle = Yii::t('app', 'hosting domain detailed information') . ' #' . $model->id;
@@ -35,34 +37,26 @@
@@ -90,7 +84,51 @@
'ip',
'state',
'dns_on',
- 'aliases',
+ [
+ 'attribute' => 'aliases',
+ 'format' => 'raw',
+ 'value' => function ($model) {
+ $html = [];
+ foreach ((array)$model->getAttribute('aliases') as $id => $alias) {
+ $aliasModel = Yii::createObject([
+ 'class' => Hdomain::className(),
+ 'id' => $id,
+ 'domain' => $alias
+ ]);
+ $item = Html::a($aliasModel->domain, ['view', 'id' => $aliasModel->id]) . ' ';
+ $item .= ModalButton::widget([
+ 'model' => $aliasModel,
+ 'scenario' => 'delete-alias',
+ 'submit' => ModalButton::SUBMIT_AJAX,
+ 'button' => [
+ 'label' => '
',
+ ],
+ 'modal' => [
+ 'header' => Html::tag('h4', Yii::t('app', 'Confirm alias deleting')),
+ 'headerOptions' => ['class' => 'label-info'],
+ 'footer' => [
+ 'label' => Yii::t('app', 'Delete alias'),
+ 'data-loading-text' => Yii::t('app', 'Deleting alias...'),
+ 'class' => 'btn btn-danger',
+ ]
+ ],
+ 'body' => Yii::t('app',
+ 'Are you sure, that you want to delete alias {name}?',
+ ['name' => $aliasModel->domain]
+ ),
+ 'ajaxOptions' => [
+ 'success' => new JsExpression("
+ function (data) {
+ form.closest('.alias-item').remove();
+ }
+ ")
+ ]
+ ]);
+ $html[] = Html::tag('div', $item, ['class' => 'alias-item']);
+ }
+ return implode("\n", $html);
+ }
+ ]
],
]);
$box->endBody();