Skip to content

Commit

Permalink
feat(groupRow): add expand/collapse toggle for group rows
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrowhurstram committed Sep 5, 2015
1 parent ea55c42 commit 32f208b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
12 changes: 10 additions & 2 deletions src/ng-table/groupRow.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@
}">
<a href="" ng-click="isSelectorOpen = !isSelectorOpen" class="ng-table-group-selector">
<strong class="sort-indicator">{{$selGroupTitle}}</strong>
<button class="btn btn-default btn-xs" ng-click="$groupRow.show = false"
ng-disabled="isSelectorOpen"><span class="glyphicon glyphicon-resize-small"></span>
<button class="btn btn-default btn-xs ng-table-group-close"
ng-click="$groupRow.show = false; $event.preventDefault(); $event.stopPropagation();">
<span class="glyphicon glyphicon-remove"></span>
</button>
<button class="btn btn-default btn-xs ng-table-group-toggle"
ng-click="toggleDetail(); $event.preventDefault(); $event.stopPropagation();">
<span class="glyphicon" ng-class="{
'glyphicon-resize-small': params.settings().groupOptions.isExpanded,
'glyphicon-resize-full': !params.settings().groupOptions.isExpanded
}"></span>
</button>
</a>
<div class="list-group" ng-if="isSelectorOpen">
Expand Down
6 changes: 6 additions & 0 deletions src/scripts/ngTableGroupRowController.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
$scope.getVisibleColumns = getVisibleColumns;
$scope.groupBy = groupBy;
$scope.isSelectedGroup = isSelectedGroup;
$scope.toggleDetail = toggleDetail;

$scope.$watch('params.group()', setGroup, true);
}
Expand Down Expand Up @@ -107,5 +108,10 @@
}
}
}

function toggleDetail(){
$scope.params.settings().groupOptions.isExpanded = !$scope.params.settings().groupOptions.isExpanded;
return $scope.params.reload();
}
}
})();
9 changes: 6 additions & 3 deletions src/styles/ng-table.less
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,12 @@
}
.ng-table-group-selector {
display: block;
> button {
float: right;
}
}
.ng-table-group-close, .ng-table-group-toggle {
float: right;
}
.ng-table-group-toggle {
margin-right: 5px;
}
& + .pagination {
margin-top: 0;
Expand Down

0 comments on commit 32f208b

Please sign in to comment.