2
0
mirror of https://github.com/VinylDNS/vinyldns synced 2025-08-22 10:10:12 +00:00

Wait for zone and record set promises in portal before displaying record sets (#359)

* Add wait for promise.

* Replace event.preventDefault with button type in HTML since buttons default to submit type.
This commit is contained in:
Michael Ly 2018-11-30 12:03:36 -05:00 committed by GitHub
parent 6047b0a904
commit 26e8a77e46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 21 deletions

View File

@ -150,16 +150,16 @@
{{batchError}}
</p>
</td>
<td><button class="btn btn-danger batch-change-delete" ng-click="deleteSingleChange($index)">Delete</button></td>
<td><button type="button" class="btn btn-danger batch-change-delete" ng-click="deleteSingleChange($index)">Delete</button></td>
</tr>
</tbody>
</table>
<button id="addChange" class="btn btn-default" ng-click="addSingleChange()" ng-disabled="newBatch.changes.length == batchChangeLimit"><span class="fa fa-plus"></span> Add a Change</button>
<button type="button" id="addChange" class="btn btn-default" ng-click="addSingleChange()" ng-disabled="newBatch.changes.length == batchChangeLimit"><span class="fa fa-plus"></span> Add a Change</button>
<span ng-if="newBatch.changes.length == batchChangeLimit">Limit reached. Cannot add more than {{batchChangeLimit}} records per batch change.</span>
</div>
<div class="panel-footer clearfix">
<div ng-if="formStatus=='pendingSubmit'" class="pull-right">
<button id="create-batch-changes-button" class="btn btn-primary" ng-click="submitChange()">Submit</button>
<button type="button" id="create-batch-changes-button" class="btn btn-primary" ng-click="submitChange()">Submit</button>
</div>
<div ng-if="formStatus=='pendingConfirm'" class="pull-right">
<span>Are you sure you want to submit this batch change request?</span>

View File

@ -28,7 +28,6 @@
$scope.formStatus = "pendingSubmit";
$scope.addSingleChange = function() {
event.preventDefault();
$scope.newBatch.changes.push({changeType: "Add", type: "A", ttl: 200});
var changesLength =$scope.newBatch.changes.length;
$timeout(function() {document.getElementsByClassName("changeType")[changesLength - 1].focus()});
@ -75,13 +74,11 @@
};
$scope.deleteSingleChange = function(changeNumber) {
event.preventDefault();
$('.batch-change-delete').blur();
$scope.newBatch.changes.splice(changeNumber, 1);
};
$scope.submitChange = function() {
event.preventDefault();
$scope.formStatus = "pendingConfirm";
}

View File

@ -15,7 +15,7 @@
*/
angular.module('controller.records', [])
.controller('RecordsController', function ($scope, $timeout, $log, recordsService, groupsService, pagingService, utilityService) {
.controller('RecordsController', function ($scope, $timeout, $log, recordsService, groupsService, pagingService, utilityService, $q) {
/**
* Scope data initial setup
@ -35,6 +35,9 @@ angular.module('controller.records', [])
$scope.currentRecord = {};
$scope.zoneInfo = {};
var loadZonesPromise;
var loadRecordsPromise;
$scope.recordModalState = {
CREATE: 0,
UPDATE: 1,
@ -391,17 +394,20 @@ angular.module('controller.records', [])
};
function updateRecordDisplay(records) {
var newRecords = [];
angular.forEach(records, function(record) {
newRecords.push(recordsService.toDisplayRecord(record, $scope.zoneInfo.name));
});
$scope.records = newRecords;
if($scope.records.length > 0) {
$("td.dataTables_empty").hide();
} else {
$("td.dataTables_empty").show();
}
}
$q.all([loadZonesPromise, loadRecordsPromise])
.then(function(){
var newRecords = [];
angular.forEach(records, function(record) {
newRecords.push(recordsService.toDisplayRecord(record, $scope.zoneInfo.name));
});
$scope.records = newRecords;
if($scope.records.length > 0) {
$("td.dataTables_empty").hide();
} else {
$("td.dataTables_empty").show();
}
});
};
/**
* Recordset paging
@ -447,7 +453,6 @@ angular.module('controller.records', [])
});
};
/**
* Record change paging
*/
@ -492,8 +497,8 @@ angular.module('controller.records', [])
});
};
$timeout($scope.refreshZone, 0);
$timeout($scope.refreshRecords, 0);
loadZonesPromise = $timeout($scope.refreshZone, 0);
loadRecordsPromise = $timeout($scope.refreshRecords, 0);
$timeout($scope.refreshRecordChangesPreview, 0);
$timeout($scope.refreshRecordChanges, 0);