You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 20, 2018. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+66-31Lines changed: 66 additions & 31 deletions
Original file line number
Diff line number
Diff line change
@@ -59,7 +59,7 @@ You need also init translations and animations module, because Tree needs it to
59
59
...
60
60
BrowserAnimationsModule,
61
61
TranslateModule.forRoot(),
62
-
TreeModule.forRoot(AppNodeService)
62
+
TreeModule.forRoot()
63
63
]
64
64
})
65
65
@@ -69,7 +69,7 @@ In any html file put
69
69
70
70
<ri-tree [treeModel]="treeModel"></ri-tree>
71
71
72
-
In component where you create tree, you should initialize_TreeModel_, remember that in configuration object, parameter _treeId_ should be the same as in _AppNodeService_ it allows to use proper API service in each instance of node.
72
+
In component where you create tree, you should create_TreeModel_ passing _configuration_ and _AppNodeService_.
73
73
74
74
export class MyTreeComponent implements OnInit {
75
75
public folders: Observable<ITreeData>;
@@ -88,15 +88,18 @@ In component where you create tree, you should initialize _TreeModel_, remember
88
88
public treeModel: TreeModel;
89
89
90
90
91
-
public constructor(private treeModelGenerator: TreeModelGeneratorService) {
91
+
public constructor(private treeInitializerService: TreeInitializerService,
If function _createTreeModel_ has got second parameter - array of nodes, then the tree will be marked as fully loaded. It will not use _load API_ function to get new subnodes it will use only passed nodes.
102
+
If function _init_ has got third parameter - array of nodes, then the tree will be marked as fully loaded. It will not use _load API_ function to get new subnodes it will use only passed nodes.
100
103
101
104
### CSS Styles
102
105
@@ -155,17 +158,24 @@ and _newItem.component.html_
<new-tree-item *ngFor="let child of children$ | async" [node]="child" [treeModel]="treeModel" [contextMenu]="contextMenu"></new-tree-item>
161
-
</div>
161
+
<div class="tree" *ngIf="isExpanded" [@expand]>
162
+
<ri-tree-item *ngFor="let child of children$ | async" [node]="child; trackBy: trackByFn"
163
+
[treeModel]="treeModel"
164
+
[isExpanded]="treeModel.isExpanded(child)"
165
+
[isSelected]="treeModel.isSelected(child)"
166
+
[contextMenu]="contextMenu"></ri-tree-item>
162
167
</div>
163
168
164
169
165
170
Then when you create tree component in your application use such construction
166
171
167
172
<rign-tree [treeModel]="treeModel">
168
-
<new-tree-item *ngFor="let node of treeModel.getRootNodes() | async" [node]="node" [treeModel]="treeModel" [contextMenu]="contextMenu"></new-tree-item>
173
+
<new-tree-item *ngFor="let node of treeModel.getRootNodes() | async; trackBy: trackByFn"
174
+
[node]="node"
175
+
[treeModel]="treeModel"
176
+
[isSelected]="treeModel.isSelected(node)"
177
+
[isExpanded]="treeModel.isExpanded(node)"
178
+
[contextMenu]="contextMenu"></new-tree-item>
169
179
</rign-tree>
170
180
171
181
and that is all. Please see Demo where is such example.
@@ -190,24 +200,24 @@ The _treeModel_ value is the same object that is used in _ri-tree_.
190
200
191
201
Using _ngrx/store_ you can listen on below actions and do whatever you want:
192
202
193
-
TreeActionsService.TREE_SAVE_NODE
194
-
TreeActionsService.TREE_SAVE_NODE_ERROR
195
-
TreeActionsService.TREE_SAVE_NODE_SUCCESS
196
-
TreeActionsService.TREE_DELETE_NODE
197
-
TreeActionsService.TREE_DELETE_NODE_ERROR
198
-
TreeActionsService.TREE_DELETE_NODE_SUCCESS
199
-
TreeActionsService.TREE_EDIT_NODE_START
200
-
TreeActionsService.TREE_EXPAND_NODE
201
-
TreeActionsService.TREE_LOAD
202
-
TreeActionsService.TREE_LOAD_ERROR
203
-
TreeActionsService.TREE_LOAD_SUCCESS
204
-
TreeActionsService.TREE_LOAD_PATH
205
-
TreeActionsService.TREE_MOVE_NODE
206
-
TreeActionsService.TREE_MOVE_NODE_ERROR
207
-
TreeActionsService.TREE_MOVE_NODE_SUCCESS
208
-
TreeActionsService.TREE_REGISTER
209
-
TreeActionsService.TREE_SET_ALL_NODES
210
-
TreeActionsService.TREE_SELECT_NODE
203
+
TreeActionTypes.TREE_SAVE_NODE
204
+
TreeActionTypes.TREE_SAVE_NODE_ERROR
205
+
TreeActionTypes.TREE_SAVE_NODE_SUCCESS
206
+
TreeActionTypes.TREE_DELETE_NODE
207
+
TreeActionTypes.TREE_DELETE_NODE_ERROR
208
+
TreeActionTypes.TREE_DELETE_NODE_SUCCESS
209
+
TreeActionTypes.TREE_EDIT_NODE_START
210
+
TreeActionTypes.TREE_EXPAND_NODE
211
+
TreeActionTypes.TREE_LOAD
212
+
TreeActionTypes.TREE_LOAD_ERROR
213
+
TreeActionTypes.TREE_LOAD_SUCCESS
214
+
TreeActionTypes.TREE_LOAD_PATH
215
+
TreeActionTypes.TREE_MOVE_NODE
216
+
TreeActionTypes.TREE_MOVE_NODE_ERROR
217
+
TreeActionTypes.TREE_MOVE_NODE_SUCCESS
218
+
TreeActionTypes.TREE_REGISTER
219
+
TreeActionTypes.TREE_SET_ALL_NODES
220
+
TreeActionTypes.TREE_SELECT_NODE
211
221
212
222
## Translation
213
223
@@ -240,7 +250,7 @@ where:
240
250
Then you have to create _@Effects_ similar to that one in _[treeEffects.service](src/store/treeEffects.service.ts)_or create only Observable and subscribe to it.
@@ -250,7 +260,7 @@ Then you have to create _@Effects_ similar to that one in _[treeEffects.service]
250
260
251
261
but you have to replace
252
262
253
-
.ofType(TreeActionsService.TREE_MOVE_NODE)
263
+
.ofType(TreeActionTypes.TREE_MOVE_NODE)
254
264
255
265
to
256
266
@@ -260,6 +270,19 @@ At the end do not forget to add this effects to your app.
260
270
261
271
## Changes
262
272
273
+
### v3.1.0
274
+
* change tree model initialize and injecting NodeService
275
+
* add NestJS server with new _TreeTwoNodeBackendService_ angular service to show how Tree works with real backend (details in _Demo_ section)
276
+
* actions and reducer
277
+
* change events from TreeActionService to TreeActionTypes (the first one will be removed in 4.0.0)
278
+
* rewrite actions from one class to many simpler classes
279
+
* create one type _TreeAction_ which cover all tree actions
280
+
* rewrite _TreeItemComponent_ - improved performance and reduce code
281
+
* move information about expanded nodes from _TreeItemComponent_ to _store_, these cause that _isExpanded_ is now _@Input()_ property for _TreeItemComponent_
282
+
*_TreeItemComponent_ has new _@Input()_ property _isSelected_
283
+
* small changes in expand animation
284
+
* fix issue - when add new node parent node was expanded but not loaded
285
+
263
286
### v3.0.2
264
287
* small fixes with interfaces
265
288
* fix export CSS styles
@@ -346,6 +369,18 @@ Working demo with _local storage_ you can find [here](https://qjon.github.io/ang
346
369
To run Demo locally clone this repository and run
347
370
348
371
npm start
372
+
373
+
If you would like to use demo with real API then you have to make small change.
374
+
In _demo/srx/app/treeTwo.component.ts_ change injection from _TreeTwoNodeService_ to _TreeTwoNodeBackendService_.
0 commit comments