Skip to content

Commit

Permalink
Add DomainRegistrationProduct, add validation to DomainCheck
Browse files Browse the repository at this point in the history
  • Loading branch information
tafid committed Nov 4, 2015
1 parent 57a44d3 commit bc15164
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/controllers/DomainController.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public function actionCheckDomain()
->andFilterWhere(['type' => 'domain'])
->andFilterWhere(['seller' => 'ahnames'])
->one();
$zones = array_filter($tariffs->resources, function($resource) {
$zones = array_filter($tariffs->resources ? : [], function($resource) {
return ($resource->zone != null && $resource->type == Resource::TYPE_DOMAIN_REGISTRATION);
});
$dropDownZones = [];
Expand Down
1 change: 1 addition & 0 deletions src/models/Domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function rules () {

// Check domain
[['domain'], DomainPartValidator::className(), 'on' => ['check-domain']],
[['domain', 'zone'], 'required', 'on' => ['check-domain']],
[['zone'], 'safe', 'on' => ['check-domain']],
[['zone'], 'trim', 'on' => ['check-domain']],
[['is_available'], 'boolean', 'on' => ['check-domain']],
Expand Down
11 changes: 11 additions & 0 deletions src/models/DomainProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace hipanel\modules\domain\models;

use hipanel\models\CartPosition;
use Yii;

class DomainProduct extends CartPosition
{
Expand All @@ -12,4 +13,14 @@ class DomainProduct extends CartPosition
public $model;

public $icon = '<i class="fa fa-globe"></i>'; //'<i class="fa fa-server text-muted"></i>';

public function getQuantityOptions()
{
$result = [];
foreach ([1,2,3,4,5,6,7,8,9,10] as $n) {
$result[$n] = Yii::t('app', '{0, plural, one{# year} other{# years}}', $n);
}

return $result;
}
}
2 changes: 2 additions & 0 deletions src/models/DomainRegistrationProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

class DomainRegistrationProduct extends DomainProduct
{
protected $_operation = 'registration';

public function getId()
{
return implode('_', ['domain', 'registration', $this->name]);
Expand Down
10 changes: 0 additions & 10 deletions src/models/DomainRenewalProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,4 @@ public function getId()
{
return implode('_', ['domain', 'renewal', $this->_model->id]);
}

public function getQuantityOptions()
{
$result = [];
foreach ([1,2,3,4,5,6,7,8,9,10] as $n) {
$result[$n] = Yii::t('app', '{0, plural, one{# year} other{# years}}', $n);
}

return $result;
}
}
28 changes: 14 additions & 14 deletions src/views/domain/checkDomain.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,20 @@ function Plugin(element, options) {
};
})(jQuery, window, document);
jQuery(document).on('pjax:complete', function() {
$('.domainsCheck').domainsCheck({
domainRowClass: '.check-item',
success: function(data, domain, element) {
console.log('123');
var $elem = $(element).find("tr[data-domain='" + domain + "']");
$elem.html(data);
return this;
},
finally: function() {
console.log('finally');
}
});
});
//jQuery(document).on('pjax:complete', function() {
// $('.domainsCheck').domainsCheck({
// domainRowClass: '.check-item',
// success: function(data, domain, element) {
// console.log('123');
// var $elem = $(element).find("tr[data-domain='" + domain + "']");
// $elem.html(data);
// return this;
// },
// finally: function() {
// console.log('finally');
// }
// });
//});
JS
);
?>
Expand Down

0 comments on commit bc15164

Please sign in to comment.