2323 Showing first {{ projectGroups.length }} of {{ totalCount }} project groups
2424 <span v-if =" hasMore && !loading" class =" pg-scroll-hint" >· ; Scroll to continue loading</span >
2525 </template >
26- <template v-else-if =" ! hasMore " >Showing all {{ projectGroups.length }} project group{{ projectGroups.length !== 1 ? 's' : '' }}</template >
26+ <template v-else-if =" ! showScrollHint " >Showing all {{ projectGroups.length }} project group{{ projectGroups.length !== 1 ? 's' : '' }}</template >
2727 <template v-else >
2828 Showing first {{ projectGroups.length }} results
2929 <span v-if =" !loading" class =" pg-scroll-hint" >· ; Scroll to continue loading</span >
3333 </div >
3434 <div
3535 class =" pg-list-wrap"
36- :class =" { 'pg-has-more': hasMore && !loading }"
36+ :class =" { 'pg-has-more': showScrollHint && !loading }"
3737 ref =" listRef"
3838 @scroll =" onScroll"
3939 >
@@ -89,8 +89,9 @@ import { ref, watch, onMounted, onUnmounted, nextTick } from 'vue'
8989import { tdeiUserClient } from ' ~/services/index'
9090import type { TdeiProjectGroupItem } from ' ~/types/tdei'
9191
92- const props = withDefaults (defineProps <{ id? : string ; disabled? : boolean ; options? : TdeiProjectGroupItem [] }>(), {
92+ const props = withDefaults (defineProps <{ id? : string ; disabled? : boolean ; options? : TdeiProjectGroupItem []; rememberSelection ? : boolean }>(), {
9393 disabled: false ,
94+ rememberSelection: false ,
9495})
9596
9697const model = defineModel ({ required: true })
@@ -105,6 +106,7 @@ const listRef = ref<HTMLElement | null>(null)
105106const activeIndex = ref (- 1 )
106107
107108const projectGroups = computed (() => props .options ?? fetchedGroups .value )
109+ const showScrollHint = computed (() => ! props .options && hasMore .value )
108110
109111let pageNo = 1
110112const hasMore = ref (true )
@@ -144,7 +146,9 @@ const loadGroups = async (reset = false) => {
144146 if (total !== undefined ) totalCount .value = total
145147 fetchedGroups .value .push (... newGroups )
146148 const selected = newGroups .find (g => g .tdei_project_group_id === model .value )
147- if (selected ) persistCachedName (selected .tdei_project_group_id , selected .name )
149+ if (selected && props .rememberSelection ) {
150+ persistCachedName (selected .tdei_project_group_id , selected .name )
151+ }
148152
149153 if (newGroups .length < pageSize ) {
150154 hasMore .value = false
@@ -205,7 +209,9 @@ const selectGroup = (id: string) => {
205209 if (pg ) {
206210 searchText .value = pg .name
207211 selectedGroupName .value = pg .name
208- persistCachedName (pg .tdei_project_group_id , pg .name )
212+ if (props .rememberSelection ) {
213+ persistCachedName (pg .tdei_project_group_id , pg .name )
214+ }
209215 }
210216}
211217
@@ -296,7 +302,7 @@ watch(
296302 (groups ) => {
297303 if (groups .length > 0 ) {
298304 const pgId = model .value as string | undefined
299- if (! pgId || ! groups .some (pg => pg .tdei_project_group_id === pgId )) {
305+ if (! pgId || ( props . options && ! groups .some (pg => pg .tdei_project_group_id === pgId ) )) {
300306 model .value = groups [0 ]?.tdei_project_group_id
301307 }
302308 const selected = groups .find (pg => pg .tdei_project_group_id === model .value )
@@ -311,7 +317,7 @@ watch(
311317
312318onMounted (async () => {
313319 // Show cached name immediately before the API call completes
314- if (model .value && loadCachedName (model .value as string )) {
320+ if (props . rememberSelection && model .value && loadCachedName (model .value as string )) {
315321 applyCachedName ()
316322 }
317323
@@ -323,7 +329,7 @@ onMounted(async () => {
323329 if (selected ) {
324330 searchText .value = selected .name
325331 selectedGroupName .value = selected .name
326- } else if (model .value && loadCachedName (model .value as string )) {
332+ } else if (props . rememberSelection && model .value && loadCachedName (model .value as string )) {
327333 // Group is beyond page 1 — use the cached name for display
328334 applyCachedName ()
329335 } else if (model .value ) {
0 commit comments