Skip to content

ListView drag and drop #393

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

Merged
merged 2 commits into from
Jan 27, 2017
Merged

Conversation

dlabrecq
Copy link
Member

@dlabrecq dlabrecq commented Jan 27, 2017

Description

A CloudForms contribution adding drag and drop features to the ListView component for Angular 1. There is a separate PR for Angular 1.5 (i.e., the branch-4.0-dev branch).

Note that Patternfly depends on a feature branch for the CSS. However, this dependency will be replaced automatically by build scripts, upon the next release.

See: https://patternfly.atlassian.net/browse/CFUX-311

Steps to test or reproduce and link to rawgit

https://dlabrecq.github.io/angular-patternfly.github.io/index.html#/api/patternfly.views.directive:pfListView

listview dnd

@dlabrecq dlabrecq changed the title ListView drag and drop for Angular 1 ListView drag and drop Jan 27, 2017
@@ -618,6 +660,30 @@ angular.module('patternfly.views').directive('pfListView', function ($timeout, $
scope.checkDisabled = function (item) {
return scope.config.checkDisabled && scope.config.checkDisabled(item);
};

scope.dragEnd = function () {
if (scope.config.dragEnd) {
Copy link
Member

Choose a reason for hiding this comment

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

Safer to us use angular.isFunction(scope.config.dragEnd) when checking these config items

Copy link
Member Author

Choose a reason for hiding this comment

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

Will do.

@@ -1,52 +1,64 @@
<div class="list-group list-view-pf">
<div class="list-group list-view-pf" dnd-list="items" ng-class="{'list-view-pf-dnd': config.dragEnabled === true}">
<div class='dndPlaceholder'></div>
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 div only be added when drag drop is enabled?

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 placeholder div has to be there; otherwise, I get an ugly empty space at the top of the list when enabled.

screen shot 2017-01-27 at 10 04 29 am

Copy link
Member

Choose a reason for hiding this comment

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

yeah, but if drag/drop is not enabled it should be OK without it right?
(ng-if="config.dragEnabled")

Copy link
Member

Choose a reason for hiding this comment

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

I tried this and I don't quite understand why it behaves this way but you are correct. I don't see why the ng-if makes a difference but I guess we leave it as is.

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 don't quite understand why it behaves like this, but suspect the library is looking for the selector when the page is loaded. If I don't provide this tag, the dnd library will use an HTML "li" element and then you see a list dot in the page when dragging.

Copy link
Member Author

@dlabrecq dlabrecq Jan 27, 2017

Choose a reason for hiding this comment

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

If this is a problem, I can style the HTML "li" element to not show up. Just thought this solution was more elegant than incorrectly using an "li" within a "div" tag.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, if is fine as is. No harm no foul.

<div class="list-view-pf-checkbox" ng-if="config.showSelectBox" >
<input type="checkbox" value="item.selected" ng-model="item.selected" ng-disabled="checkDisabled(item)" ng-change="checkBoxChange(item)"/>
<div class="list-view-pf-dnd-drag-items">
<div pf-transclude="parent" class="list-view-pf-main-info"></div>
</div>
Copy link
Member

Choose a reason for hiding this comment

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

This div should only be added if drag and drop is enabled

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I will add this only when drag and drop is enabled.

</div>
<div class="list-view-pf-dnd-original-items">
Copy link
Member

Choose a reason for hiding this comment

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

only add the class if drag/drop is enabled

@dlabrecq
Copy link
Member Author

Updated per Jeffs code review comments.

var dragEnd = function() {
$scope.eventText = 'drag end\r\n' + $scope.eventText;
};
var dragMoved = function() {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this dragMoved functionality be the default behavior in the directive instead of leaving it up to the end users to implement it correctly?

Copy link
Member

Choose a reason for hiding this comment

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

Applications will want to handle this on their own. Moving an item's order in the list would typically require a backend call to make the change. Maybe some validation, etc.

@dtaylor113
Copy link
Member

LGTM. I like the way the drag-n-drop works with all the existing selecting mechanisms and row expand content :-)

Copy link
Member

@jeff-phillips-18 jeff-phillips-18 left a comment

Choose a reason for hiding this comment

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

👍

@jeff-phillips-18 jeff-phillips-18 merged commit aed2484 into patternfly:master Jan 27, 2017
@dlabrecq dlabrecq deleted the CFUX-311 branch August 6, 2017 00:57
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