shwstppr commented on code in PR #11991:
URL: https://github.com/apache/cloudstack/pull/11991#discussion_r2668166079


##########
ui/src/components/widgets/InfiniteScrollSelect.vue:
##########
@@ -246,6 +274,44 @@ export default {
       this.preselectedOptionValue = null
       this.successiveFetches = 0
     },
+    getApiOptionsCount () {
+      // Return count of options excluding the locally added defaultOption
+      if (this.defaultOption) {
+        const defaultOptionValue = this.defaultOption[this.optionValueKey]
+        return this.options.filter(option => option[this.optionValueKey] !== 
defaultOptionValue).length
+      }
+      return this.options.length
+    },

Review Comment:
   this can be under computed?



##########
ui/src/components/view/DedicateDomain.vue:
##########
@@ -72,59 +64,49 @@ export default {
   },
   data () {
     return {
-      domainsLoading: false,
       domainId: null,
-      accountsList: null,
-      domainsList: null,
+      selectedAccount: null,
       domainError: false
     }
   },
+  computed: {
+    domainsApiParams () {
+      return {
+        listall: true,
+        details: 'min'
+      }
+    },
+    accountsApiParams () {
+      if (!this.domainId) {
+        return {
+          listall: true,
+          showicon: true
+        }
+      }
+      return {
+        showicon: true,
+        domainid: this.domainId
+      }
+    }
+  },
   watch: {
     error () {
       this.domainError = this.error
     }
   },
   created () {
-    this.fetchData()
   },
   methods: {
-    fetchData () {
-      this.domainsLoading = true
-      api('listDomains', {
-        listAll: true,
-        details: 'min'
-      }).then(response => {
-        this.domainsList = response.listdomainsresponse.domain
-
-        if (this.domainsList[0]) {
-          this.domainId = this.domainsList[0].id
-          this.handleChangeDomain(this.domainId)
-        }
-      }).catch(error => {
-        this.$notifyError(error)
-      }).finally(() => {
-        this.domainsLoading = false
-      })
-    },
-    fetchAccounts () {
-      api('listAccounts', {
-        domainid: this.domainId
-      }).then(response => {
-        this.accountsList = response.listaccountsresponse.account || []
-        if (this.accountsList && this.accountsList.length === 0) {
-          this.handleChangeAccount(null)
-        }
-      }).catch(error => {
-        this.$notifyError(error)
-      })
-    },
-    handleChangeDomain (e) {
-      this.$emit('domainChange', e)
+    handleChangeDomain (domainId) {
+      this.domainId = domainId
+      this.selectedAccount = null
+      this.$emit('domainChange', domainId)
       this.domainError = false
-      this.fetchAccounts()
+      // InfiniteScrollSelect will auto-reload accounts when apiParams changes

Review Comment:
   do we really need these comments?



##########
ui/src/components/widgets/InfiniteScrollSelect.vue:
##########
@@ -166,6 +178,19 @@ export default {
     },
     formattedSearchFooterMessage () {
       return `${this.$t('label.showing.results.for').replace('%x', 
this.searchQuery)}`
+    },
+    selectableOptions () {
+      const currentValue = this.$attrs.value
+      // Only filter out null/empty options when the current value is also 
null/undefined/empty
+      // This prevents such options from being selected and allows the 
placeholder to show instead
+      if (currentValue === null || currentValue === undefined || currentValue 
=== '') {
+        return this.options.filter(option => {
+          const optionValue = option[this.optionValueKey]
+          return optionValue !== null && optionValue !== undefined && 
optionValue !== ''
+        })
+      }
+      // When a valid value is selected, show all options
+      return this.options

Review Comment:
   What is the benefit of this differentiation? Maybe we can show the 
null/empty option always or is it beneficial when using the value from route?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to