fix issue sort and search on table browse screen#69
Conversation
📝 WalkthroughWalkthroughThe changes enhance sorting and filtering capabilities across the application by integrating server-side sorting and filtering into the browse endpoints. The backend repository methods now accept ordering and filter parameters, supported by a new utility to construct SQL filter clauses. The frontend integrates AG Grid's server-side datasource to propagate sort and filter parameters to the API. Additionally, the moderation workflow is improved with better button state management and user feedback via toast notifications. Changes
Sequence DiagramssequenceDiagram
participant Client as Client / Browser
participant Handler as API Handler
participant Repo as Repository
participant DB as Database
Client->>Handler: GET /browse?sortBy=downloads&filterName=test
Handler->>Handler: Parse sortBy → downloads (map to db_downloads)<br/>Parse filters (name: test)
Handler->>Repo: SearchPaginated(ctx, query, categoryID,<br/>limit, offset, "db_downloads", "desc",<br/>{name: {value: "test", type: "contains"}})
Repo->>Repo: buildFilterClause(filters) → WHERE clause<br/>Construct ORDER BY clause
Repo->>DB: SELECT * FROM records<br/>WHERE name LIKE '%test%'<br/>ORDER BY db_downloads DESC
DB-->>Repo: Filtered & sorted records
Repo-->>Handler: Records, total count
Handler-->>Client: JSON with sorted/filtered results
sequenceDiagram
participant User as User
participant UI as UI Button
participant API as API Handler
participant Server as Server
User->>UI: Click moderation action button
UI->>UI: Capture original button text<br/>Disable all related buttons<br/>Update button text (e.g., "Approving...")
UI->>API: POST /moderate {action: "approve"}
API->>Server: Process moderation action
alt Success
Server-->>API: 200 OK
API-->>UI: Success response
UI->>UI: Show toast "Action successful"<br/>Reload page
else Error
Server-->>API: 4xx/5xx Error
API-->>UI: Error response
UI->>UI: Show error toast<br/>Reset button text<br/>Re-enable buttons
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
Fixed the issue:
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.