Skip to content

Commit e0e4bd6

Browse files
committed
Inspector improvements. Readme improvements. use gojs-angular 1.0.15.
1 parent 0e3e609 commit e0e4bd6

8 files changed

+40
-25
lines changed

README.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,27 @@ Check out the [Intro page on using GoJS with Angular](https://gojs.net/latest/in
77

88
It makes use of the [gojs-angular](https://github.com/NorthwoodsSoftware/gojs-angular) package to handle some boilerplate for setting up Diagram, Palette and Overview components.
99

10-
When running the sample, try moving around nodes, adding / deleting nodes, editing text in the inspector, relinking, undoing (Ctrl-Z), etc. within the diagram
11-
and you'll notice the changes are reflected in app-level data. You'll also notice that changes
10+
When running the sample, try moving around nodes, adding / deleting nodes, editing text in the inspector, relinking, undoing (Ctrl-Z), re-doing (Ctrl-Y), etc. within the diagram and you'll notice the changes are reflected in app-level data. You'll also notice that changes
1211
made in the inspector are reflected in the diagram.
1312

1413
## Installation
1514

16-
Start by running npm install to install all necessary dependencies.
15+
Start by running npm install to install all necessary dependencies.
16+
17+
If you do not have Angular already globally installed, you may do so by running:
18+
19+
### `npm i -g @angular/cli`
1720

1821
## Running the project
1922

2023
In the project directory, run:
2124

2225
### `ng serve`
2326

27+
Alternatively, if you do not have Angular installed globally, you may run:
28+
29+
### `npm run start`
30+
2431
Runs the app in the development mode.<br>
2532
Open [http://localhost:4200](http://localhost:4200) to view it in the browser.
2633

package-lock.json

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

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"@angular/platform-browser-dynamic": "~11.0.0",
2121
"@angular/router": "~11.0.0",
2222
"core-js": "^3.6.5",
23-
"gojs": "^2.1.27",
24-
"gojs-angular": "^1.0.13",
23+
"gojs": "^2.1.32",
24+
"gojs-angular": "^1.0.15",
2525
"rxjs": "^6.6.3",
2626
"tslib": "^2.0.0",
2727
"zone.js": "~0.11.2"

src/app/app.component.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ <h3>Links in app data</h3>
4040
<h3>Nodes in app data</h3>
4141
<ul>
4242
<li *ngFor="let nd of diagramNodeData">
43-
Node Key: {{nd.key}}, Color: {{nd.color}}
43+
Node Key: {{nd.key}}, Text: {{nd.text}}, Color: {{nd.color}}
4444
</li>
4545
</ul>
4646
</div>
4747

4848
<div class="clear left">
4949
<p>
50-
This Angular-GoJS sample demonstrates how to use the Diagram, Palette, and Overview Angular-GoJS components, made
50+
This <code>gojs-angular</code> sample demonstrates how to use the Diagram, Palette, and Overview <a href="https://www.npmjs.com/package/gojs-angular">gojs-angular</a> components, made
5151
and
5252
maintained by <a href="http://www.nwoods.com/">Northwoods Software</a>.
5353
</p>

src/app/app.component.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as _ from 'lodash';
77
selector: 'app-root',
88
templateUrl: './app.component.html',
99
styleUrls: ['./app.component.css'],
10-
encapsulation: ViewEncapsulation.None
10+
encapsulation: ViewEncapsulation.ShadowDom
1111
})
1212
export class AppComponent {
1313

@@ -31,7 +31,6 @@ export class AppComponent {
3131

3232
dia.commandHandler.archetypeGroupData = { key: 'Group', isGroup: true };
3333

34-
3534
const makePort = function(id: string, spot: go.Spot) {
3635
return $(go.Shape, 'Circle',
3736
{
@@ -62,7 +61,7 @@ export class AppComponent {
6261
new go.Binding('fill', 'color')
6362
),
6463
$(go.TextBlock, { margin: 8 },
65-
new go.Binding('text', 'key'))
64+
new go.Binding('text'))
6665
),
6766
// Ports
6867
makePort('t', go.Spot.TopCenter),
@@ -75,13 +74,13 @@ export class AppComponent {
7574
}
7675

7776
public diagramNodeData: Array<go.ObjectData> = [
78-
{ key: 'Alpha', color: 'lightblue', arr: [1, 2] },
79-
{ key: 'Beta', color: 'orange' },
80-
{ key: 'Gamma', color: 'lightgreen' },
81-
{ key: 'Delta', color: 'pink' }
77+
{ key: 'Alpha', text: "Node Alpha", color: 'lightblue' },
78+
{ key: 'Beta', text: "Node Beta", color: 'orange' },
79+
{ key: 'Gamma', text: "Node Gamma", color: 'lightgreen' },
80+
{ key: 'Delta', text: "Node Delta", color: 'pink' }
8281
];
8382
public diagramLinkData: Array<go.ObjectData> = [
84-
{ key: -1, from: 'Alpha', to: 'Beta', fromPort: 'r', toPort: '1' },
83+
{ key: -1, from: 'Alpha', to: 'Beta', fromPort: 'r', toPort: 'l' },
8584
{ key: -2, from: 'Alpha', to: 'Gamma', fromPort: 'b', toPort: 't' },
8685
{ key: -3, from: 'Beta', to: 'Beta' },
8786
{ key: -4, from: 'Gamma', to: 'Delta', fromPort: 'r', toPort: 'l' },
@@ -134,7 +133,7 @@ export class AppComponent {
134133
{ key: 'PaletteNode2', color: 'blueviolet' }
135134
];
136135
public paletteLinkData: Array<go.ObjectData> = [
137-
{ from: 'PaletteNode1', to: 'PaletteNode2' }
136+
{ }
138137
];
139138
public paletteModelData = { prop: 'val' };
140139
public paletteDivClassName = 'myPaletteDiv';

src/app/inspector/inspector.component.css

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
width: fit-content;
77
}
88

9+
p {
10+
padding: 0px;
11+
margin: 0px;
12+
}
13+
914
form {
1015
background: lightgray;
1116
border: 1px solid black;

src/app/inspector/inspector.component.html

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<form *ngIf='selectedNode' (ngSubmit)='onCommitForm()'>
2-
Key: {{ selectedNode.data.key }}
3-
Color: <input name='color' [(ngModel)]='data.color' />
2+
<p>Key: <input style="display: inline;" name='key' disabled [(ngModel)]='data.key' /></p>
3+
<p>Color: <input style="display: inline;" name='color' [(ngModel)]='data.color' /></p>
4+
<p>Text: <input style="display: inline;" name='text' [(ngModel)]='data.text' /></p>
45
<button type="submit">Commit</button>
56
</form>
67

src/app/inspector/inspector.component.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export class InspectorComponent {
1212
public _selectedNode: go.Node;
1313
public data = {
1414
key: null,
15-
color: null
15+
color: null,
16+
text: null
1617
};
1718

1819
@Input()
@@ -28,10 +29,12 @@ export class InspectorComponent {
2829
this._selectedNode = node;
2930
this.data.key = this._selectedNode.data.key;
3031
this.data.color = this._selectedNode.data.color;
32+
this.data.text = this._selectedNode.data.text;
3133
} else {
3234
this._selectedNode = null;
3335
this.data.key = null;
3436
this.data.color = null;
37+
this.data.text = null;
3538
}
3639
}
3740

0 commit comments

Comments
 (0)