Skip to content

Conversation

@jeff-phillips-18
Copy link
Member

@jeff-phillips-18 jeff-phillips-18 commented Nov 3, 2016

Description

This PR removes the JQuery dependency from the default patternfly module. Two of the existing directives have been moved from the default module to patternfly.jquery: pfSelect and pfDatepicker. To use either of these directives add the patternfly.jquery module to your application module.

An additional directive, pfBootstrapSelect, has been added to achieve the same basic features of pfSelect but without the JQuery dependency.

The angular patternfly code has been adjusted to use the non-JQuery patternfly settings. To keep JQuery independence, include only patternfly-settings.js rather than patternfly.js.

@dtaylor113 @dgutride @dlabrecq @bleathem

@jeff-phillips-18 jeff-phillips-18 force-pushed the no-jquery branch 2 times, most recently from 2b45a01 to 1c1c4a6 Compare November 4, 2016 17:56
@jeff-phillips-18 jeff-phillips-18 changed the title [WIP] Remove JQuery dependency from default modules Remove JQuery dependency from default modules Nov 7, 2016
'use strict';

return {
restrict: 'A',
Copy link
Member

Choose a reason for hiding this comment

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

Why just an 'A'? I expected <pf-bootstrap-select..., not having to have to use a <div pf-bootstrap-select=...
Not a big issue though

Copy link
Member Author

Choose a reason for hiding this comment

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

Typically the Angular Patternfly directives are Attribute only.

* @param {boolean} updateActiveItemsOnClick Flag if active items should be marked on click rather than on navigation change, default: false
* @param {boolean} ignoreMobile Flag if mobile state should be ignored (use only if absolutely necessary) default: false
*
* @example
Copy link
Member

Choose a reason for hiding this comment

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

What are all these changes to vert. nav? Doesn't seem to have anything to do with removing jQuery or pf-select?

Copy link
Member Author

Choose a reason for hiding this comment

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

The example was using JQuery to initialize the vertical navigation. Things like:
$(document).ready(function()
I'm trying to use as little jQuery as possible throughout even in the examples.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, thanks for the info.

<div class="col-sm-10">
<select pf-select ng-model="type" id="type" ng-options="o as o for o in types"></select>
<div class="col-sm-4">
<div pf-bootstrap-select current-selection="type" id="type" selections="types"></divselect>
Copy link
Member

@dtaylor113 dtaylor113 Nov 11, 2016

Choose a reason for hiding this comment

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

Is that correct closing tag? </divselect>?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope. I will fix that. Thanks.

@dtaylor113
Copy link
Member

This is great work Jeff! I realize this was the result of a breakaway sprint story whose end goal was to remove jQuery dependency, so this PR contains all those changes to accomplish that goal. However, this PR changes several components. Ideally, this PR would have been better as several smaller PRs. I'm going to clone this dev branch and do some manual testing, but so far everything looks good.
Thanks,

  • Dave

@jeff-phillips-18
Copy link
Member Author

Thanks @dtaylor113. Agreed which is why I did not squash commits so that the progression was evident and each commit is reviewable on its own.

@dtaylor113
Copy link
Member

dtaylor113 commented Nov 11, 2016

Think we need to udpate the README file with some of the stuff you talk about in this PR's Description:

"This PR removes the JQuery dependency from the default patternfly module. Two of the existing directives have been moved from the default module to patternfly.jquery: pfSelect and pfDatepicker. To use either of these directives add the patternfly.jquery module to your application module.

The angular patternfly code has been adjusted to use the non-JQuery patternfly settings. To keep JQuery independence, include only patternfly-settings.js rather than patternfly.js."

@dtaylor113
Copy link
Member

Hi @jeff-phillips-18, ran through all ngdoc examples. I'm seeing two issues:

In ngdocs:view

  • pfFilter input field doesn't seem to be accepting input, filter not being applied. Also seen in pfToolbar
  • patternfly.jquery.pfDatepicker, throws error:
angular.js:13920 Error: [$injector:modulerr] Failed to instantiate module patternfly.datepicker due to:
Error: [$injector:nomod] Module 'patternfly.datepicker' is not available!

Everything else looks good 👍

@dtaylor113
Copy link
Member

Probably not due to this PR, but pfValidation:
image
After clicking on the button with no label:
image

@jeff-phillips-18
Copy link
Member Author

Fixed the 3 issues noted by @dtaylor113

'patternfly.jquery'
]);

Note: the pfSelect and datepicker directives are only available in the patternfly.jquery module. Using these directives requires the inclusion of the jQuery library.
Copy link
Member

Choose a reason for hiding this comment

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

Should 'datepicker' be 'pfDatepicker' or are you also including the straight bootstrap-datepicker as requiring jQuery?

Copy link
Member

Choose a reason for hiding this comment

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

I know base refs README talks about Wiredep. I just played around with angular-patternfly-demo-app which uses something like wiredep (grunt-usemin?) and it was always including patternfly.js. Since we talk about just using patternfly-settings.js here, should we mention how to config wiredep to grab the correct file, or is that up to the app dev to know/figure out?

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 would prefer to leave that exercise to the reader. You can setup wiredep to include/exclude how you like.

@jeff-phillips-18
Copy link
Member Author

I haven't changed the name and would prefer not to to keep as much backwards compatibility as possible.

@dtaylor113
Copy link
Member

LGTM 👍

@dtaylor113
Copy link
Member

Any movement on this? Can we get another reviewer? @dgutride , @dlabrecq -thanks 😄

'patternfly.charts'
]);
'patternfly.charts',
'patternfly.jquery'
Copy link
Member

Choose a reason for hiding this comment

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

We seem to have lost the granularity of our modules. Should we consider keeping the granularity, but adding a -jquery suffix to the modules to indicate they bring in the jQuery dependency (with possibly a common jquery parent dependency)? eg. patternfly-datepicker-jquery or patternfly-form-jquery.

Copy link
Member Author

Choose a reason for hiding this comment

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

There are 2 jquery dependent directives. We could add modules for each patternfly.datepicker and patternfly.select then have patternfly.jquery pull both in. I wouldn't be a fan of patternfly-form-jquery with only one directive then patternfly.jquery pull in patternfly-form-jquery. that's 3 modules for one directive.

@bleathem
Copy link
Member

I've reviewed each of the commits - thanks for not squashing them @jeff-phillips-18, it's much easier to review each change in context. The changes overall seem reasonable to me, I'll leave it up to those more familiar with the angular-patternfly implementation to assess there technical validity (thanks @dtaylor113).

I had one question I asked inline about the module consolidation into the module.jquery module.

The only other question I have is to confirm that this PR does not introduce a breaking change for downstream applications. Rather they will have to "opt in" to get the jQuery independence provided by this PR.

Nice work overall @jeff-phillips-18, a very well thought out and comprehensive approach!

@jeff-phillips-18
Copy link
Member Author

Well, this is the opposite @bleathem. Any downstream applications currently using pfSelect or pfDatepicker will need to "opt in" in order to continue using them (by adding a dependency on the patternfly.jquery module).

To "opt out" of jquery dependence would require a patternfly module that was jquery independent. I couldn't think of a good naming convention for that. Any thoughts or is release noting this good enough?

@jeff-phillips-18
Copy link
Member Author

@bleathem ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants