[Search] Filter search

Filtering search using the search menu works.
Load more does not work with this yet.
This commit is contained in:
slhale 2015-08-13 11:45:46 -07:00
parent c51856522c
commit b26aa3cab7
4 changed files with 71 additions and 50 deletions

View File

@ -347,18 +347,21 @@ ul.tree {
border-top: 0; } border-top: 0; }
/* line 141, ../sass/search/_search.scss */ /* line 141, ../sass/search/_search.scss */
.search-holder .search .search-bar .search-menu-holder .search-menu .search-menu-item { .search-holder .search .search-bar .search-menu-holder .search-menu .search-menu-item {
padding: 0px 4px; padding-top: 0;
padding-bottom: 0;
padding-left: 4px;
padding-right: 6px;
font-size: 0.8em; } font-size: 0.8em; }
/* line 146, ../sass/search/_search.scss */ /* line 150, ../sass/search/_search.scss */
.search-holder .search .search-bar .search-menu-holder .search-menu .search-menu-item .search-menu-checkbox { .search-holder .search .search-bar .search-menu-holder .search-menu .search-menu-item .search-menu-checkbox {
margin-top: 4px; margin-top: 0.3em;
padding-left: 0; padding-left: 0;
margin-right: 0; } margin-right: 0; }
/* line 156, ../sass/search/_search.scss */ /* line 160, ../sass/search/_search.scss */
.search-holder .search .search-bar .search-menu-holder .search-menu .search-menu-item .search-menu-icon { .search-holder .search .search-bar .search-menu-holder .search-menu .search-menu-item .search-menu-glyph {
color: white; color: white;
padding-left: 2px; } padding-left: 3px; }
/* line 165, ../sass/search/_search.scss */ /* line 173, ../sass/search/_search.scss */
.search-holder .search .search-bar .search-menu-holder:after { .search-holder .search .search-bar .search-menu-holder:after {
position: absolute; position: absolute;
top: -6px; top: -6px;
@ -368,18 +371,18 @@ ul.tree {
border-bottom: 6px solid #5e5e5e; border-bottom: 6px solid #5e5e5e;
border-left: 6px solid transparent; border-left: 6px solid transparent;
content: ''; } content: ''; }
/* line 178, ../sass/search/_search.scss */ /* line 186, ../sass/search/_search.scss */
.search-holder .search .search-bar .menu-icon:hover + div.search-menu-holder { .search-holder .search .search-bar .menu-icon:hover + div.search-menu-holder {
visibility: visible; } visibility: visible; }
/* line 181, ../sass/search/_search.scss */ /* line 189, ../sass/search/_search.scss */
.search-holder .search .search-bar div.search-menu-holder:hover { .search-holder .search .search-bar div.search-menu-holder:hover {
visibility: visible; } visibility: visible; }
/* line 186, ../sass/search/_search.scss */ /* line 194, ../sass/search/_search.scss */
.search-holder .search .search-scroll { .search-holder .search .search-scroll {
top: 25px; top: 25px;
overflow-y: auto; overflow-y: auto;
padding-right: 5px; } padding-right: 5px; }
/* line 194, ../sass/search/_search.scss */ /* line 202, ../sass/search/_search.scss */
.search-holder .search .search-scroll .results .search-result-item { .search-holder .search .search-scroll .results .search-result-item {
-moz-transition: background-color 0.25s; -moz-transition: background-color 0.25s;
-o-transition: background-color 0.25s; -o-transition: background-color 0.25s;
@ -389,10 +392,10 @@ ul.tree {
border-radius: 2px; border-radius: 2px;
padding-top: 4px; padding-top: 4px;
padding-bottom: 2px; } padding-bottom: 2px; }
/* line 208, ../sass/search/_search.scss */ /* line 216, ../sass/search/_search.scss */
.search-holder .search .search-scroll .results .search-result-item .label { .search-holder .search .search-scroll .results .search-result-item .label {
margin-left: 6px; } margin-left: 6px; }
/* line 212, ../sass/search/_search.scss */ /* line 220, ../sass/search/_search.scss */
.search-holder .search .search-scroll .results .search-result-item .label .title-label { .search-holder .search .search-scroll .results .search-result-item .label .title-label {
display: inline-block; display: inline-block;
position: absolute; position: absolute;
@ -404,47 +407,47 @@ ul.tree {
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; } white-space: nowrap; }
/* line 234, ../sass/search/_search.scss */ /* line 242, ../sass/search/_search.scss */
.search-holder .search .search-scroll .results .search-result-item.selected { .search-holder .search .search-scroll .results .search-result-item.selected {
background: #005177; background: #005177;
color: #fff; } color: #fff; }
/* line 238, ../sass/search/_search.scss */ /* line 246, ../sass/search/_search.scss */
.search-holder .search .search-scroll .results .search-result-item.selected .view-control { .search-holder .search .search-scroll .results .search-result-item.selected .view-control {
color: #0099cc; } color: #0099cc; }
/* line 241, ../sass/search/_search.scss */ /* line 249, ../sass/search/_search.scss */
.search-holder .search .search-scroll .results .search-result-item.selected .label .type-icon { .search-holder .search .search-scroll .results .search-result-item.selected .label .type-icon {
color: #fff; } color: #fff; }
/* line 248, ../sass/search/_search.scss */ /* line 256, ../sass/search/_search.scss */
.search-holder .search .search-scroll .results .search-result-item:not(.selected):hover { .search-holder .search .search-scroll .results .search-result-item:not(.selected):hover {
background: #404040; background: #404040;
color: #cccccc; } color: #cccccc; }
/* line 251, ../sass/search/_search.scss */ /* line 259, ../sass/search/_search.scss */
.search-holder .search .search-scroll .results .search-result-item:not(.selected):hover .context-trigger { .search-holder .search .search-scroll .results .search-result-item:not(.selected):hover .context-trigger {
display: block; } display: block; }
/* line 254, ../sass/search/_search.scss */ /* line 262, ../sass/search/_search.scss */
.search-holder .search .search-scroll .results .search-result-item:not(.selected):hover .icon { .search-holder .search .search-scroll .results .search-result-item:not(.selected):hover .icon {
color: #33ccff; } color: #33ccff; }
/* line 262, ../sass/search/_search.scss */ /* line 270, ../sass/search/_search.scss */
.search-holder .search .search-scroll .load-icon { .search-holder .search .search-scroll .load-icon {
position: relative; } position: relative; }
/* line 264, ../sass/search/_search.scss */ /* line 272, ../sass/search/_search.scss */
.search-holder .search .search-scroll .load-icon.loading { .search-holder .search .search-scroll .load-icon.loading {
pointer-events: none; pointer-events: none;
margin-left: 6px; } margin-left: 6px; }
/* line 268, ../sass/search/_search.scss */ /* line 276, ../sass/search/_search.scss */
.search-holder .search .search-scroll .load-icon.loading .title-label { .search-holder .search .search-scroll .load-icon.loading .title-label {
font-style: italic; font-style: italic;
font-size: .9em; font-size: .9em;
opacity: 0.5; opacity: 0.5;
margin-left: 26px; margin-left: 26px;
line-height: 24px; } line-height: 24px; }
/* line 278, ../sass/search/_search.scss */ /* line 286, ../sass/search/_search.scss */
.search-holder .search .search-scroll .load-icon.loading .wait-spinner { .search-holder .search .search-scroll .load-icon.loading .wait-spinner {
margin-left: 6px; } margin-left: 6px; }
/* line 283, ../sass/search/_search.scss */ /* line 291, ../sass/search/_search.scss */
.search-holder .search .search-scroll .load-icon:not(.loading) { .search-holder .search .search-scroll .load-icon:not(.loading) {
cursor: pointer; } cursor: pointer; }
/* line 288, ../sass/search/_search.scss */ /* line 296, ../sass/search/_search.scss */
.search-holder .search .search-scroll .load-more-button { .search-holder .search .search-scroll .load-more-button {
margin-top: 5px; margin-top: 5px;
margin-bottom: 5px; margin-bottom: 5px;

View File

@ -140,12 +140,16 @@
.search-menu-item { .search-menu-item {
// Padding only on sides // Padding only on sides
padding: 0px 4px; padding-top: 0;
padding-bottom: 0;
padding-left: 4px;
padding-right: 6px;
font-size: 0.8em; font-size: 0.8em;
.search-menu-checkbox { .search-menu-checkbox {
// Vertically center // Vertically center
margin-top: 4px; margin-top: 0.3em;
// Get rid of weird checkbox positioning // Get rid of weird checkbox positioning
// from label.checkbox.custom // from label.checkbox.custom
@ -153,9 +157,13 @@
margin-right: 0; margin-right: 0;
} }
.search-menu-icon { .search-menu-glyph {
color: white; color: white;
padding-left: 2px; padding-left: 3px;
}
&:hover {
// Do nothing
} }
} }
} }

View File

@ -62,11 +62,11 @@
<label class="checkbox custom search-menu-checkbox"> <label class="checkbox custom search-menu-checkbox">
<input type="checkbox" <input type="checkbox"
class="checkbox" class="checkbox"
checked="true"/> ng-model="ngModel.checked[type.key]" />
<em></em> <em></em>
</label> </label>
<span class="ui-symbol search-menu-icon"> <span class="ui-symbol search-menu-glyph">
{{ type.glyph }} {{ type.glyph }}
</span> </span>

View File

@ -36,7 +36,26 @@ define(function () {
loading = false, loading = false,
fullResults = {hits: []}; fullResults = {hits: []};
console.log('types', types); // Scope variables are
// $scope.results, $scope.types
// $scope.ngModel.input, $scope.ngModel.search, $scope.ngModel.checked
$scope.types = [];
$scope.ngModel.checked = {};
function filter(hits) {
var newResults = [],
i = 0;
while (newResults.length < numResults && i < hits.length) {
// If this is of an acceptable type, add it to the list
if ($scope.ngModel.checked[hits[i].object.getModel().type] === true) {
newResults.push(fullResults.hits[i]);
}
i += 1;
}
return newResults;
}
function search(maxResults) { function search(maxResults) {
var inputText = $scope.ngModel.input; var inputText = $scope.ngModel.input;
@ -60,7 +79,8 @@ define(function () {
// Send the query // Send the query
searchService.query(inputText, maxResults).then(function (result) { searchService.query(inputText, maxResults).then(function (result) {
fullResults = result; fullResults = result;
$scope.results = result.hits.slice(0, numResults); //$scope.results = result.hits.slice(0, numResults);
$scope.results = filter(result.hits);
// Update whether the file tree should be displayed // Update whether the file tree should be displayed
// Reveal tree only when finishing search // Reveal tree only when finishing search
@ -73,31 +93,21 @@ define(function () {
}); });
} }
function filter(types) {
var newResults = [],
i = 0;
while (newResults.length < numResults && newResults.length < fullResults.hits.length) {
// If this is of an acceptable type, add it to the list
if (types.indexOf(fullResults.hits[i].getModel().type) !== -1) {
newResults.push(fullResults.hits[i]);
}
i += 1;
}
$scope.results = newResults;
}
$scope.types = [];
// On initialization, fill the scope's types with type keys // On initialization, fill the scope's types with type keys
types.forEach(function (type) { types.forEach(function (type) {
// We only want some types: the ones that have keys and // We only want some types: the ones that have keys and
// descriptions are probably human user usable types // descriptions are probably human user usable types
if (type.key && type.description) { if (type.key && type.description) {
$scope.types.push(type); $scope.types.push(type);
$scope.ngModel.checked[type.key] = true;
} }
}); });
// Re-filter the results when the checked type options change
$scope.$watch("$scope.ngModel.checked", function () {
$scope.results = filter(fullResults.hits);
});
return { return {
/** /**
* Search the filetree. * Search the filetree.