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

Cleaning up publisher/plugin/mapmodule interaction #2164

Merged
merged 31 commits into from
Mar 13, 2023

Conversation

ZakarFin
Copy link
Member

@ZakarFin ZakarFin commented Mar 10, 2023

Includes commits from #2156

Notes for future self:

Entering publisher:

  1. Sends UIChangeEvent with param publisher2 to notify other functionalities that they should clean up the UI
  2. When editing: sets the app state with StateHandler.SetStateRequest
  3. Stops and unregisters all mapmodule plugins where hasUI() returns true (keeps track of these for resuming after publisher as sidebar.normalMapPlugins)
  4. Fetches all Tool classes, calls Oskari.clazz.create() and filters out any where tool.isDisplayed(data) != true

Exiting publisher:

  1. calls stop() for each "panel" (==accordion component). The panels are responsible for tearing down anything they changed during use of the publisher functionality. For example the "PanelMapTools" will in turn call stop() for each of the publisher tools that are then responsible for tearing down anything they have set up during the use of publisher functionality. The tools can in turn call plugin.stop() which should tear down a plugin that the tool has initialized.
  2. Restores any plugins that were "stashed" in sidebar.normalMapPlugins during startup

Note! Publisher2.ToolEnabledChangedEvent is used by AbstractPluginTool.setEnabled() to notify the app that a tool has been enabled/disabled. This is only used to notify the PanelToolLayout that any tools that are activated during the "drag and drop" of plugins between plugin containers should start in the dragging mode or stop the dragging mode on disable.

Removed:

  • tool.isShownInToolsPanel() as this was not used in a meaningful way where isDisplayed() could not be used.
  • tool.isDisplayedInMode() as this was not used at all
  • tools panel setMode() as this was not used
  • myplaces/drawing related code for embedded maps tools as this hasn't been re-implemented after OL2 departure
  • duplicated Publisher2.ToolEnabledChangedEvent sent on setEnabled() as render() is called right after that sends these again (see 4 above)
  • Tools no longer receive references to publisher instance or handlers in panel tools. These were not used and instance was only used to reference localization that was already available to tools in another constructor param.
  • sidebar._disablePreview() no longer stops plugins as any plugins started by publisher tools should be cleaned up by the tools stop() function that is called when publisher is exited

The tool API:

  • isDisplayed() is used to detect if tool should be shown as a selection to user. This might be false if we don't want the user to be able to disable something like the "terms of use" plugin. It can still be shown on the map and dragged to different plugin containers.
  • isDisabled() if true the selection is shown to the user but it is disabled. There should be a tooltip shown to the user instructing why the tool is disabled
  • isEnabled() if the tool is activated (checkbox checked for the tool)
  • setEnabled() the tool should initialize the plugin on the map corresponding to the tool. This is implemented in AbstractPluginTool and works for many of the tool choices. Should send on Publisher2.ToolEnabledChangedEvent
  • stop() should stop and clean out the plugin the tool is controlling (closing any additional popups etc)
  • getExtraOptions() should return a jQuery reference that presents any extra options that the tool offers to the user.

@ZakarFin ZakarFin marked this pull request as ready for review March 13, 2023 15:22
@ZakarFin ZakarFin added this to the 2.11.0 milestone Mar 13, 2023
@ZakarFin ZakarFin merged commit 9ae633e into oskariorg:develop Mar 13, 2023
@ZakarFin ZakarFin deleted the maprotator-publisher branch March 13, 2023 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant