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

improvement: now widget search result will be show as one list #2504

Merged
merged 2 commits into from
Mar 15, 2022
Merged
Changes from 1 commit
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
Next Next commit
Now search result will show as one list
  • Loading branch information
shah21 committed Mar 14, 2022
commit 8dd8c5b629fec74cc6ee5f48050148c804747fa0
24 changes: 15 additions & 9 deletions frontend/src/Editor/WidgetManager.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const WidgetManager = function WidgetManager({ componentTypes, zoomLevel,
const formSection = { title: 'forms', items: [] };
const integrationSection = { title: 'integrations', items: [] };
const otherSection = { title: 'others', items: [] };
const searchedWidgets = [];

const commonItems = ['Table', 'Chart', 'Button', 'Text', 'Datepicker'];
const formItems = [
Expand All @@ -96,22 +97,27 @@ export const WidgetManager = function WidgetManager({ componentTypes, zoomLevel,
const layoutItems = ['Container', 'Listview', 'Tabs', 'Modal'];

filteredComponents.forEach((f) => {
if (searchQuery) searchedWidgets.push(f);
if (commonItems.includes(f.name)) commonSection.items.push(f);
if (formItems.includes(f.name)) formSection.items.push(f);
else if (integrationItems.includes(f.name)) integrationSection.items.push(f);
else if (layoutItems.includes(f.name)) layoutsSection.items.push(f);
else otherSection.items.push(f);
});

return (
<>
{renderList(commonSection.title, commonSection.items)}
{renderList(layoutsSection.title, layoutsSection.items)}
{renderList(formSection.title, formSection.items)}
{renderList(otherSection.title, otherSection.items)}
{renderList(integrationSection.title, integrationSection.items)}
</>
);
if (searchedWidgets.length > 0) {
return <>{renderList(undefined, searchedWidgets)}</>;
} else {
return (
<>
{renderList(commonSection.title, commonSection.items)}
{renderList(layoutsSection.title, layoutsSection.items)}
{renderList(formSection.title, formSection.items)}
{renderList(otherSection.title, otherSection.items)}
{renderList(integrationSection.title, integrationSection.items)}
</>
);
}
}

return (
Expand Down