remove unused custom filter for grids (which adds complexity)
This commit is contained in:
@@ -326,33 +326,6 @@ export default class EntityGrid extends Vue {
|
||||
@Prop({ default: "other party" })
|
||||
conflictContext!: string;
|
||||
|
||||
/**
|
||||
* Function to determine which entities to display (allows parent control)
|
||||
*
|
||||
* This function prop allows parent components to customize which entities
|
||||
* are displayed in the grid, enabling advanced filtering and sorting.
|
||||
* Note: Infinite scroll is disabled when this prop is provided.
|
||||
*
|
||||
* @param entities - The full array of entities (Contact[] or PlanData[])
|
||||
* @param entityType - The type of entities being displayed ("people" or "projects")
|
||||
* @returns Filtered/sorted array of entities to display
|
||||
*
|
||||
* @example
|
||||
* // Custom filtering: only show contacts with profile images
|
||||
* :display-entities-function="(entities, type) =>
|
||||
* entities.filter(e => e.profileImageUrl)"
|
||||
*
|
||||
* @example
|
||||
* // Custom sorting: sort projects by name
|
||||
* :display-entities-function="(entities, type) =>
|
||||
* entities.sort((a, b) => a.name.localeCompare(b.name))"
|
||||
*/
|
||||
@Prop({ default: null })
|
||||
displayEntitiesFunction?: (
|
||||
entities: Contact[] | PlanData[],
|
||||
entityType: "people" | "projects",
|
||||
) => Contact[] | PlanData[];
|
||||
|
||||
/**
|
||||
* CSS classes for the empty state message
|
||||
*/
|
||||
@@ -397,11 +370,6 @@ export default class EntityGrid extends Vue {
|
||||
return this.filteredEntities.slice(0, this.displayedCount);
|
||||
}
|
||||
|
||||
// If custom function provided, use it (disables infinite scroll)
|
||||
if (this.displayEntitiesFunction) {
|
||||
return this.displayEntitiesFunction(this.entitiesToUse, this.entityType);
|
||||
}
|
||||
|
||||
// Default: projects use infinite scroll
|
||||
if (this.entityType === "projects") {
|
||||
return (this.entitiesToUse as PlanData[]).slice(0, this.displayedCount);
|
||||
@@ -860,11 +828,6 @@ export default class EntityGrid extends Vue {
|
||||
* Determine if more entities can be loaded
|
||||
*/
|
||||
canLoadMore(): boolean {
|
||||
if (this.displayEntitiesFunction) {
|
||||
// Custom function disables infinite scroll
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.searchTerm.trim()) {
|
||||
// Search mode: check if more results available
|
||||
if (this.entityType === "projects") {
|
||||
|
||||
@@ -2,15 +2,6 @@
|
||||
<div>
|
||||
<h2>EntityGrid Function Prop Test</h2>
|
||||
|
||||
<div class="mb-4">
|
||||
<button @click="toggleCustomFunction">
|
||||
{{ useCustomFunction ? "Use Default" : "Use Custom Function" }}
|
||||
</button>
|
||||
<span class="ml-2"
|
||||
>Current: {{ useCustomFunction ? "Custom" : "Default" }}</span
|
||||
>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<h3>
|
||||
People Grid ({{ people.length }} total,
|
||||
@@ -23,9 +14,6 @@
|
||||
:all-my-dids="allMyDids"
|
||||
:all-contacts="people"
|
||||
:conflict-checker="conflictChecker"
|
||||
:display-entities-function="
|
||||
useCustomFunction ? customPeopleFunction : undefined
|
||||
"
|
||||
@entity-selected="handleEntitySelected"
|
||||
/>
|
||||
</div>
|
||||
@@ -42,9 +30,6 @@
|
||||
:all-my-dids="allMyDids"
|
||||
:all-contacts="people"
|
||||
:conflict-checker="conflictChecker"
|
||||
:display-entities-function="
|
||||
useCustomFunction ? customProjectsFunction : undefined
|
||||
"
|
||||
@entity-selected="handleEntitySelected"
|
||||
/>
|
||||
</div>
|
||||
@@ -74,7 +59,6 @@ import { PlanData } from "../interfaces/records";
|
||||
},
|
||||
})
|
||||
export default class EntityGridFunctionPropTest extends Vue {
|
||||
useCustomFunction = false;
|
||||
selectedEntity: {
|
||||
type: "person" | "project" | "special";
|
||||
entityType?: string;
|
||||
@@ -144,26 +128,6 @@ export default class EntityGridFunctionPropTest extends Vue {
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* Custom function for people: only show those with profile images
|
||||
*/
|
||||
customPeopleFunction = (
|
||||
entities: Contact[],
|
||||
_entityType: string,
|
||||
): Contact[] => {
|
||||
return entities.filter((person) => person.profileImageUrl);
|
||||
};
|
||||
|
||||
/**
|
||||
* Custom function for projects: sort by name and limit to 3
|
||||
*/
|
||||
customProjectsFunction = (
|
||||
entities: PlanData[],
|
||||
_entityType: string,
|
||||
): PlanData[] => {
|
||||
return entities.sort((a, b) => a.name.localeCompare(b.name)).slice(0, 3);
|
||||
};
|
||||
|
||||
/**
|
||||
* Simple conflict checker for testing
|
||||
*/
|
||||
@@ -171,13 +135,6 @@ export default class EntityGridFunctionPropTest extends Vue {
|
||||
return did === this.activeDid;
|
||||
};
|
||||
|
||||
/**
|
||||
* Toggle between custom and default display functions
|
||||
*/
|
||||
toggleCustomFunction(): void {
|
||||
this.useCustomFunction = !this.useCustomFunction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle entity selection
|
||||
*/
|
||||
@@ -193,16 +150,10 @@ export default class EntityGridFunctionPropTest extends Vue {
|
||||
* Computed properties to show display counts
|
||||
*/
|
||||
get displayedPeopleCount(): number {
|
||||
if (this.useCustomFunction) {
|
||||
return this.customPeopleFunction(this.people, "people").length;
|
||||
}
|
||||
return Math.min(10, this.people.length); // Initial batch size for infinite scroll
|
||||
}
|
||||
|
||||
get displayedProjectsCount(): number {
|
||||
if (this.useCustomFunction) {
|
||||
return this.customProjectsFunction(this.projects, "projects").length;
|
||||
}
|
||||
return Math.min(10, this.projects.length); // Initial batch size for infinite scroll
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user