-
Notifications
You must be signed in to change notification settings - Fork 90
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this div only be added when drag drop is enabled? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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-group-item {{item.rowClass}}" | ||
ng-repeat="item in items track by $index" | ||
ng-class="{'pf-selectable': selectItems, 'active': isSelected(item), 'disabled': checkDisabled(item), 'list-view-pf-expand-active': item.isExpanded}"> | ||
dnd-draggable="item" | ||
dnd-effect-allowed="move" | ||
dnd-disable-if="config.dragEnabled !== true" | ||
dnd-dragstart="dragStart(item)" | ||
dnd-moved="dragMoved()" | ||
dnd-dragend="dragEnd()" | ||
ng-class="{'drag-original': isDragOriginal(item), 'pf-selectable': selectItems, 'active': isSelected(item), 'disabled': checkDisabled(item), 'list-view-pf-expand-active': item.isExpanded}"> | ||
<div class="list-group-item-header"> | ||
<div class="list-view-pf-expand" ng-if="config.useExpandingRows"> | ||
<span class="fa fa-angle-right" ng-show="!item.disableRowExpansion" ng-click="toggleItemExpansion(item)" ng-class="{'fa-angle-down': item.isExpanded}"></span> | ||
<span class="pf-expand-placeholder" ng-show="item.disableRowExpansion"></span> | ||
</div> | ||
<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" ng-if="config.dragEnabled === true"> | ||
<div pf-transclude="parent" class="list-view-pf-main-info"></div> | ||
</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This div should only be added if drag and drop is enabled There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ng-class="{'list-view-pf-dnd-original-items': config.dragEnabled === true}"> | ||
<div class="list-view-pf-expand" ng-if="config.useExpandingRows"> | ||
<span class="fa fa-angle-right" ng-show="!item.disableRowExpansion" ng-click="toggleItemExpansion(item)" ng-class="{'fa-angle-down': item.isExpanded}"></span> | ||
<span class="pf-expand-placeholder" ng-show="item.disableRowExpansion"></span> | ||
</div> | ||
<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> | ||
|
||
<div class="list-view-pf-actions" | ||
ng-if="(actionButtons && actionButtons.length > 0) || (menuActions && menuActions.length > 0)"> | ||
<button class="btn btn-default {{actionButton.class}}" ng-repeat="actionButton in actionButtons" | ||
title="{{actionButton.title}}" | ||
ng-class="{'disabled' : checkDisabled(item) || !enableButtonForItem(actionButton, item)}" | ||
ng-click="handleButtonAction(actionButton, item)"> | ||
<div ng-if="actionButton.include" class="actionButton.includeClass" ng-include src="actionButton.include"></div> | ||
<span ng-if="!actionButton.include">{{actionButton.name}}</span> | ||
</button> | ||
<div uib-dropdown class="{{dropdownClass}} pull-right dropdown-kebab-pf {{getMenuClassForItem(item)}} {{hideMenuForItem(item) ? 'invisible' : ''}}" | ||
id="kebab_{{$index}}" | ||
ng-if="menuActions && menuActions.length > 0"> | ||
<button uib-dropdown-toggle class="btn btn-link" type="button" | ||
id="dropdownKebabRight_{{$index}}" | ||
ng-class="{'disabled': checkDisabled(item)}" | ||
ng-click="setupActions(item, $event)"> | ||
<span class="fa fa-ellipsis-v"></span> | ||
<div class="list-view-pf-actions" | ||
ng-if="(actionButtons && actionButtons.length > 0) || (menuActions && menuActions.length > 0)"> | ||
<button class="btn btn-default {{actionButton.class}}" ng-repeat="actionButton in actionButtons" | ||
title="{{actionButton.title}}" | ||
ng-class="{'disabled' : checkDisabled(item) || !enableButtonForItem(actionButton, item)}" | ||
ng-click="handleButtonAction(actionButton, item)"> | ||
<div ng-if="actionButton.include" class="actionButton.includeClass" ng-include src="actionButton.include"></div> | ||
<span ng-if="!actionButton.include">{{actionButton.name}}</span> | ||
</button> | ||
<ul uib-dropdown-menu class="dropdown-menu dropdown-menu-right {{$index}}" aria-labelledby="dropdownKebabRight_{{$index}}" > | ||
<li ng-repeat="menuAction in menuActions" | ||
ng-if="menuAction.isVisible !== false" | ||
role="{{menuAction.isSeparator === true ? 'separator' : 'menuitem'}}" | ||
ng-class="{'divider': (menuAction.isSeparator === true), 'disabled': (menuAction.isDisabled === true)}"> | ||
<a ng-if="menuAction.isSeparator !== true" title="{{menuAction.title}}" ng-click="handleMenuAction(menuAction, item)"> | ||
{{menuAction.name}} | ||
</a> | ||
</li> | ||
</ul> | ||
<div uib-dropdown class="{{dropdownClass}} pull-right dropdown-kebab-pf {{getMenuClassForItem(item)}} {{hideMenuForItem(item) ? 'invisible' : ''}}" | ||
id="kebab_{{$index}}" | ||
ng-if="menuActions && menuActions.length > 0"> | ||
<button uib-dropdown-toggle class="btn btn-link" type="button" | ||
id="dropdownKebabRight_{{$index}}" | ||
ng-class="{'disabled': checkDisabled(item)}" | ||
ng-click="setupActions(item, $event)"> | ||
<span class="fa fa-ellipsis-v"></span> | ||
</button> | ||
<ul uib-dropdown-menu class="dropdown-menu dropdown-menu-right {{$index}}" aria-labelledby="dropdownKebabRight_{{$index}}" > | ||
<li ng-repeat="menuAction in menuActions" | ||
ng-if="menuAction.isVisible !== false" | ||
role="{{menuAction.isSeparator === true ? 'separator' : 'menuitem'}}" | ||
ng-class="{'divider': (menuAction.isSeparator === true), 'disabled': (menuAction.isDisabled === true)}"> | ||
<a ng-if="menuAction.isSeparator !== true" title="{{menuAction.title}}" ng-click="handleMenuAction(menuAction, item)"> | ||
{{menuAction.name}} | ||
</a> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
<div pf-transclude="parent" | ||
class="list-view-pf-main-info" | ||
ng-click="itemClick($event, item)" | ||
ng-dblclick="dblClick($event, item)"> | ||
<div pf-transclude="parent" | ||
class="list-view-pf-main-info" | ||
ng-click="itemClick($event, item)" | ||
ng-dblclick="dblClick($event, item)"> | ||
</div> | ||
<div class="list-group-item-container container-fluid" ng-transclude="expandedContent" ng-if="config.useExpandingRows && item.isExpanded"></div> | ||
</div> | ||
</div> | ||
<div class="list-group-item-container container-fluid" ng-transclude="expandedContent" ng-if="config.useExpandingRows && item.isExpanded"></div> | ||
</div> | ||
</div> |
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.
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?
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.
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.