@spacenate opened this Pull Request on October 24th 2017 Contributor

Fixes #12162

Hello! In this change:

  • Added a new protected method getLongPrettyDate to Piwik\Plugin\Controller.
  • Added a new public method getDateString to Piwik\Plugins\CoreHome\Controller.
  • Added a new XHR request to the calendar.js module in CoreHome, to get a new "long pretty date string" when the user has updated the date or range.

In calendar.js, the logic to fetch new string/update page title has been appended to propagateNewUrlParams, but in retrospect this would be better in its own function, perhaps still invoked from propagateNewUrlParams? (done)

In Piwik\Plugin\Controller, the logic inside getLongPrettyDate is currently is copy/pasted from setGeneralVariablesView. I tried to tease apart the duplicated logic, but it started to become a time sink so I wanted to seek feedback on this approach before spending further time de-duplicating this logic.

Your thoughts?

@spacenate commented on October 24th 2017 Contributor

Huh, okay - I got my branch updated, no conflicts when merging upstream/master (as outlined in your Contributing to Piwik Core guide).

Shouldn't I be merging upstream/3.x-dev instead though? Quite the conflict there! :) It looks like I should be working in the AngularJS PeriodSelectorController now.

@sgiehl commented on October 24th 2017 Member

Actually we use 3.x-dev as our master branch, so yes, please rebase your changes on 3.x-dev instead of on master

@spacenate commented on October 27th 2017 Contributor

Rebased on 3.x-dev and then force pushed (sorry if I misunderstood your instructions, hopefully no one had work based on my PR branch). The old calendar.js (now PeriodSelectorController) function propagateNewUrlParams is no longer being called on page load, so I'll need to figure out another way to fix the issue on page load, but the rest transferred pretty cleanly to the new Angular component. (fixed now)

I went ahead and and refactored the JS logic to its own function updateDateInTitle, in the piwik service (organized there so it will be accessible from piwik.updatePeriodParamsFromUrl). I'll still need to de-dupe the logic in Piwik\Plugin\Controller::getLongPrettyDate. Thumbs up on this approach?

Powered by GitHub Issue Mirror