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

Extract series picker into angular component #11905

Merged
merged 3 commits into from Oct 2, 2017
Merged

Extract series picker into angular component #11905

merged 3 commits into from Oct 2, 2017

Conversation

diosmosis
Copy link
Member

@diosmosis diosmosis commented Jul 30, 2017

This PR is based off #11857.

Ready for review, but won't resolve conflicts until #11857 is merged.

Changes:

  • Moved the SeriesPicker class logic to a new piwik-series-picker component. The SeriesPicker class stays for BC (used at least by the treemap visualization plugin).
  • Added ability to create an isolate scope to piwikHelper.compileAngularComponents.
  • (side effect) Fixed some issues w/ UI tests that include the series picker.

@diosmosis diosmosis added c: Design / UI For issues that impact Matomo's user interface or the design overall. Needs Review PRs that need a code review labels Jul 30, 2017
@mattab mattab modified the milestone: 3.1.0 Aug 3, 2017
<div
class="jqplot-seriespicker"
ng-class="{open: $ctrl.isPopupVisible}"
ng-mouseenter="$ctrl.isPopupVisible = true"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@diosmosis just wondering... with components... can we as well use a syntax like controllerAs and refer to their controller name specifically to make sure we work in the right scope? Or do components not have this problem?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can supply controllerAs, however the default for components is $ctrl: https://docs.angularjs.org/guide/component#comparison-between-directive-definition-and-component-definition

So you don't have to explicitly supply it. When coding this, I thought it was better not to have different controller variables all over the place (ie, instead of periodSelector in one component, seriesPicker in another, dataTable in another, everything uses $ctrl). Seems more consistent.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet 👍

class="jqplot-seriespicker-popover"
ng-if="$ctrl.isPopupVisible"
>
<p class="headline">{{ (this.multiselect ? 'General_MetricsToPlot' : 'General_MetricToPlot') | translate }}</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be $ctrl.multiselect?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so

<label>{{ columnConfig.translation }}</label>
</p>
<p
ng-if="$ctrl.selectableRows && $ctrl.selectableRows.length"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW: I think it would simply do $ctrl.selectableRows.length as angular will check $ctrl.selectableRows automatically

@@ -15,7 +15,9 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* NOTE, manual modification made:
* - removed Function.bind implementation, does not work properly w/ angular 1.6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file supposed to be changed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have been changed in the upgrade to angular 1.6, not sure why it's changed here. I'll take a look.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I didn't rebase the PR.

@tsteur
Copy link
Member

tsteur commented Sep 24, 2017

Left a few comments. Worked for me in general, also in IE10.

@diosmosis
Copy link
Member Author

Made some changes, if the UI tests pass, should be good to go.

@mattab mattab modified the milestones: 3.3.0, 3.2.0 Sep 28, 2017
@tsteur
Copy link
Member

tsteur commented Sep 28, 2017

@diosmosis did you squash the last change or so? be good to keep the individual commits so we can more easily review what changed since last time. We can always squash when we merge.

@tsteur
Copy link
Member

tsteur commented Sep 28, 2017

FYI: this ui test is now failing maybe because the title is next to series picker? http://builds-artifacts.piwik.org/piwik/piwik/3.x-dev/24550/UIIntegrationTest_exampleui_treemap.png

.attr('href', '#')
.html('+')
var seriesPicker = '<piwik-series-picker'
+ ' multiselect="' + this.multiSelect + '"'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we call some escaping here? I see it seems to hold a boolean value so should be fine just to prevent possible XSS it in the future (or maybe something like this.multiselect ? 'true' : false')? Also wondering: can we use old <div piwik-series-picker syntax with components? I checked at it seems to be still working with IE10 so reckon no other browsers will have trouble with this but not sure. I presume custom element names are supported everywhere else?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, completely missed it.

Also wondering: can we use old <div piwik-series-picker syntax with components?

I think angularjs 1.6 does not formally allow this (though oddly, angular 2+ supports it). See the 'restrict' part of https://docs.angularjs.org/guide/component#comparison-between-directive-definition-and-component-definition .

From some googling it might be allowed, but not intentionally.

I presume custom element names are supported everywhere else?

I can't find a proper browser support page, they all show support for the whole custom element feature, not just unknown tags. From what I remember only IE and some older versions of Firefox had this problem. Not sure what version of IE, but since angularjs 1.6 doesn't really allow attribute names for components, I'm assuming it works for whatever browser versions angular 1.6 supports.

@tsteur
Copy link
Member

tsteur commented Sep 28, 2017

Left a comment but looks good to merge otherwise. Only minor tweak needed maybe to prevent possible XSS in the future (currently wouldn't be possible). UI test might need a fix as well.

@diosmosis
Copy link
Member Author

@tsteur didn't squash, rebased, there was only one different commit in this PR.

@diosmosis
Copy link
Member Author

@tsteur Tweaked the positioning in treemap visualization so it would look better w/ this change: matomo-org/plugin-TreemapVisualization#13

Think you could look at that today? Since the branch is in a fork I can't use it as the submodule commit in this PR w/o changing the submodule repo.

@tsteur
Copy link
Member

tsteur commented Oct 1, 2017

I tried to test it but couldn't as the treemap is not rendering for me (I highly doubt it is related to your PR... the canvas element etc has always 0 height) and looks like this:
image

The tests don't run as it seems to not be able to check out your treemap branch but I trust it is fixed and can be merged 👍

tsteur added a commit to matomo-org/plugin-TreemapVisualization that referenced this pull request Oct 1, 2017
@tsteur
Copy link
Member

tsteur commented Oct 1, 2017

I merged the other branch in treemap plugin. can you maybe update the submodule to use the master branch and then tests will work?

@diosmosis
Copy link
Member Author

Working on getting the tests to pass, will post a comment when it's all working.

@diosmosis
Copy link
Member Author

Updated the screenshot, if it passes, this PR is good to go. (Let me know if there's anything else to do for TreemapVisualization, release-wise).

@tsteur
Copy link
Member

tsteur commented Oct 2, 2017

tests pass 👍

@tsteur tsteur merged commit 359c3ec into matomo-org:3.x-dev Oct 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Design / UI For issues that impact Matomo's user interface or the design overall. Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants