From 81c111c4200319c6efc7b2aabb063d69b2838160 Mon Sep 17 00:00:00 2001 From: Jonathan Cobb Date: Fri, 10 Jan 2020 18:56:37 -0500 Subject: [PATCH] update default region when footprint changes --- src/account/NewNetworkPage.vue | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/account/NewNetworkPage.vue b/src/account/NewNetworkPage.vue index ebb26a0..ae93e89 100644 --- a/src/account/NewNetworkPage.vue +++ b/src/account/NewNetworkPage.vue @@ -134,7 +134,7 @@
-
{{ errors.first('footprint') }}
@@ -430,6 +430,9 @@ console.log('findRegion: uuid not found: '+uuid); return null; }, + refreshCloudRegions() { + this.getNearestRegions({footprintId: this.accountPlan.footprint, messages: this.messages, errors: this.errors}); + }, handleSubmit(e) { this.submitted = true; this.$validator.validate().then(valid => { @@ -474,9 +477,14 @@ }, nearestRegions (regions) { if (regions) { + console.log('nearestRegions: received: '+regions.length+' regions'); this.regions = regions; - if (this.cloudRegionUuid === null) this.cloudRegionUuid = regions[0].uuid; - if (this.defaults.region === '') this.defaults.region = regions[0]; + if (this.cloudRegionUuid === null || (typeof regions.find(r => r.uuid === this.cloudRegionUuid) === 'undefined')) { + this.cloudRegionUuid = regions[0].uuid; + } + if (this.defaults.region === '' || (typeof regions.find(r => r.uuid === this.defaults.region.uuid) === 'undefined')) { + this.defaults.region = regions[0]; + } } }, paymentMethod (pm) {