Skip to content

Commit f505b85

Browse files
committed
restored export from explorer after changes there
1 parent 81f2b25 commit f505b85

File tree

3 files changed

+55
-32
lines changed

3 files changed

+55
-32
lines changed

src/commands/export.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,15 @@ export async function exportList(files: string[], workspaceFolder: string, names
155155
outputChannel.appendLine(`Items failed to export: \n${errors.join("\n")}`);
156156
}
157157
};
158-
return run(files);
158+
return vscode.window.withProgress(
159+
{
160+
title: "Export items",
161+
location: vscode.ProgressLocation.Notification,
162+
},
163+
() => {
164+
return run(files);
165+
}
166+
);
159167
}
160168

161169
export async function exportAll(workspaceFolder?: string): Promise<any> {
@@ -198,15 +206,7 @@ Would you like to continue?`,
198206
}
199207
}
200208
const { workspaceFolder, namespace } = node;
201-
const nodesList = node instanceof RootNode ? node.getChildren(node) : Promise.resolve([node]);
202-
return nodesList
203-
.then(nodes =>
204-
nodes.reduce(
205-
(list, subNode) => list.concat(subNode instanceof PackageNode ? subNode.getClasses() : [subNode.fullName]),
206-
[]
207-
)
208-
)
209-
.then(items => {
210-
return exportList(items, workspaceFolder, namespace);
211-
});
209+
return node.getItems4Export().then(items => {
210+
return exportList(items, workspaceFolder, namespace);
211+
});
212212
}

src/explorer/models/nodeBase.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,8 @@ export class NodeBase {
4242
public async getChildren(element): Promise<NodeBase[]> {
4343
return [];
4444
}
45+
46+
public async getItems4Export(): Promise<string[]> {
47+
return [this.fullName];
48+
}
4549
}

src/explorer/models/rootNode.ts

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ export class RootNode extends NodeBase {
2828
const path = this instanceof PackageNode ? this.fullName + "/" : "";
2929
return this.getItems(path, this._category);
3030
}
31-
public getItems(path: string, category: string): Promise<NodeBase[]> {
31+
32+
public getList(path: string, category: string, flat: boolean) {
3233
const sql = "CALL %Library.RoutineMgr_StudioOpenDialog(?,?,?,?,?,?,?)";
3334
// const sql = "CALL %Library.RoutineMgr_StudioOpenDialog(?,,,,,,?)";
3435
let spec = "";
@@ -42,12 +43,14 @@ export class RootNode extends NodeBase {
4243
case "INC":
4344
spec = "*.inc";
4445
break;
46+
case "ALL":
47+
spec = "*.cls,*.mac,*.int,*.inc";
48+
break;
4549
default:
4650
return;
4751
}
4852
const direction = "1";
4953
const orderBy = "1"; // by Name
50-
const flat = "0";
5154
const notStudio = "0";
5255
const generated = this.options.generated ? "1" : "0";
5356

@@ -58,29 +61,45 @@ export class RootNode extends NodeBase {
5861
const api = new AtelierAPI(this.workspaceFolder);
5962
api.setNamespace(this.namespace);
6063
return api
61-
.actionQuery(sql, [spec, direction, orderBy, systemFiles, flat, notStudio, generated])
64+
.actionQuery(sql, [spec, direction, orderBy, systemFiles, flat ? "1" : "0", notStudio, generated])
6265
.then(data => {
6366
const content = data.result.content;
6467
return content;
6568
})
6669
.then(data =>
67-
data
68-
.map(el => {
69-
const fullName = (this instanceof PackageNode ? this.fullName + "." : "") + el.Name;
70-
switch (el.Type) {
71-
case "9":
72-
return new PackageNode(el.Name, fullName, category, this.options);
73-
case "4":
74-
return new ClassNode(el.Name, fullName, this.options);
75-
case "0":
76-
case "1":
77-
case "2":
78-
return new RoutineNode(el.Name, fullName, this.options);
79-
default:
80-
return null;
81-
}
82-
})
83-
.filter(el => el !== null)
70+
data.map(el => {
71+
const fullName = (this instanceof PackageNode ? this.fullName + "." : "") + el.Name;
72+
return {
73+
...el,
74+
fullName,
75+
};
76+
})
8477
);
8578
}
79+
80+
public getItems(path: string, category: string): Promise<NodeBase[]> {
81+
return this.getList(path, category, false).then(data =>
82+
data
83+
.map(el => {
84+
switch (el.Type) {
85+
case "9":
86+
return new PackageNode(el.Name, el.fullName, category, this.options);
87+
case "4":
88+
return new ClassNode(el.Name, el.fullName, this.options);
89+
case "0":
90+
case "1":
91+
case "2":
92+
return new RoutineNode(el.Name, el.fullName, this.options);
93+
default:
94+
return null;
95+
}
96+
})
97+
.filter(el => el !== null)
98+
);
99+
}
100+
101+
public getItems4Export(): Promise<string[]> {
102+
const path = this instanceof PackageNode ? this.fullName + "/" : "";
103+
return this.getList(path, "ALL", true).then(data => data.map(el => el.Name));
104+
}
86105
}

0 commit comments

Comments
 (0)