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

Added ability to add parentId into api calls #52

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/src/js/grids/vuetify/dataAdaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import type { Query, OrderBy } from "@js/grids/vuetify/types";

export class DataAdaptor extends ObApiClient {
private readonly errorCallback: Function;
private readonly _parentId?: string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The underscore for private fields is an outdated convention...
It should be used only in case of possible member conflict:

https://stackoverflow.com/questions/47747809/typescript-underscore-convention-for-members
https://www.typescriptlang.org/docs/handbook/2/classes.html#private


constructor(apiBaseUrl: string, errorCallback: Function) {
constructor(apiBaseUrl: string, errorCallback: Function, parentId?: string) {
super(apiBaseUrl);
this._parentId = parentId;
this.errorCallback = errorCallback;
}

Expand All @@ -21,6 +23,10 @@ export class DataAdaptor extends ObApiClient {
filters.push(`limit=${query.limit}`);
filters.push(this.constructSortQuery(query.orderBy));

if (this._parentId) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the syncfusion front-end, the executeApi is more complex and with more parameters. Why can't we do this here? Why can't parentId be an optional parameter to pass to executeApi instead of being passed in the ctor?

image

filters.push(`parentId=${this._parentId}`);
}

const finalQuery = `?${filters.join("&")}`;

try {
Expand Down
4 changes: 2 additions & 2 deletions src/src/js/grids/vuetify/vuetifyEntityGrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ export class VuetifyEntityGrid extends EntityGrid {
}
}

public initDataAdaptor(apiUrl: string, errorCallback: Function): void {
this._dataAdaptor = new DataAdaptor(apiUrl, errorCallback);
public initDataAdaptor(apiUrl: string, errorCallback: Function, parentId?: string): void {
this._dataAdaptor = new DataAdaptor(apiUrl, errorCallback, parentId);
}

public async refresh(): Promise<void> {
Expand Down