[enh] Allow only 1 DynDns domain (so don't show a useless form).

This commit is contained in:
opi 2014-12-01 19:06:09 +01:00
parent 8c0b211851
commit d0c4230e24
2 changed files with 25 additions and 2 deletions

View file

@ -348,6 +348,13 @@ app = Sammy('#main', function (sam) {
* Filters * Filters
* *
*/ */
sam.before(/domains\/add/, function (req){
// Preload domains list.
req.params.domains = [];
req.api('/domains', function(data) {
req.params.domains = data.domains;
});
});
sam.before(/apps\/install\//, function (req){ sam.before(/apps\/install\//, function (req){
// Preload domains list. // Preload domains list.
req.params.domains = []; req.params.domains = [];
@ -857,7 +864,21 @@ app = Sammy('#main', function (sam) {
c.params.ddomains = ['.nohost.me', '.noho.st']; c.params.ddomains = ['.nohost.me', '.noho.st'];
}) })
.always(function() { .always(function() {
c.view('domain/domain_add', c.params); data = {
ddomains : c.params.ddomains,
domains : c.params.domains,
allowDyndnsDomain : true
}
// Allow only 1 DynDns domain.
var regex = data.ddomains.join('|')
$.each(data.domains, function(k, domain) {
if ( domain.search(regex) > 0 ) {
data.allowDyndnsDomain = false;
}
});
c.view('domain/domain_add', data);
}); });
}); });

View file

@ -17,7 +17,7 @@
</a> </a>
</h4> </h4>
</div> </div>
<div id="collapseOne" class="panel-collapse collapse"> <div id="collapseOne" class="panel-collapse {{#if allowDyndnsDomain }}collapse{{/if}}">
<div class="panel-body"> <div class="panel-body">
<small>{{t 'domain_add_dns_doc'}}</small> <small>{{t 'domain_add_dns_doc'}}</small>
<hr> <hr>
@ -30,6 +30,7 @@
</div> </div>
</div> </div>
</div> </div>
{{#if allowDyndnsDomain }}
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<h4 class="panel-title"> <h4 class="panel-title">
@ -59,6 +60,7 @@
</div> </div>
</div> </div>
</div> </div>
{{/if}}
</div> </div>
<div class="br"></div> <div class="br"></div>