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

Zoom level drop down box not functional in Gantt diagram #1909

Open
grypho opened this issue Jul 5, 2019 · 10 comments
Open

Zoom level drop down box not functional in Gantt diagram #1909

grypho opened this issue Jul 5, 2019 · 10 comments

Comments

@grypho
Copy link
Contributor

grypho commented Jul 5, 2019

In the gantt diagrams there is a zoomlevel drop-down list (Year, Quarter, Month, Week, Day).
At least in my used Browsers (recent FF, Chrome) nothing happens when I change the zoom level. (Maybe related to #372 )

Can anyone confirm that issue in the current git version?

@grypho
Copy link
Contributor Author

grypho commented Jul 5, 2019

Issue is not related to version of jQuery. Same behaviour with jQuery 3.x

@grypho
Copy link
Contributor Author

grypho commented Aug 2, 2019

After some investigation using the non-minified zk library it seems that a rendering operation of the drop-down box (select tag) unregisters the _zoomLevelChanged handler. So far I'm not sure why the component is rendered again and how the event handler can be re-attached (it's eleven years old code). I doubt this effect was introduced by an update of the zk library as our Planner does extend these components.

@grypho
Copy link
Contributor Author

grypho commented Aug 14, 2019

Update on this topic after several hours of debugging. It looks like the Java class (TimeTrackerComponent) which is linked to the TimeTracker UI component gets destructed for some reason.

(1) Initially when the site is built, an instance of TimeTrackerComponent is being created and registers an IZoomLevelChangedListener. That listener is called by TimeTracker.fireZoomChanged() after the compose process and sets the initial zoom to the right level. (all steps verified by additional profiling log entries).

(2) When I change the zoom level later by selecting another item in the drop-down box, the method TimeTracker.fireZoomChanged() which fires the event again. Within the method, the method zoomListeners.fireEvent is called which should iterate all registered handlers. In the begining of that method another method getActiveListeners is called to retrieve a list of active handlers. There all registered handlers are checked if they are null (=> they are removed from the handler list) or not null (=> they are returned by getActiveListeners). Sadly, the former registered TimeTrackerComponent callback is null at this point and is being removed from the list and never called again.

I do not have enough experience in Java but I think, the TimeTrackerComponent (or at least the event Handler) is being destructed by the garbage collector for some reason between (1) and (2). Any Ideas how to track it down?

@grypho
Copy link
Contributor Author

grypho commented Oct 16, 2019

This issue has the same cause as #406. Issue 406 adresses only the Advance assignment window but the issue also happens on every other window which uses the GanttPlanner component and where the zoom can be changed.

@grypho
Copy link
Contributor Author

grypho commented Oct 16, 2019

Update on this topic after some more hours of debugging, stack dumping and investigating.

On Aug 14 my assumption (2) was not correct at all. When a GanttPanel component (the charting area where Tasks, Dependencies, ... are being drawn) is instanciated, two instances which derive from TimeTrackerComponent will be created:

  • A normal TimeTrackerComponent instance as part of the GanttPanel (GanttPanel.java):
    private TimeTrackerComponent timeTrackerComponent; This component is responsible for the white/gray background on worksdays/weekend in the GanttPanel where Tasks/Milestones/Dependencies/... are being drawn.
  • A TimeTrackerWithoutColumns instance as part of the Planner (Planner.java):
    `TimeTrackerComponent timetrackerheader = new TimeTrackerComponentWithoutColumns(ganttPanel.getTimeTracker(), "timetrackerheader");
    which is responsible for the header part with months/days/...

Both components do exist at the same time. For some reason (I think the garbage collector is involved) their registered callbacks IZoomLevelChangedListener (Constructor of TimeTrackerComponent) is destructed (maybe a combination of delta expression and WeakReference?). Nevertheless when I store all instances of TimeTrackerComponent in a List and call the method zoomChanged manually the behavior of the Gantt component is as expected and the zoom works fine.

I'll continue investigating the GC+Weak assumption and will provide a pull request afterwards.

kwoot added a commit that referenced this issue Oct 16, 2019
Bugfix: #1909 Zoom level issue solved
@j-arnott
Copy link
Contributor

In the plannerLayout.zul I had to change the zoom listbox code to:

<listbox id="listZoomLevels" mold="select" rows="1" model="${planner.zoomLevels}" onSelect="planner.setZoomLevel(self.selectedItem.value,1);" />

Not sure what the scroll left arg does.

@tramseyer
Copy link
Collaborator

In the plannerLayout.zul I had to change the zoom listbox code to:

<listbox id="listZoomLevels" mold="select" rows="1" model="${planner.zoomLevels}" onSelect="planner.setZoomLevel(self.selectedItem.value,1);" />

Not sure what the scroll left arg does.

Works for me as well.

@kwoot
Copy link
Contributor

kwoot commented Sep 27, 2021

Can somebody make a PR that I can accept?

j-arnott added a commit to j-arnott/libreplan-2.x that referenced this issue Sep 27, 2021
For Bug LibrePlan#1909
Need that onSelect.
@kwoot
Copy link
Contributor

kwoot commented Sep 30, 2021

PR merged. Would be nice if somebody can confirm it works, cause I am currently swamped with work. (sorry).

@tramseyer
Copy link
Collaborator

PR merged. Would be nice if somebody can confirm it works, cause I am currently swamped with work. (sorry).

Its work for me.

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

No branches or pull requests

4 participants