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
Conversation
<div | ||
class="jqplot-seriespicker" | ||
ng-class="{open: $ctrl.isPopupVisible}" | ||
ng-mouseenter="$ctrl.isPopupVisible = true" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Left a few comments. Worked for me in general, also in IE10. |
Made some changes, if the UI tests pass, should be good to go. |
@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. |
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 + '"' |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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. |
@tsteur didn't squash, rebased, there was only one different commit in this PR. |
@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. |
I merged the other branch in treemap plugin. can you maybe update the submodule to use the master branch and then tests will work? |
Working on getting the tests to pass, will post a comment when it's all working. |
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). |
tests pass 👍 |
This PR is based off #11857.
Ready for review, but won't resolve conflicts until #11857 is merged.
Changes:
piwikHelper.compileAngularComponents
.