[Vue] add manage goals store to share loaded idGoal with plugin components that extend goal management #19236
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
Plugins can extend goal management with their own components. Each component provided by a plugin has to access the currently edited goal's ID. W/ angularjs this was done by looking for the manage goals root HTML element and getting the "show-goal" attribute, which was previously used to initiate an angularjs directive. This PR changes the system to use a store. ManageGoals sets a value in the store, and other components can read it at any given time. Vue's watch() method can be used to watch the idGoal if needed.
PiwikApiMock is also exported as it's used in an event and having the type is useful for the TypeScript migrations of some premium features. (It will still be removed in Matomo 5.)
Other changes (related to funnels):
.checked
property change before emitting a model value change, so the parent component can decide whether it goes through. I had thought vue would do this itself since in this case the modelValue wouldn't match what the template sets it to, but I think since the value doesn't change, Vue doesn't initiate change detection and nothing happens, leaving the DOM value toggled. This would allow, for example, showing a modal when unchecking a checkbox to ask if the user is sure (which is done in Funnels when attempting to deactivate a funnel).Review