From 34724e5278b8c09bba58470395da17677fbe664b Mon Sep 17 00:00:00 2001 From: Sam Grund Date: Tue, 26 Jan 2021 11:05:38 -0500 Subject: [PATCH] fix: disabled in progress and size error fixed --- .../components/EditReserveCategoryModal.vue | 21 ++++++++++++------- src/public/pages/reserve-instances.vue | 20 ++++++++++++++---- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/public/components/EditReserveCategoryModal.vue b/src/public/components/EditReserveCategoryModal.vue index 962ba02e..c05292ee 100644 --- a/src/public/components/EditReserveCategoryModal.vue +++ b/src/public/components/EditReserveCategoryModal.vue @@ -124,7 +124,7 @@ ]" @click="saveCategory" > - {{ `${mode === 'add' ? 'Add' : 'Edit'}` }} + {{ `${mode === 'add' ? 'Add' : 'Save'}` }} @@ -181,13 +181,20 @@ export default { }, computed: { availableSupply() { - const defaultCategory = this.$store.state.currentConfig.reserveCategories.find( - (cat) => !!cat.isDefault + const totalAllocation = this.$store.state.currentConfig.reserveCategories.reduce( + (total, cat) => { + // we are allowed to take units from the default category + if (!cat.isDefault) { + return total + parseInt(cat.size) + } + return total + }, + 0 + ) + return ( + parseInt(this.initialSize) + + parseInt(this.$store.state.currentConfig.supply - totalAllocation) ) - if (defaultCategory) { - return parseInt(this.initialSize) + parseInt(defaultCategory.size) - } - return this.$store.state.currentConfig.supply }, CATEGORY_TYPE() { return CATEGORY_TYPE diff --git a/src/public/pages/reserve-instances.vue b/src/public/pages/reserve-instances.vue index 531e8bc0..cf163894 100644 --- a/src/public/pages/reserve-instances.vue +++ b/src/public/pages/reserve-instances.vue @@ -74,7 +74,12 @@ -
+