Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Commit 4feee6c

Browse files
committed
Update readme & prepare working live demo
1 parent 6517ee0 commit 4feee6c

15 files changed

+106
-151
lines changed

.angular-cli.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
},
77
"apps": [
88
{
9-
"root": "demo/src",
10-
"outDir": "dist",
9+
"root": "./demo/src",
10+
"outDir": "./dist",
1111
"assets": [
1212
"assets",
1313
"favicon.ico"

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ apt:
1717
install:
1818
- npm i -g @angular/cli
1919
- npm i
20-
- ./node_modules/.bin/karma --config karma.conf.js start
20+
- npm test
2121

2222
before_install:
2323
- export CHROME_BIN=chromium-browser

README.md

Lines changed: 73 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,13 @@
11
# angular2-tree
22

3-
## Installation
4-
5-
npm i @rign/angular2-tree
6-
7-
## Changes
8-
9-
### v1.0.0
10-
11-
* use ngrx/store
12-
* remove events ITreeItemEvents - use Actions and Effects
13-
* remove NodeModel
14-
* simplify using tree
15-
16-
### v0.8.1
17-
18-
* fix package.json
19-
20-
### v0.8.0
21-
22-
* allow to create own template for tree item (if not specify it use default) - look in demo
23-
* input option _disableContextMenu_ to disable context menu (default: false)
24-
* update Demo - add alternative view of tree
25-
26-
### v0.7.0
27-
28-
* remove API config service (see section _Usage_)
29-
30-
### v0.6.2
31-
32-
* change name FolderService to NodeService
33-
* change params names from _dirId_ to _nodeId_
34-
* now you can use in your API paths parameter _{nodeId}_ which will be replaced on _nodeId_
35-
36-
### v0.6.1
37-
38-
* expose _ConfigService_ - it allow override urls for create, edit, and delete folder
3+
## Demo
394

40-
### v0.6.0
5+
Working demo with _local storage_ you can find [here](https://qjon.github.io/angular2-tree/).
416

42-
* upgrade angular/cli to version _beta.32.3_
43-
* fix demo
44-
45-
### v0.5.0
7+
## Installation
468

47-
* primary version with all features described below.
9+
npm i @rign/angular2-tree
10+
4811

4912
## Usage
5013

@@ -79,9 +42,10 @@ Create your own loader service as it is done in example
7942
}
8043
}
8144

82-
and use it to load data.
45+
and use it to load data. Or you can extend and rewrite all methods of that service to store your data wherever you want. See example _localStorage.service.ts_
46+
8347

84-
In component where you create tree you should register _tree store_, create _TreeModel_ and load root tree
48+
In component where you create tree, you should register _tree store_, create _TreeModel_ and load root tree
8549

8650
export class MyTreeComponent implements OnInit {
8751
public folders: Observable<ITreeData>;
@@ -177,16 +141,71 @@ Then when you create tree component in your application use such construction
177141

178142
and that is all. Please see Demo where is such example.
179143

180-
## Demo
144+
## Events(Actions)
145+
146+
Using _ngrx/store_ you can listen on below actions and do whatever you want:
147+
148+
TreeActionsService.TREE_SAVE_NODE
149+
TreeActionsService.TREE_SAVE_NODE_SUCCESS
150+
TreeActionsService.TREE_SAVE_NODE_ERROR
151+
TreeActionsService.TREE_DELETE_NODE
152+
TreeActionsService.TREE_DELETE_NODE_SUCCESS
153+
TreeActionsService.TREE_DELETE_NODE_ERROR
154+
TreeActionsService.TREE_EDIT_NODE_START
155+
TreeActionsService.TREE_EXPAND_NODE
156+
TreeActionsService.TREE_LOAD
157+
TreeActionsService.TREE_LOAD_SUCCESS
158+
TreeActionsService.TREE_LOAD_ERROR
159+
TreeActionsService.TREE_MOVE_NODE
160+
TreeActionsService.TREE_MOVE_NODE_SUCCESS
161+
TreeActionsService.TREE_MOVE_NODE_ERROR
162+
TreeActionsService.TREE_REGISTER
163+
164+
165+
## Changes
181166

182-
In folder _demo_ you can find application which use _TreeModule_
167+
### v2.0.0
168+
* use ngrx/store to store data
169+
* use actions and effects instead of events
170+
* add TravisCI configuration
171+
* remove backend example, move all functionality of demo to local storage
183172

184-
To run this example run in console:
185-
186-
* frontend
187-
188-
npm start
189-
190-
* backend (be sure that directory _demo/backend/data_ has permissions to write)
173+
### v1.0.0
174+
175+
* use ngrx/store
176+
* remove events ITreeItemEvents - use Actions and Effects
177+
* remove NodeModel
178+
* simplify using tree
179+
180+
### v0.8.1
181+
182+
* fix package.json
183+
184+
### v0.8.0
185+
186+
* allow to create own template for tree item (if not specify it use default) - look in demo
187+
* input option _disableContextMenu_ to disable context menu (default: false)
188+
* update Demo - add alternative view of tree
191189

192-
npm run backend
190+
### v0.7.0
191+
192+
* remove API config service (see section _Usage_)
193+
194+
### v0.6.2
195+
196+
* change name FolderService to NodeService
197+
* change params names from _dirId_ to _nodeId_
198+
* now you can use in your API paths parameter _{nodeId}_ which will be replaced on _nodeId_
199+
200+
### v0.6.1
201+
202+
* expose _ConfigService_ - it allow override urls for create, edit, and delete folder
203+
204+
### v0.6.0
205+
206+
* upgrade angular/cli to version _beta.32.3_
207+
* fix demo
208+
209+
### v0.5.0
210+
211+
* primary version with all features described below.

demo/proxy.config.example.json

Lines changed: 0 additions & 21 deletions
This file was deleted.

demo/src/app/app.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="row">
22
<div class="col-sm-6">
33
<h2>Basic tree</h2>
4-
<app-tree-three></app-tree-three>
4+
<app-tree-one></app-tree-one>
55
</div>
66
<div class="col-sm-6">
77
<h2>Tree with modified ItemComponent</h2>

demo/src/app/app.component.spec.ts

Lines changed: 0 additions & 32 deletions
This file was deleted.

demo/src/app/treeOne/treeOne.component.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
11
import {Component, OnInit} from '@angular/core';
2-
import {
3-
IConfiguration,
4-
IContextMenu,
5-
ITreeState,
6-
TreeActionsService,
7-
TreeModel,
8-
NodeDispatcherService
9-
} from '../../../../main';
2+
import {IConfiguration, IContextMenu, ITreeState, ITreeData, TreeActionsService, TreeModel, NodeDispatcherService} from '../../../../main';
103
import {Store} from '@ngrx/store';
114
import {Observable} from 'rxjs/Observable';
12-
import {ITreeData} from '../../../../src/store/ITreeState';
13-
import {NodeService} from '../../../../src/service/node.service';
145
import {TreeOneNodeService} from './treeOneNode.service';
156

167
@Component({
17-
selector: 'app-tree-three',
8+
selector: 'app-tree-one',
189
templateUrl: './treeOne.component.html'
1910
})
20-
export class TreeThreeComponent implements OnInit {
11+
export class TreeOneComponent implements OnInit {
2112
public folders: Observable<ITreeData>;
2213

2314
public contextMenu: IContextMenu[] = [];

demo/src/app/treeOne/treeOne.module.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ import {NgModule} from '@angular/core';
33
import {FormsModule} from '@angular/forms';
44
import {HttpModule} from '@angular/http';
55
import {TreeModule} from '../../../../main';
6-
import {TreeThreeComponent} from "./treeOne.component";
7-
import {TreeOneNodeService} from "./treeOneNode.service";
6+
import {TreeOneNodeService} from './treeOneNode.service';
7+
import {TreeOneComponent} from './treeOne.component';
88

99
@NgModule({
10-
declarations: [
11-
TreeThreeComponent
12-
],
13-
exports: [TreeThreeComponent],
10+
declarations: [TreeOneComponent],
11+
exports: [TreeOneComponent],
1412
imports: [
1513
BrowserModule,
1614
FormsModule,

demo/src/favicon.ico

-3.93 KB
Binary file not shown.

demo/src/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
<html>
33
<head>
44
<meta charset="utf-8">
5-
<title>Projects</title>
5+
<title>angular2-tree</title>
66
<base href="/">
77

88
<meta name="viewport" content="width=device-width, initial-scale=1">
99
<link rel="icon" type="image/x-icon" href="favicon.ico">
1010
</head>
1111
<body>
1212
<div class="container">
13-
<h1>Angular2 - Tree</h1>
13+
<h1>Angular2 - Tree v2.0.0</h1>
1414

1515
<app-root>Loading...</app-root>
1616
</div>

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "@rign/angular2-tree",
3-
"version": "1.0.0",
3+
"version": "2.0.0",
44
"license": "MIT",
55
"angular-cli": {},
66
"scripts": {
7-
"backend": "node demo/backend/index.js",
8-
"start": "ng serve --proxy-config demo/proxy.config.example.json"
7+
"start": "ng serve",
8+
"test": "./node_modules/.bin/karma --config karma.conf.js start",
9+
"gh-pages" : "ng build --env=prod --base-href \"https://qjon.github.io/angular2-tree/\" && ./node_modules/.bin/angular-cli-ghpages -b gh-pages --name=\"Rafał Ignaszewski\" --email=\"[email protected]\" --no-silent"
910
},
1011
"repository": {
1112
"type": "git",
@@ -40,15 +41,16 @@
4041
"@ngrx/store-devtools": "^3.2.4",
4142
"@types/jasmine": "2.5.38",
4243
"@types/node": "~6.0.60",
44+
"angular-cli-ghpages": "^0.5.1",
4345
"codelyzer": "~2.0.0-beta.4",
4446
"jasmine-core": "~2.5.2",
4547
"jasmine-spec-reporter": "~3.2.0",
4648
"karma": "~1.4.1",
4749
"karma-chrome-launcher": "~2.0.0",
4850
"karma-cli": "~1.0.1",
51+
"karma-coverage-istanbul-reporter": "^0.2.0",
4952
"karma-jasmine": "~1.1.0",
5053
"karma-jasmine-html-reporter": "^0.2.2",
51-
"karma-coverage-istanbul-reporter": "^0.2.0",
5254
"protractor": "~5.1.0",
5355
"ts-node": "~2.0.0",
5456
"tslint": "~4.4.2",

src/item/item.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class ItemComponent implements OnInit, AfterViewInit {
4545
public children$: Observable<IOuterNode[]>;
4646

4747

48-
private insert$: Observable<Action> = this.actions$
48+
protected insert$: Observable<Action> = this.actions$
4949
.ofType(TreeActionsService.TREE_INSERT_NODE)
5050
.filter((action: Action) => {
5151
return action.payload && action.payload === this.node.id;

src/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import {
1313
} from '@angular/platform-browser-dynamic/testing';
1414

1515
// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
16-
declare var __karma__: any;
17-
declare var require: any;
16+
declare const __karma__: any;
17+
declare const require: any;
1818

1919
// Prevent Karma from running prematurely.
2020
__karma__.loaded = function () {};

src/tree.component.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@ import {ITreeState} from './store/ITreeState';
1212
@Component({
1313
encapsulation: ViewEncapsulation.None,
1414
selector: 'rign-tree',
15-
templateUrl: 'tree.component.html',
16-
styleUrls: ['tree.component.less']
15+
templateUrl: './tree.component.html',
16+
styleUrls: ['./tree.component.less']
1717
})
1818
export class TreeComponent implements OnInit, OnChanges {
1919
@Input() treeModel: TreeModel;
2020

21-
@ViewChild('contextMenu')
22-
public contextMenu: ContextMenuComponent;
21+
@ViewChild('contextMenu') contextMenu: ContextMenuComponent;
2322

2423
/**
2524
* List of default options for context menu
@@ -46,8 +45,8 @@ export class TreeComponent implements OnInit, OnChanges {
4645
*/
4746
public menuList: IContextMenu[] = [];
4847

49-
public constructor(private store: Store<ITreeState>,
50-
private treeActions: TreeActionsService,
48+
public constructor(protected store: Store<ITreeState>,
49+
protected treeActions: TreeActionsService,
5150
protected dragAndDrop: DragAndDrop) {
5251

5352
}
@@ -93,7 +92,7 @@ export class TreeComponent implements OnInit, OnChanges {
9392
/**
9493
* Register node "move event"
9594
*/
96-
private registerMove(): void {
95+
protected registerMove(): void {
9796
if (this.treeModel.configuration.disableMoveNodes) {
9897
return;
9998
}

0 commit comments

Comments
 (0)