diff --git a/src/components/EntityGrid.vue b/src/components/EntityGrid.vue index 6f3163c28a..dd825c5e29 100644 --- a/src/components/EntityGrid.vue +++ b/src/components/EntityGrid.vue @@ -155,6 +155,7 @@ projects, and special entities with selection. * * @author Matthew Raymer */ :active-did="activeDid" :all-my-dids="allMyDids" :all-contacts="allContacts" + :conflicted="isProjectConflicted(project.handleId)" :notify="notify" :conflict-context="conflictContext" @project-selected="handleProjectSelected" @@ -175,6 +176,7 @@ projects, and special entities with selection. * * @author Matthew Raymer */ :active-did="activeDid" :all-my-dids="allMyDids" :all-contacts="allContacts" + :conflicted="isProjectConflicted(project.handleId)" :notify="notify" :conflict-context="conflictContext" @project-selected="handleProjectSelected" @@ -190,6 +192,7 @@ projects, and special entities with selection. * * @author Matthew Raymer */ :active-did="activeDid" :all-my-dids="allMyDids" :all-contacts="allContacts" + :conflicted="isProjectConflicted(project.handleId)" :notify="notify" :conflict-context="conflictContext" @project-selected="handleProjectSelected" @@ -556,6 +559,13 @@ export default class EntityGrid extends Vue { return this.conflictChecker(did); } + /** + * Check if a project handleId is conflicted + */ + isProjectConflicted(handleId: string): boolean { + return this.conflictChecker(handleId); + } + /** * Handle person selection from PersonCard */ @@ -1037,6 +1047,50 @@ export default class EntityGrid extends Vue { return data; } + /** + * Watch for changes in entityType to load projects when switching to projects + */ + @Watch("entityType") + async onEntityTypeChange(newType: "people" | "projects"): Promise { + // Reset displayed count and clear search when switching types + this.displayedCount = INITIAL_BATCH_SIZE; + this.searchTerm = ""; + this.filteredEntities = []; + this.searchBeforeId = undefined; + this.infiniteScrollReset?.(); + + // When switching to projects, load them if not provided via entities prop + if (newType === "projects" && !this.entities) { + // Ensure apiServer is loaded + if (!this.apiServer) { + const settings = await this.$accountSettings(); + this.apiServer = settings.apiServer || ""; + this.starredPlanHandleIds = settings.starredPlanHandleIds || []; + } + + // Load projects if we have an API server + if (this.apiServer && this.allProjects.length === 0) { + this.isLoadingProjects = true; + try { + await this.fetchProjects(); + } catch (error) { + logger.error( + "Error loading projects when switching to projects:", + error, + ); + } finally { + this.isLoadingProjects = false; + } + } + } + + // Clear project state when switching away from projects + if (newType === "people") { + this.allProjects = []; + this.loadBeforeId = undefined; + } + } + /** * Watch for changes in search term to reset displayed count and pagination */ diff --git a/src/components/EntitySelectionStep.vue b/src/components/EntitySelectionStep.vue index 3fba214129..c6f0f197c0 100644 --- a/src/components/EntitySelectionStep.vue +++ b/src/components/EntitySelectionStep.vue @@ -8,9 +8,19 @@ notifications for conflicted entities * - Template streamlined with computed CSS properties * * @author Matthew Raymer */