-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Paginated selectable list directive #6550
Changes from 8 commits
9c7c4d9
930a0eb
1aab5e0
8455d56
3aa06ab
c72c440
c852844
5a488f4
8790a79
041c2f6
6939960
27c6f17
ec68aa0
f7cc5f1
765185f
96e5937
41e3081
1ff22b1
242fe85
420c1bc
2152047
00f5527
b968b0b
a8c1305
2a71673
690a140
49d297f
a612a0e
1dc9a18
d66df55
149cc2e
cf78a36
08bae15
b126e35
115128b
2ebd94d
08e9202
12fe251
7bbfa22
4408069
f458af2
62316aa
66a8c7f
2992a66
d90baae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,14 @@ | ||
<div class="wizard"> | ||
<div class="wizard-column"> | ||
<h3>From a New Search</h3> | ||
<!-- Index patterns --> | ||
<div class="wizard-row"> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Index Patterns</div> | ||
</div> | ||
<ul class="striped list-group"> | ||
<li class="list-group-item" ng-repeat="pattern in indexPattern.list | orderBy: 'toString()'"> | ||
<a class="index-link" kbn-href="{{ makeUrl(pattern) }}">{{pattern}}</a> | ||
</li> | ||
</ul> | ||
</div> | ||
<div class="wizard-small wizard-column"> | ||
<h3>From a New Search, Select Index</h3> | ||
<paginated-selectable-list | ||
per-page="20" | ||
list="indexPattern.list" | ||
user-make-url="makeUrl" | ||
class="wizard-row"> | ||
</paginataed-selectable-list> | ||
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. typo |
||
</div> | ||
<div class="wizard-column"> | ||
<div class="wizard-large wizard-column"> | ||
<h3>Or, From a Saved Search</h3> | ||
<!-- Saved searches --> | ||
<saved-object-finder | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -194,5 +194,3 @@ uiModules.get('kibana') | |
template: paginateControlsTemplate | ||
}; | ||
}); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import _ from 'lodash'; | ||
import uiModules from 'ui/modules'; | ||
import paginatedSelectableListTemplate from 'ui/partials/paginated_selectable_list.html'; | ||
|
||
const module = uiModules.get('kibana'); | ||
|
||
module.directive('paginatedSelectableList', function (kbnUrl) { | ||
|
||
return { | ||
restrict: 'E', | ||
scope: { | ||
perPage: '=', | ||
list: '=', | ||
userMakeUrl: '=', | ||
userOnSelect: '=' | ||
}, | ||
template: paginatedSelectableListTemplate, | ||
controller: function ($scope, $element, $filter) { | ||
$scope.perPage = $scope.perPage || 10; | ||
|
||
$scope.hits = $scope.list.sort() || []; | ||
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 would only do anything useful if $scope.list was an array of strings. If the user of the directive wants sorting they need to pass in a property or a sort function. 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. Actually, re-reading this, the entire directive appear that this assume you always pass in a list of strings. I think it would be more likely that we'd have a list of objects and we'd want to pass that in. I mentioned that here: #6156 (comment) |
||
|
||
$scope.hitCount = $scope.hits.length; | ||
|
||
/** | ||
* Boolean that keeps track of whether hits are sorted ascending (true) | ||
* or descending (false) by title | ||
* @type {Boolean} | ||
*/ | ||
$scope.isAscending = true; | ||
|
||
/** | ||
* Sorts saved object finder hits either ascending or descending | ||
* @param {Array} hits Array of saved finder object hits | ||
* @return {Array} Array sorted either ascending or descending | ||
*/ | ||
$scope.sortHits = function (hits) { | ||
$scope.isAscending = !$scope.isAscending; | ||
$scope.hits = $scope.isAscending ? hits.sort() : hits.reverse(); | ||
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. See above note on sorting |
||
}; | ||
|
||
$scope.makeUrl = function (hit) { | ||
return $scope.userMakeUrl(hit); | ||
}; | ||
|
||
$scope.onSelect = function (hit, $event) { | ||
return $scope.userOnSelect(hit, $event); | ||
}; | ||
|
||
$scope.$watch('query', function (val) { | ||
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. You can get rid of this watcher, this can be done in the view, see notes starting here: https://github.com/elastic/kibana/pull/6550/files#r56722858 |
||
$scope.hits = $filter('filter')($scope.list, val); | ||
$scope.hitCount = $scope.hits.length; | ||
}); | ||
} | ||
}; | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<form role="form" class="form-inline"> | ||
<div class="container-fluid"> | ||
<div class="row"> | ||
<div class="input-group form-group finder-form col-md-9"> | ||
<span class="input-group-addon"> | ||
<i class="fa fa-search"></i> | ||
</span> | ||
<input | ||
input-focus | ||
ng-model="query" | ||
placeholder="Filter..." | ||
class="form-control" | ||
name="query" | ||
type="text" | ||
autocomplete="off" /> | ||
</div> | ||
<div class="finder-hit-count col-md-3"> | ||
<span>{{hitCount}} of {{hitCount}}</span> | ||
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 will always show |
||
</div> | ||
</div> | ||
</div> | ||
</form> | ||
<paginate list="hits" per-page="{{perPage}}"> | ||
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. Make this |
||
<ul class="li-striped list-group list-group-menu"> | ||
<li class="list-group-item list-group-menu-item"> | ||
<span class="paginate-heading"> | ||
Name | ||
<i | ||
class="fa" | ||
ng-click="sortHits(hits)" | ||
ng-class="isAscending ? 'fa-caret-up' : 'fa-caret-down'"> | ||
</i> | ||
</span> | ||
</li> | ||
<li | ||
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. The entire |
||
class="list-group-item list-group-menu-item" | ||
ng-repeat="hit in page | filter: query"> | ||
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. remove this filter, it can go on the |
||
<a ng-if="userMakeUrl" kbn-href="{{makeUrl(hit)}}"> | ||
<div><span>{{hit}}</span></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. Why is this |
||
</a> | ||
<div ng-if="userOnSelect" ng-click="onSelect(hit, $event)"> | ||
<span>{{hit}}</span> | ||
</div> | ||
</li> | ||
<li class="list-group-item list-group-no-results" ng-if="hits.length === 0"> | ||
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. Small nit-pick, use ng-show here instead of ng-if. |
||
<p ng-bind="'No matches found.'"></p> | ||
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.
|
||
</li> | ||
</ul> | ||
</paginate> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,6 @@ | |
</form> | ||
<paginate list="finder.hits" per-page="20"> | ||
<ul class="li-striped list-group list-group-menu" ng-class="{'select-mode': finder.selector.enabled}"> | ||
|
||
<li class="list-group-item list-group-menu-item"> | ||
<span class="paginate-heading"> | ||
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. Why was this removed? |
||
Name | ||
|
@@ -37,7 +36,6 @@ | |
</i> | ||
</span> | ||
</li> | ||
|
||
<li | ||
class="list-group-item list-group-menu-item" | ||
ng-class="{'active': finder.selector.index === $index && finder.selector.enabled}" | ||
|
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.
Is this list-group-item-menu class still in use?
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.
I see
list-group-menu-item
in use, but I don't see a style of it it (note the menu->item item->menu swap in the name). In any case it looks like everywhere it is usedlist-group-item
is already a class on the element. Seems like it could go right?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.
Yes, that can go.