Skip to content

Commit

Permalink
nt-script: only clear input fields when RR type
Browse files Browse the repository at this point in the history
changes.
  • Loading branch information
Matt Simerson committed Feb 7, 2014
1 parent 768df73 commit a7bc4f7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
13 changes: 11 additions & 2 deletions client/htdocs/nt-script.js
Expand Up @@ -9,10 +9,20 @@ function changeNewZoneName() {
mailAddr.val('hostmaster.'+zoneName.val() + '.');
};

function changeRRType(rrType) {
if (!rrType) return false;

var rrOptions = [ 'weight', 'priority', 'other' ];
for ( var i=0; i < rrOptions.length; i++ ) {
$('input#' +rrOptions[i]).val('');
}

selectedRRType(rrType);
}

function selectedRRType(rrType) {

if (!rrType) return false;

resetZoneRecordFormFields();

switch (rrType) {
Expand Down Expand Up @@ -43,7 +53,6 @@ function resetZoneRecordFormFields() {
for ( var i=0; i < rrOptions.length; i++ ) {
$('tr#' + rrOptions[i] ).hide(); // hide conditional rows
$('select#'+rrOptions[i]).hide().empty(); // hide and empty option lists
$('input#' +rrOptions[i]).val('');
};

var rrAll = $.merge(rrOptions, ['name','address','description']);
Expand Down
8 changes: 4 additions & 4 deletions client/htdocs/zone.cgi
Expand Up @@ -1043,7 +1043,7 @@ sub _build_rr_type {
-values => $type_values,
-labels => $type_labels,
-default => $zone_record->{'type'} || $default_record_type,
-onChange => "selectedRRType(value);",
-onChange => "changeRRType(value);",
-required => 'required',
) );
$q->autoEscape(1);
Expand Down Expand Up @@ -1106,7 +1106,7 @@ sub _build_rr_weight {
-default => $zone_record->{'weight'},
-onChange => q[$('select#weight').val(this.value);],
)
. q[<select id=weight class='hidden' onChange="if (this.value.length) $('input#weight').val(this.value);"></select>
. q[<select id=weight class='hidden' onChange="$('input#weight').val(this.value);"></select>
];
};

Expand All @@ -1122,7 +1122,7 @@ sub _build_rr_priority {
-default => $zone_record->{'priority'},
-onChange => q[$('select#priority').val(this.value);],
)
. q[<select id=priority class='hidden' onChange="if (this.value.length) $('input#priority').val(this.value);"></select>
. q[<select id=priority class='hidden' onChange="$('input#priority').val(this.value);"></select>
];
};

Expand All @@ -1138,7 +1138,7 @@ sub _build_rr_other {
-default => $zone_record->{'other'},
-onChange => q[$('select#other').val(this.value);],
)
. q[<select id=other class='hidden' onChange="if (this.value.length) $('input#other').val(this.value);"></select>
. q[<select id=other class='hidden' onChange="$('input#other').val(this.value);"></select>
];
};

Expand Down

0 comments on commit a7bc4f7

Please sign in to comment.