Coder Social home page Coder Social logo

zicrael / ngx-tree-dnd Goto Github PK

View Code? Open in Web Editor NEW
39.0 4.0 11.0 1.76 MB

Angular 7 support, data sortable draggable smart tree.

Home Page: https://ngx-tree-dnd.stackblitz.io

License: MIT License

JavaScript 5.53% TypeScript 77.01% CSS 5.15% HTML 12.31%
dnd tree-dnd tree-structure angular-tree tree-component angular-tree-component ngx-tree-dnd data-tree angular-data-tree data-sortable

ngx-tree-dnd's People

Contributors

manish-jain-alept avatar njofce avatar snyk-bot avatar zicrael avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ngx-tree-dnd's Issues

Is there any way to get node level in the tree ?

Hi @Zicrael, I am using this plugin in one of my app and I want to add a dropdown instead of input at a particular level. Is there any option, that I can get the selected node level in the event while adding or renaming node. So, that I can do my stuff based on node level.

Is there a way to disable drag on my items?

Looks like a very nice tree, but I didn't see a way to mark some items (ie my top level folders) so that they can be locked and not dragged. I realize I could disallow the drop, but this would be a better user experience.

How to drag and drop an element between two trees ?

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Unable load SVG in production build while using ngx tree dnd

I have follow same step to resolve this issue as mentioned in this closed issue #46 but i am still not able to resolve this.

I am using <lib-ngx-tree-component [treeData]='youTree' (ondragend)='onDragEnd($event)'> in my component and i have also import the fortawesome in my module and component but still i don't know where we use this import fortawesome(import { faEdit,faMinus,faPlus,faTimes } from '@fortawesome/free-solid-svg-icons';) because i am using <lib-ngx-tree-component [treeData]='youTree' (ondragend)='onDragEnd($event)'> instead of <fa-icon [icon]="faCoffee">.

So, Please provide more clarity to resolve this issue.

How can I call an event when delete button is clicked?

Hi @Zicrael , This one is similar to an earlier issue I raised #16 . This time I would like you to provide two separate events when delete button is clicked.

Basically, I would like to ask for confirmation before a node is removed from the tree, so a (onStartDeleteItem) and (onFinishDeleteItem) events would be great!.

Thanks,

Can't Find Component

Describe the bug
A clear and concise description of what the bug is.
When I use the directive, it can't find the component

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
    Chrome
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.
core.js:1673 ERROR Error: Uncaught (in promise): Error: Template parse errors:
Can't bind to 'treeData' since it isn't a known property of 'ngx-tree-component'.

  1. If 'ngx-tree-component' is an Angular component and it has 'treeData' input, then verify that it is part of this module.
  2. If 'ngx-tree-component' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
  3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("

<ngx-tree-component [ERROR ->][treeData]='youTree'>

<ion-content (onload)="testFunc()">
"): ng:///HomePageModule/HomePage.html@12:20
'ngx-tree-component' is not a known element:

  1. If 'ngx-tree-component' is an Angular component, then verify that it is part of this module.
  2. If 'ngx-tree-component' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("

[ERROR ->]<ngx-tree-component [treeData]='youTree'>

<ion-content (onload)="testFunc()">
"): ng:///HomePageModule/HomePage.html@12:0
Error: Template parse errors:
Can't bind to 'treeData' since it isn't a known property of 'ngx-tree-component'.

  1. If 'ngx-tree-component' is an Angular component and it has 'treeData' input, then verify that it is part of this module.
  2. If 'ngx-tree-component' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
  3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("

<ngx-tree-component [ERROR ->][treeData]='youTree'>

<ion-content (onload)="testFunc()">
"): ng:///HomePageModule/HomePage.html@12:20
'ngx-tree-component' is not a known element:

  1. If 'ngx-tree-component' is an Angular component, then verify that it is part of this module.
  2. If 'ngx-tree-component' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("

[ERROR ->]<ngx-tree-component [treeData]='youTree'>

<ion-content (onload)="testFunc()">
"): ng:///HomePageModule/HomePage.html@12:0
at syntaxError (compiler.js:1016)
at TemplateParser.push../node_modules/@angular/compiler/fesm5/compiler.js.TemplateParser.parse (compiler.js:14813)
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._parseTemplate (compiler.js:24000)
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileTemplate (compiler.js:23987)
at compiler.js:23930
at Set.forEach ()
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileComponents (compiler.js:23930)
at compiler.js:23840
at Object.then (compiler.js:1007)
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileModuleAndComponents (compiler.js:23839)
at syntaxError (compiler.js:1016)
at TemplateParser.push../node_modules/@angular/compiler/fesm5/compiler.js.TemplateParser.parse (compiler.js:14813)
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._parseTemplate (compiler.js:24000)
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileTemplate (compiler.js:23987)
at compiler.js:23930
at Set.forEach ()
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileComponents (compiler.js:23930)
at compiler.js:23840
at Object.then (compiler.js:1007)
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileModuleAndComponents (compiler.js:23839)
at resolvePromise (zone.js:814)
at resolvePromise (zone.js:771)
at zone.js:873
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:3815)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188)
at drainMicroTaskQueue (zone.js:595)

How to set custom button only for child?

How to set right side menu popup like (...) and when on click (...) this menu open dialog for rename/delete option only for child. basically i want drag and drop menu like https://todoist.com

we want also custom button and its custom function can we get it.?

onAddItem doesn't work

Describe the bug
when onAddItem event triggers returns wrong parentList

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://stackblitz.com/edit/ngx-tree-dnd
  2. make a console.log(event) in line 71.
  3. Click on add new item button in front of Iphone item.
  4. See console that shows the google play as parent not the apple item.

How to pass dynamic data to the tree using services ?

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

checkTreeLength bug

For empty treeStorage there is TypeError which breaks tree render.

TypeError: Cannot read property 'options' of undefined at NgxTreeService.push../node_modules/ngx-tree-dnd/fesm5/ngx-tree-dnd.js.NgxTreeService.checkTreeLength (ngx-tree-dnd.js:840) at Observable._subscribe (ngx-tree-dnd.js:75) at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable._trySubscribe (Observable.js:42) at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe (Observable.js:28) at NgxTreeParentComponent.push../node_modules/ngx-tree-dnd/fesm5/ngx-tree-dnd.js.NgxTreeParentComponent.getTreeData (ngx-tree-dnd.js:1057) at NgxTreeParentComponent.set [as treeData] (ngx-tree-dnd.js:941) at updateProp (core.js:22207) at checkAndUpdateDirectiveInline (core.js:21962) at checkAndUpdateNodeInline (core.js:23265) at checkAndUpdateNode (core.js:23227)

NgxTreeService.checkTreeLength method has wrong IF statement. For empty treeStorage (0 is smaller then 2) code tries to read first array item which is non existing by index of zero.

if (this.treeStorage.length < 2) { this.treeStorage[0].options.showDeleteButton = false; } else { try { for (var _b = __values(this.treeStorage), _c = _b.next(); !_c.done; _c = _b.next()) { var el = _c.value; if (el && el.options) { el.options.showDeleteButton = true; } } } catch (e_7_1) { e_7 = { error: e_7_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_7) throw e_7.error; } } }

Possible fix could be?

if (this.treeStorage.length == 0) { // do nothing } else { // no need to remove delete button // if (this.treeStorage.length == 1) { // this.treeStorage[0].options.showDeleteButton = false; // } ...

Package version
"ngx-tree-dnd": "^2.5.0"

How to add more fields to TreeModel interface

Hı,

How can I possibly add more fields to TreeModel interface:-

export interface TreeModel {
name: string;
id: number;
code: string;
translateId: string;

options?: TreeItemOptions;
childrens: TreeModel[]; // childrens list
}

and also should show in the view, or maybe add beforeAddItemEvent that can be bind to, by so doing the developer can raise maybe a dialog modal form for data entry for the selected ITEM-ID.

please help.

Thanks in advance.

onDeleteItem(event) does not work

Hi Yaroslav, My problem is ;
When I clicked onDeleteItem(event) button it give me wrong items id for example ;

--> element: {id: 90, name: "iiiii", orderNo: 0, parentCategoryId: null, options: {…}, …}
when I clicked on delete button in child items, it return id:90 when ı clicked id:93 it return id:90 .
it gives me same result with whole clicks
So how can ı fix this ?

thanks,
Ayyildiz

Fix base config

''ERROR TypeError: Cannot read property 'enableDragging' of null".

root

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Unable load SVG in production build

Describe the bug
SVG icon unable to load in production mode in angular

To Reproduce
Steps to reproduce the behavior:

  1. Make demo from https://stackblitz.com/edit/ngx-tree-dnd
  2. ng build --prod to make build production
  3. run application on browser(any)
  4. there are not able to see plus,minus,delete button in tree view

Expected behavior
when i see in production build there are missing icon of font-awesome which are useful to manage child and parent of tree.
in console showing to many errors for each icons like :
FontAwesome: Could not find icon with iconName=plus and prefix=fas

Screenshots
Screenshot from 2019-04-12 11-32-34
Screenshot from 2019-04-12 11-33-32

How can I call an event when edit button is clicked?

I see you have provided (onrenameitem) event, which triggers once the user has updated the node in the tree and clicked on the check mark.

But, can we have an event when the edit button is clicked, because I would like to open a new page when we click on edit button.
Thanks.

bug with "onFinishDeleteItem" event

Describe the bug
when we click on delete icon(x) and call "onFinishDeleteItem" event the node not removing from myTree variable

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'application'
  2. Click on 'delete icon and "onFinishDeleteItem" event'
  3. See error like myTree variable not updating with deleted node

Expected behavior
i want myTree variable with updated data when click on delete icon (x)

Desktop (please complete the following information):

  • OS: [e.g. Windows]
  • Browser [chrome]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.