2
0
mirror of https://github.com/VinylDNS/vinyldns synced 2025-08-22 02:02:14 +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}} {{batchError}}
</p> </p>
</td> </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> </tr>
</tbody> </tbody>
</table> </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> <span ng-if="newBatch.changes.length == batchChangeLimit">Limit reached. Cannot add more than {{batchChangeLimit}} records per batch change.</span>
</div> </div>
<div class="panel-footer clearfix"> <div class="panel-footer clearfix">
<div ng-if="formStatus=='pendingSubmit'" class="pull-right"> <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>
<div ng-if="formStatus=='pendingConfirm'" class="pull-right"> <div ng-if="formStatus=='pendingConfirm'" class="pull-right">
<span>Are you sure you want to submit this batch change request?</span> <span>Are you sure you want to submit this batch change request?</span>

View File

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

View File

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