Skip to content

Commit 1d5ec72

Browse files
Release v0.0.97
1 parent eae9275 commit 1d5ec72

14 files changed

+108
-9
lines changed

dist/index.css

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.css.map

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js

+25-1
Original file line numberDiff line numberDiff line change
@@ -43277,6 +43277,7 @@ var SchemaDesignerToolbar = class {
4327743277
this._container = _container;
4327843278
this._graph = _graph;
4327943279
this._config = _config;
43280+
this.buttons = /* @__PURE__ */ new Map();
4328043281
this._toolbarDiv = document.createElement("div");
4328143282
this._container.appendChild(this._toolbarDiv);
4328243283
this._toolbarDiv.classList.add("sd-toolbar");
@@ -43287,7 +43288,11 @@ var SchemaDesignerToolbar = class {
4328743288
this._toolbarDiv.appendChild(button);
4328843289
button.classList.add("sd-toolbar-button");
4328943290
button.innerHTML = icon;
43290-
button.onclick = callback;
43291+
button.onclick = () => {
43292+
if (!this.isButtonDisabled(title)) {
43293+
callback();
43294+
}
43295+
};
4329143296
button.title = title;
4329243297
if (onDragEndCallback) {
4329343298
const dragImage = button.cloneNode(true);
@@ -43300,6 +43305,16 @@ var SchemaDesignerToolbar = class {
4330043305
);
4330143306
ds.highlightDropTargets = true;
4330243307
}
43308+
this.buttons.set(title, button);
43309+
}
43310+
disableButton(title) {
43311+
this.buttons.get(title)?.classList.add("sd-toolbar-button-disabled");
43312+
}
43313+
enableButton(title) {
43314+
this.buttons.get(title)?.classList.remove("sd-toolbar-button-disabled");
43315+
}
43316+
isButtonDisabled(title) {
43317+
return this.buttons.get(title)?.classList.contains("sd-toolbar-button-disabled");
4330343318
}
4330443319
addDivider() {
4330543320
const divider = document.createElement("div");
@@ -44252,6 +44267,15 @@ var SchemaDesigner = class {
4425244267
}
4425344268
}
4425444269
);
44270+
this.toolbar.addDivider();
44271+
this.toolbar.addButton(
44272+
this.config.icons.exportIcon,
44273+
"Export",
44274+
() => {
44275+
const schema = this.schema;
44276+
this.config.publish(schema);
44277+
}
44278+
);
4425544279
}
4425644280
}
4425744281
/**

dist/index.js.map

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/src/ts/schemaDesigner/schemaDesigner.js

+5
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,11 @@ class SchemaDesigner {
510510
this.mxEditor.execute("delete", cell);
511511
}
512512
});
513+
this.toolbar.addDivider();
514+
this.toolbar.addButton(this.config.icons.exportIcon, "Export", () => {
515+
const schema = this.schema;
516+
this.config.publish(schema);
517+
});
513518
}
514519
}
515520
/**

dist/src/ts/schemaDesigner/schemaDesignerInterfaces.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@ export interface SchemaDesignerConfig {
200200
* @param scale scale of the graph
201201
*/
202202
updateEditorPosition: (x: number, y: number, scale: number) => void;
203+
/**
204+
* Callback to publish the schema
205+
* @param model schema model
206+
*/
207+
publish: (model: ISchema) => void;
203208
}
204209
/**
205210
* Interface for edge cells in schema designer

dist/src/ts/schemaDesigner/schemaDesignerToolbar.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ export declare class SchemaDesignerToolbar {
55
private _graph;
66
private _config;
77
private _toolbarDiv;
8+
buttons: Map<string, HTMLElement>;
89
constructor(_container: HTMLElement, _graph: mxGraph, _config: SchemaDesignerConfig);
910
addButton(icon: string, title: string, callback: () => void, onDragEndCallback?: (graph: mxGraph, evt: MouseEvent, cell: mxCellState) => void): void;
11+
disableButton(title: string): void;
12+
enableButton(title: string): void;
13+
isButtonDisabled(title: string): boolean | undefined;
1014
addDivider(): void;
1115
}

dist/src/ts/schemaDesigner/schemaDesignerToolbar.js

+19-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class SchemaDesignerToolbar {
77
this._container = _container;
88
this._graph = _graph;
99
this._config = _config;
10+
this.buttons = new Map();
1011
this._toolbarDiv = document.createElement("div");
1112
this._container.appendChild(this._toolbarDiv);
1213
this._toolbarDiv.classList.add("sd-toolbar");
@@ -17,14 +18,31 @@ class SchemaDesignerToolbar {
1718
this._toolbarDiv.appendChild(button);
1819
button.classList.add("sd-toolbar-button");
1920
button.innerHTML = icon;
20-
button.onclick = callback;
21+
button.onclick = () => {
22+
if (!this.isButtonDisabled(title)) {
23+
callback();
24+
}
25+
};
2126
button.title = title;
2227
if (onDragEndCallback) {
2328
const dragImage = button.cloneNode(true);
2429
dragImage.style.backgroundColor = this._config.colors.toolbarBackground;
2530
const ds = mx_1.mxGraphFactory.mxUtils.makeDraggable(button, this._graph, onDragEndCallback, dragImage);
2631
ds.highlightDropTargets = true;
2732
}
33+
this.buttons.set(title, button);
34+
}
35+
disableButton(title) {
36+
var _a;
37+
(_a = this.buttons.get(title)) === null || _a === void 0 ? void 0 : _a.classList.add("sd-toolbar-button-disabled");
38+
}
39+
enableButton(title) {
40+
var _a;
41+
(_a = this.buttons.get(title)) === null || _a === void 0 ? void 0 : _a.classList.remove("sd-toolbar-button-disabled");
42+
}
43+
isButtonDisabled(title) {
44+
var _a;
45+
return (_a = this.buttons.get(title)) === null || _a === void 0 ? void 0 : _a.classList.contains("sd-toolbar-button-disabled");
2846
}
2947
addDivider() {
3048
const divider = document.createElement("div");

dist/tsconfig.tsbuildinfo

+1-1
Large diffs are not rendered by default.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "azdataGraph",
33
"description": "azdataGraph is a derivative of mxGraph, which is a fully client side JavaScript diagramming library that uses SVG and HTML for rendering.",
4-
"version": "0.0.96",
4+
"version": "0.0.97",
55
"homepage": "https://github.com/microsoft/azdataGraph",
66
"author": "Microsoft",
77
"license": "Apache-2.0",

src/ts/schemaDesigner/schemaDesigner.css

+5
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
align-items: center;
4848
}
4949

50+
.sd-toolbar-button-disabled {
51+
cursor: not-allowed;
52+
opacity: 0.5;
53+
}
54+
5055
.sd-toolbar-button:hover {
5156
background-color: var(--sd-toolbar-hover-background-color);
5257
}

src/ts/schemaDesigner/schemaDesigner.ts

+9
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,15 @@ export class SchemaDesigner {
641641
}
642642
}
643643
);
644+
this.toolbar.addDivider();
645+
this.toolbar.addButton(
646+
this.config.icons.exportIcon,
647+
"Export",
648+
() => {
649+
const schema = this.schema;
650+
this.config.publish(schema);
651+
}
652+
);
644653
}
645654
}
646655

src/ts/schemaDesigner/schemaDesignerInterfaces.ts

+5
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,11 @@ export interface SchemaDesignerConfig {
207207
* @param scale scale of the graph
208208
*/
209209
updateEditorPosition: (x: number, y: number, scale: number) => void;
210+
/**
211+
* Callback to publish the schema
212+
* @param model schema model
213+
*/
214+
publish: (model: ISchema) => void;
210215
}
211216

212217
/**

src/ts/schemaDesigner/schemaDesignerToolbar.ts

+21-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import { SchemaDesignerConfig } from "./schemaDesignerInterfaces";
44

55
export class SchemaDesignerToolbar {
66
private _toolbarDiv: HTMLElement;
7+
8+
public buttons: Map<string, HTMLElement> = new Map();
9+
710
constructor(private _container: HTMLElement, private _graph: mxGraph, private _config: SchemaDesignerConfig) {
811
this._toolbarDiv = document.createElement("div");
912
this._container.appendChild(this._toolbarDiv);
@@ -20,7 +23,11 @@ export class SchemaDesignerToolbar {
2023
this._toolbarDiv.appendChild(button);
2124
button.classList.add("sd-toolbar-button");
2225
button.innerHTML = icon;
23-
button.onclick = callback;
26+
button.onclick = () => {
27+
if (!this.isButtonDisabled(title)) {
28+
callback();
29+
}
30+
}
2431
button.title = title;
2532
if (onDragEndCallback) {
2633
const dragImage = button.cloneNode(true) as HTMLElement;
@@ -33,6 +40,19 @@ export class SchemaDesignerToolbar {
3340
);
3441
ds.highlightDropTargets = true;
3542
}
43+
this.buttons.set(title, button);
44+
}
45+
46+
public disableButton(title: string) {
47+
this.buttons.get(title)?.classList.add("sd-toolbar-button-disabled");
48+
}
49+
50+
public enableButton(title: string) {
51+
this.buttons.get(title)?.classList.remove("sd-toolbar-button-disabled");
52+
}
53+
54+
public isButtonDisabled(title: string) {
55+
return this.buttons.get(title)?.classList.contains("sd-toolbar-button-disabled");
3656
}
3757

3858
public addDivider() {

0 commit comments

Comments
 (0)