Skip to content

Commit

Permalink
Merge pull request #12 from Zicrael/dev-branch
Browse files Browse the repository at this point in the history
fix onremoveitem issue
  • Loading branch information
Zicrael authored Nov 29, 2018
2 parents b224e65 + ed4e4ac commit 4dae479
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
4 changes: 3 additions & 1 deletion projects/ngx-tree-dnd/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-tree-dnd",
"version": "2.3.1",
"version": "2.3.2",
"repository": {
"type": "git",
"url": "https://github.com/Zicrael/ngx-tree-dnd"
Expand All @@ -11,12 +11,14 @@
},
"keywords": [
"angular" ,
"treeview",
"angular-tree",
"angular-tree-dnd",
"anuglar-sortable-dnd",
"tree-view",
"tree-component",
"tree-links",
"tree-dnd",
"data-tree",
"ngx-tree-dnd",
"ngx-sortable-dnd",
Expand Down
8 changes: 4 additions & 4 deletions projects/ngx-tree-dnd/src/lib/ngx-tree-dnd.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ export class NgxTreeService {
element: createObj,
parentList: this.selectedElement
};
this.onAddItem.next(eventEmit);
this.elementFinder(this.treeStorage, parent.id);
this.selectedElement.childrens.push(createObj);
this.clearAction();
this.onAddItem.next(eventEmit);
}

/*
Expand All @@ -128,16 +128,16 @@ export class NgxTreeService {
Emit onRemoveItem Subject.
*/
public deleteItem(id) {
this.elementFinder(this.treeStorage, id);
const eventEmit = {
element: this.selectedElement,
parentList: this.listOfSelectedElement
};
this.elementFinder(this.treeStorage, id);
this.onRemoveItem.next(eventEmit);
const i = this.listOfSelectedElement.indexOf(this.selectedElement);
this.listOfSelectedElement.splice(i, 1);
this.clearAction();
this.checkTreeLength();
this.onRemoveItem.next(eventEmit);
}

/*
Expand All @@ -152,11 +152,11 @@ export class NgxTreeService {
element: this.selectedElement,
parentList: this.listOfSelectedElement
};
this.onRenameItem.next(eventEmit);
// code
this.selectedElement.name = name;
this.selectedElement.options.edit = false;
this.clearAction();
this.onRenameItem.next(eventEmit);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--The content below is only a placeholder and can be replaced.-->
<div>
<lib-ngx-tree-component [treeData]='myTree' (ondrop)='onDrop($event)' [config]='config'>
<lib-ngx-tree-component [treeData]='myTree' (ondrop)='onDrop($event)' (onremoveitem)='onDelete($event)' (onadditem)='onadditem($event)' [config]='config'>
</lib-ngx-tree-component>
</div>

9 changes: 9 additions & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Component } from '@angular/core';
styleUrls: ['./app.component.css']
})
export class AppComponent {
constructor() {}
config = {
showActionButtons: true,
showAddButtons: true,
Expand Down Expand Up @@ -75,4 +76,12 @@ export class AppComponent {
console.log(this.myTree);
console.log(event);
}
onDelete(event) {
console.log(this.myTree);
console.log(event);
}
onadditem(event) {
console.log(this.myTree);
console.log(event);
}
}

0 comments on commit 4dae479

Please sign in to comment.