Skip to content
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

fixes #18282 - select all filtered table #7595

Merged
merged 1 commit into from Aug 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -17,8 +17,8 @@
* Provides the functionality for the repo discovery action pane.
*/
angular.module('Bastion.products').controller('DiscoveryController',
['$scope', '$q', '$timeout', '$http', 'Notification', 'Task', 'Organization', 'CurrentOrganization', 'DiscoveryRepositories', 'translate',
function ($scope, $q, $timeout, $http, Notification, Task, Organization, CurrentOrganization, DiscoveryRepositories, translate) {
['$scope', '$q', '$timeout', '$http', '$filter', 'Notification', 'Task', 'Organization', 'CurrentOrganization', 'DiscoveryRepositories', 'translate',
function ($scope, $q, $timeout, $http, $filter, Notification, Task, Organization, CurrentOrganization, DiscoveryRepositories, translate) {
var transformRows, setDiscoveryDetails;

$scope.discovery = {
Expand Down Expand Up @@ -50,6 +50,21 @@ angular.module('Bastion.products').controller('DiscoveryController',
$scope.table.resource.subtotal = $scope.table.resource.total;
};

$scope.filteredRows = function (filter) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should really be an angular filter instead of a function in the controller but since all of the angular application is effectively deprecated I'm okay with it as long as it work.

var rows, idx;
angular.forEach($scope.table.rows, function (row) {
row.unselectable = true;
});
rows = $filter('filter')($scope.table.rows.slice(), filter);
angular.forEach(rows, function (row) {
idx = $scope.table.rows.indexOf(row);
$scope.table.rows[idx].unselectable = false;
});
$scope.table.getSelected();

return (rows);
};

$scope.setupSelected = function () {
var url;

Expand Down
Expand Up @@ -101,7 +101,7 @@
</thead>

<tbody>
<tr bst-table-row ng-repeat="urlRow in table.rows | filter:tableFilter" row-select="urlRow">
<tr bst-table-row ng-repeat="urlRow in filteredRows(tableFilter)" row-select="urlRow">
<td bst-table-cell style="white-space:nowrap">{{ urlRow.path }}</td>
</tr>
</tbody>
Expand Down