Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option that prevents tasks to overlap #19

Open
fabiiomiiguel opened this issue Jan 14, 2021 · 16 comments
Open

Add an option that prevents tasks to overlap #19

fabiiomiiguel opened this issue Jan 14, 2021 · 16 comments
Labels
enhancement New feature or request

Comments

@fabiiomiiguel
Copy link

fabiiomiiguel commented Jan 14, 2021

Maybe it will be nice to have an optional prop, for when a task is dragged, move the overlapped task forward or backward.

@fabiiomiiguel fabiiomiiguel changed the title Add an option that allows tasks not to overlap Add an option that prevents tasks to overlap Jan 14, 2021
@ANovokmet
Copy link
Owner

Sounds nice. If we do this on task "drop", at first it looks like it should not be too complex. But when you take a case where there's a bunch of tasks one next to another it becomes more complex. Do you move only the first task or chain move all the tasks...

Do you have a use case for this? It might be too specific, and it could be implemented without changing svelte-gantt.

@ANovokmet ANovokmet added the enhancement New feature or request label Jan 14, 2021
@fabiiomiiguel
Copy link
Author

My use case is that I have orders for some driver to deliver, but of course he can't make two orders at the same time. So when a new order (task) is dragged to one driver, this new task should not override others and should go forward or backward.

@ANovokmet
Copy link
Owner

ANovokmet commented Jan 22, 2021

I suggest you try to implement it using events. On task dropped read their data and correct their times if needed. Then if it works well we could include it within the library. So basically:

  1. subscribe to task gantt.api.tasks.on.changed((task) => ... ); event.
  2. use the updated task time with the rest of your data and check for overlaps
  3. update Gantt data with gantt.$set({tasks});

I think the biggest challenge here is to update data so there are positively no overlaps.

#7 (comment) also asked if there's a way to move conflicted tasks so maybe it's a more desirable feature than I think.

@fabiiomiiguel
Copy link
Author

Yes I know, I was doing that on my side, another cool feature is to set the min and max resize time of one task, like min 1 hour, and we couldn't resize the task below than one hour

@fabiiomiiguel
Copy link
Author

Another thing that I do on my side of the code and could be nice exists by default, is to delete a task from the gantt with a inner button

@ghost
Copy link

ghost commented Jan 30, 2021

@ANovokmet Relating to overlapping events, it'd be nice if for example Row 1 has two overlapping tasks, the overlapping task is displayed below the first task. So in the same row...but the row gets bigger (in height) and the overlapping task(s) is displayed in the same row but below the first task instead of being hidden behind it. Is this possible to implement please?

@ANovokmet
Copy link
Owner

ANovokmet commented Feb 2, 2021

@ANovokmet the overlapping task is displayed below the first task. So in the same row...but the row gets bigger (in height) and the overlapping task(s) is displayed in the same row but below the first task instead of being hidden behind it. Is this possible to implement please?

@darekeapp this is something I've had in mind but I doubt It will anytime soon be implemented since it is a big feature, and pretty much just a cosmetical one. If someone could help devise an algorithm that organizes a number of tasks into a minimal number of rows so they do not overlap anywhere, just how you described, that would be at least half of the work done. Once again, it sounds good and something I've thought about.

@fabiiomiiguel these sound like good features. Maybe you could open up feature requests so they are more easily tracked. For now we have

  • Automatic overlap resolution
  • Task specific magnetUnit and magnetAmount
  • To delete a task with an inner button. We could display a popup or a context menu on right-click and display some additional options, like delete task. It would be pretty good and similar to some licensed gantt libraries.

@ghost
Copy link

ghost commented Feb 3, 2021

@ANovokmet Relating to right clicking to display context menu, the tasks could also have on hover which displays a box which contains details about the task e.g. from and to, or any other additional notes.

@ghost
Copy link

ghost commented Feb 14, 2021

@ANovokmet Could you please show how to set the min and max resize time of one task? What I am trying to achieve is not only that the tasks do NOT get resized if min and/or max limit reached, but also they CAN be moved around as they are still fulfilling the requirements of the min and max times.

UPDATE: I have tried to on gantt.current.api.tasks.on.change, find the difference between from and to time, and set enableDragging to false, but this has problems. First, if the min requirement is 20 minutes, the task should still be able to be extended (increased in length) and moved, just not decreased further. Moreover, I have tried to use gantt.current.api.tasks.move to make sure this is happening when/during the user is dragging the task, but it does not seem to log anything, does that event listener work?

@fabiiomiiguel How are you implementing this at your end please?

@fabiiomiiguel
Copy link
Author

Sorry I was a bit busy, this weekend I will put here some examples, ok?

@nguyenhuuthinh111
Copy link

@fabiiomiiguel can you sharing the code for the mode delete task? Please I need it for the my project. Thanks

@fabiiomiiguel
Copy link
Author

@darekeapp @nguyenhuuthinh111 I didn't post any code yet, because I leave the project where I did that. I will need some time to create that.

@nguyenhuuthinh111
Copy link

@fabiiomiiguel Thank for respone. So Can someone help me do this? Becasue I'm using grantt-chart for my project.

@acivgin
Copy link

acivgin commented May 18, 2021

@ANovokmet Hi man is it possible to implement a new event on mouseover. In my case should display a kind of tooltip with some data. Any suggestion? I would like to bind (mouseover)="showTooltip ($event)"

@HariSankarNayak
Copy link

@ANovokmet the overlapping task is displayed below the first task. So in the same row...but the row gets bigger (in height) and the overlapping task(s) is displayed in the same row but below the first task instead of being hidden behind it. Is this possible to implement please?

@darekeapp this is something I've had in mind but I doubt It will anytime soon be implemented since it is a big feature, and pretty much just a cosmetical one. If someone could help devise an algorithm that organizes a number of tasks into a minimal number of rows so they do not overlap anywhere, just how you described, that would be at least half of the work done. Once again, it sounds good and something I've thought about.

@fabiiomiiguel these sound like good features. Maybe you could open up feature requests so they are more easily tracked. For now we have

  • Automatic overlap resolution
  • Task specific magnetUnit and magnetAmount
  • To delete a task with an inner button. We could display a popup or a context menu on right-click and display some additional options, like delete task. It would be pretty good and similar to some licensed gantt libraries.

@ANovokmet can you add delete a task option. or is it there? how can I achieve it?

@kaigr
Copy link

kaigr commented Feb 23, 2024

@fabiiomiiguel , just yesterday, I implemented a routine (in my own code) for moving overlapping tasks into a new resourceId, or, if the overlapping task can go into a resourceId previously created without overlapping there, then re-use that one. Then today I stumbled across your change request :-) I'm using svelte-grid as a means to define 'seasons' within rows that represent 'catagories' (for example, city pairs for air travel: different city pairs can have very different seasonalities throughout the year).
My use-case is a little long-winded to explain, but suffice to say that the very first time my app containing svelte-grid is used, all the legacy date ranges that the user has created in another system are dumped into a single row that has the name "uncategorized". This is because in the legacy system there's not equivalent concept to "row" (what I call "category" here). Part of the set-up experience for the user moving forward is to organise the date ranges into correctly-named rows/categories using svelte-grid, but it was very difficult to do that when so many tasks were overlapped on top of each other in the beginning. That's where my routine to split them up came in: to split the tasks up into a minimum number of resource Id's so that no overlapping of tasks exists... then the user has an easier time moving them around/renaming, etc. Happy to share code of the routine if this sounds something like what you need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants