Skip to content

Commit dde204d

Browse files
committed
OCIF updates
1 parent 6af4e74 commit dde204d

File tree

4 files changed

+87
-16
lines changed

4 files changed

+87
-16
lines changed

libs/app-canvas/src/app/components/navbar-components.tsx

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
setSelectNode,
88
} from '@devhelpr/visual-programming-system';
99
import {
10-
navBarButton,
1110
navBarIconButton,
1211
navBarIconButtonInnerElement,
1312
} from '../consts/classes';
@@ -68,13 +67,13 @@ export class NavbarComponent extends Component<
6867
return;
6968
}
7069
// <button class="${navBarPrimaryIconButton}"><span class="${navBarIconButtonInnerElement} icon-add"></span></button>
71-
70+
//<button class="${navBarButton}">Import</button>
7271
this.template = createTemplate(
7372
`<div class="inline-flex items-center content-center">
7473
<button class="${navBarIconButton}"><span class="${navBarIconButtonInnerElement} icon-fit_screen"></span></button>
7574
<button class="${navBarIconButton}"><span class="${navBarIconButtonInnerElement} icon-delete"></span></button>
7675
<div></div>
77-
<button class="${navBarButton}">Import</button>
76+
<div></div>
7877
${
7978
props.hideFlowPresets
8079
? ''
@@ -130,11 +129,33 @@ export class NavbarComponent extends Component<
130129
this.centerButton.addEventListener('click', this.onClickCenter);
131130
this.deleteButton.addEventListener('click', this.onClickDelete);
132131
//this.exportButton.addEventListener('click', this.onClickExport);
133-
this.importButton.addEventListener('click', this.onClickImport);
132+
//this.importButton.addEventListener('click', this.onClickImport);
134133
this.selectExampleFlow?.addEventListener(
135134
'change',
136135
this.onClickImportExample
137136
);
137+
138+
renderElement(
139+
<DropdownButton
140+
class=""
141+
mainBgColorClass="bg-slate-500"
142+
bgColorClasses="bg-slate-500 "
143+
textColorClasses="text-white"
144+
caption="Import"
145+
onClick={() => {
146+
this.import();
147+
}}
148+
dropdownItems={[
149+
{
150+
caption: 'Import as OCIF',
151+
onClick: () => {
152+
//
153+
},
154+
},
155+
]}
156+
/>,
157+
this.importButton
158+
);
138159
renderElement(
139160
<DropdownButton
140161
class=""
@@ -522,8 +543,7 @@ export class NavbarComponent extends Component<
522543
);
523544
};
524545

525-
onClickImport = (event: Event) => {
526-
event.preventDefault();
546+
import = () => {
527547
const input = document.createElement('input') as HTMLInputElement & {
528548
files: FileList;
529549
};
@@ -569,7 +589,6 @@ export class NavbarComponent extends Component<
569589
}
570590
};
571591
input.click();
572-
return false;
573592
};
574593

575594
onClickImportScript = (event: Event) => {

libs/app-canvas/src/app/exporters/export-ocwg.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ export class OCWGExporter extends BaseExporter<OCWGFile, OCWGInfo> {
8787
}
8888
if (parentId && this.file) {
8989
const relation = this.file.relations.find((r) => r.id === parentId);
90-
if (relation && relation.type === '@ocwg/set') {
90+
if (relation && relation.type === '@ocwg/rel/group') {
9191
relation.members.push(ocwgNode.id);
9292
} else {
9393
const relation = {
94-
type: '@ocwg/set' as const,
94+
type: '@ocwg/rel/group' as const,
9595
members: [ocwgNode.id],
9696
id: parentId,
9797
};

libs/app-canvas/src/app/exporters/ocwg/ocwg-empty-file.ts

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,59 @@ export const ocwgEmptyFile: OCWGFile = {
55
nodes: [],
66
relations: [],
77
resources: [],
8-
schemas: {},
8+
schemas: [
9+
{
10+
uri: 'https://codeflowcanvas.io/schemas/node/0.1.json',
11+
name: '@code-flow-canvas/node-properties',
12+
type: 'object',
13+
properties: {
14+
type: {
15+
type: 'string',
16+
},
17+
nodeType: {
18+
type: 'string',
19+
},
20+
},
21+
required: ['type', 'nodeType'],
22+
additionalProperties: true,
23+
},
24+
{
25+
uri: 'https://codeflowcanvas.io/schemas/connection/0.1.json',
26+
name: '@code-flow-canvas/connection-properties',
27+
type: 'object',
28+
properties: {
29+
type: {
30+
type: 'string',
31+
},
32+
start: {
33+
type: 'object',
34+
properties: {
35+
connected_to: {
36+
type: 'string',
37+
},
38+
portName: {
39+
type: 'string',
40+
},
41+
},
42+
required: ['connected_to', 'portName'],
43+
additionalProperties: false,
44+
},
45+
end: {
46+
type: 'object',
47+
properties: {
48+
connected_to: {
49+
type: 'string',
50+
},
51+
portName: {
52+
type: 'string',
53+
},
54+
},
55+
required: ['connected_to', 'portName'],
56+
additionalProperties: false,
57+
},
58+
},
59+
required: ['type', 'start', 'end'],
60+
additionalProperties: true,
61+
},
62+
],
963
};

libs/app-canvas/src/app/exporters/ocwg/ocwg-schema.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ export type OCWGEdge = {
1414
from: string;
1515
to: string;
1616
};
17-
export type OCWGRelation = OCWGSet | OCWGEdge;
17+
export type OCWGRelation = OCWGGroup | OCWGEdge;
1818

19-
export type OCWGSet = {
20-
type: '@ocwg/set';
19+
export type OCWGGroup = {
20+
type: '@ocwg/rel/group';
2121
members: Array<string>;
2222
id: string;
2323
};
@@ -26,7 +26,5 @@ export type OCWGFile = {
2626
nodes: OCWGNode[];
2727
relations: OCWGRelation[];
2828
resources: any[];
29-
schemas: {
30-
[key: string]: any;
31-
};
29+
schemas: any[];
3230
};

0 commit comments

Comments
 (0)