-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/ef/treeview tables #32
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
47d32a1
Added placeholder for treeview for showing tables and fields
ejfasting 353b086
Fixed bug in httpHandler
ejfasting 5c78c89
Updated with logic to fetch extraTable and extraFields through the dy…
ejfasting b43330c
Updated with logic to fetch extraTable and extraFields through the dy…
ejfasting a3ff7cd
Update packages/superofficedx-vscode-core/tests/suite/commands/regist…
ejfasting 29f7f76
Update packages/superofficedx-vscode-core/src/providers/extraTablesTr…
ejfasting File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
packages/superofficedx-vscode-core/src/providers/extraTablesTreeViewDataProvider.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| import { TreeItem, TreeItemCollapsibleState, ThemeIcon, TreeDataProvider, EventEmitter, Event, ExtensionContext } from 'vscode'; | ||
| import { SuperofficeAuthenticationProvider } from './superofficeAuthenticationProvider'; | ||
| import { IHttpService } from '../services/httpService'; | ||
| import { ExtraTable } from '../types/odata/extratable'; | ||
|
|
||
| export class ExtraTablesNode implements TreeItem { | ||
| contextValue: string; | ||
| collapsibleState: TreeItemCollapsibleState; | ||
|
|
||
| constructor( | ||
| public readonly label: string, | ||
| public readonly children?: ExtraTablesNode[], | ||
| public readonly iconPath?: ThemeIcon | ||
| ) { | ||
| this.contextValue = children && children.length > 0 ? 'extraTablesParent' : 'extraTablesChild'; | ||
| this.collapsibleState = children && children.length > 0 | ||
| ? TreeItemCollapsibleState.Collapsed | ||
| : TreeItemCollapsibleState.None; | ||
| } | ||
| } | ||
|
|
||
| export class ExtraTablesTreeViewDataProvider implements TreeDataProvider<ExtraTablesNode> { | ||
| private _onDidChangeTreeData: EventEmitter<ExtraTablesNode | undefined> = new EventEmitter<ExtraTablesNode | undefined>(); | ||
| readonly onDidChangeTreeData: Event<ExtraTablesNode | undefined> = this._onDidChangeTreeData.event; | ||
|
|
||
| public static readonly viewId = 'superOfficeDX.extraTablesExplorer'; | ||
|
|
||
| constructor( | ||
| _context: ExtensionContext, // Parameter required for DI container compatibility | ||
| private authProvider: SuperofficeAuthenticationProvider, | ||
| private httpService: IHttpService) { | ||
| // _context is intentionally unused; required for DI container compatibility | ||
| } | ||
|
|
||
| // Call this method to trigger a refresh of the tree view | ||
| public refresh(): void { | ||
| this._onDidChangeTreeData.fire(undefined); | ||
| } | ||
|
|
||
| getTreeItem(element: ExtraTablesNode): TreeItem { | ||
| return element; | ||
| } | ||
|
|
||
| async getChildren(element?: ExtraTablesNode): Promise<ExtraTablesNode[]> { | ||
| if (element) { | ||
| return element.children || []; | ||
| } | ||
|
|
||
| const currentSession = this.authProvider.getCurrentSession(); | ||
| if (currentSession) { | ||
| try { | ||
| const scriptResponseData = await this.httpService.getExtraTables(currentSession); | ||
|
|
||
| // Group scripResponseData by property "extra_tables.table_name" | ||
| const groupedTables = new Map<string, ExtraTable[]>(); | ||
| scriptResponseData.value.forEach(item => { | ||
| const tableName = item["extra_tables.table_name"]; | ||
| if (!groupedTables.has(tableName)) { | ||
| groupedTables.set(tableName, []); | ||
| } | ||
| groupedTables.get(tableName)!.push(item); | ||
| }); | ||
|
|
||
| const tableNodes: ExtraTablesNode[] = []; | ||
| groupedTables.forEach((tableItems, tableName) => { | ||
| const fieldNodes = tableItems.map(item => { | ||
| const typeNode = new ExtraTablesNode( | ||
| "type: " + item["extra_tables.(extra_fields->extra_table).type"], | ||
| undefined, | ||
| new ThemeIcon('symbol-property') | ||
| ); | ||
|
|
||
| const descriptionNode = new ExtraTablesNode( | ||
| "description: " + item["extra_tables.(extra_fields->extra_table).description"], | ||
| undefined, | ||
| new ThemeIcon('symbol-property') | ||
| ); | ||
|
|
||
| return new ExtraTablesNode( | ||
| item["extra_tables.(extra_fields->extra_table).field_name"], | ||
| [typeNode, descriptionNode], | ||
| new ThemeIcon('symbol-field') | ||
| ); | ||
| }); | ||
|
|
||
| // Create parent node for the table | ||
| const tableNode = new ExtraTablesNode( | ||
| tableName, | ||
| fieldNodes, | ||
| new ThemeIcon('database') | ||
| ); | ||
|
|
||
| tableNodes.push(tableNode); | ||
| }); | ||
|
|
||
| return tableNodes; | ||
| } catch (err) { | ||
| if (err instanceof Error) { | ||
| throw new Error(err.message); | ||
| } else { | ||
| throw new Error(String(err)); | ||
| } | ||
ejfasting marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| return []; | ||
| } | ||
| } | ||
2 changes: 1 addition & 1 deletion
2
packages/superofficedx-vscode-core/src/providers/treeViewDataProvider.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/superofficedx-vscode-core/src/services/fileSystemService.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.