Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using grid views in dialogs #6178

Open
BurntimeX opened this issue Jan 27, 2025 · 1 comment
Open

Allow using grid views in dialogs #6178

BurntimeX opened this issue Jan 27, 2025 · 1 comment
Assignees

Comments

@BurntimeX
Copy link
Member

It would be handy if this were a function of dialogFactory, to which you only had to specify an endpoint, similar to FormBuilder dialogs.

ref #5990

@Cyperghost
Copy link
Contributor

Possible solution

1. Adding usingGridView()

  • Definition: Introduce a method usingGridView() that returns a GridViewSetup instance.
  • New Class: GridViewSetup
    • Provides the method fromGridView()
interface ResponseGridView {
  gridView: string;
}

export class GridViewSetup {
  async fromGridView(title: string, gridViewClass: string, pageNo: number = 1, sortField: string = "", sortOrder: string = "ASC", filters?: Map<string, string>, gridViewParameters?: Map<string, string>): Promise<WoltlabCoreDialog> {
    const url = `${window.WSC_RPC_API_URL}core/grid-views/render`;
    // append the parameters to the URL
    const json = (await prepareRequest(url).get().fetchAsJson()) as ResponseGridView;

    const dialog = dialogFactory().fromHtml(json.gridView).withoutControls();
    dialog.show(title);
    
    return dialog;
  }
}
  • Parameters:
    • title - The title of the dialog.
    • All other parameters are similar to the existing getRows() method.

2. Backend Controller for Handling Requests

  • Create GetGridView similar to GetRows that:
    • Accepts the same parameters as GetRowsParameters.
    • Validates and instantiates the specified gridView class.
    • Set the given properties.
    • Renders the grid view using AbstractGridView::render().
    • Returns a JsonResponse containing an array with the rendered template with the key gridView.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Minor Task
Development

No branches or pull requests

2 participants