This repository has been archived by the owner on Jul 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(search): Add advanced query toggle.
- Creates Search-bar directive for managing searching mode. - Advanced query becomes it's own state /query/{p,f} - Lint fixes. Closes #95
- Loading branch information
Matthew Schranz
committed
Dec 5, 2014
1 parent
f64b4ce
commit 1aac50b
Showing
27 changed files
with
405 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,7 @@ | |
} | ||
|
||
.current-filters { | ||
|
||
div, span { | ||
display: inline-block; | ||
margin-bottom: 3px; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
@import "charts/styles/charts.less"; | ||
@import "charts/styles/bar-chart.less"; | ||
@import "charts/styles/d3-tip.less"; | ||
@import "facets/styles/facets.less"; | ||
@import "facets/styles/facets.less"; | ||
@import "ui/search/styles.less"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module ngApp.components.ui.search { | ||
|
||
angular.module("ui.search", [ | ||
"search.directives", | ||
"search.controllers" | ||
]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
module ngApp.components.ui.search.controllers { | ||
import ILocationService = ngApp.components.location.services.ILocationService; | ||
|
||
interface ISearchBarController { | ||
query: string; | ||
isSearchQuery: boolean; | ||
toggle(isAdvancedQuery?: boolean): void; | ||
setQuery(): void; | ||
sendQuery(): void; | ||
resetQuery(): void; | ||
} | ||
|
||
class SearchBarController implements ISearchBarController { | ||
query: string = ""; | ||
isSearchQuery: boolean = false; | ||
|
||
/* @ngInject */ | ||
constructor(private $scope: ng.IScope, private LocationService: ILocationService, | ||
private $state: ng.ui.IStateService) { | ||
this.isSearchQuery = !!$state.current.name.match("search.") || | ||
!!$state.current.name.match("query."); | ||
$scope.$watch("query", () => { | ||
if (!this.query) { | ||
this.LocationService.clear(); | ||
} | ||
}); | ||
this.setQuery(); | ||
} | ||
|
||
sendQuery() { | ||
this.LocationService.setQuery(this.query); | ||
} | ||
|
||
setQuery() { | ||
var currentQuery = this.LocationService.query(); | ||
|
||
if (typeof currentQuery === "string") { | ||
this.query = currentQuery; | ||
} | ||
} | ||
|
||
toggle(isAdvancedQuery: boolean = false) { | ||
this.$scope.$parent.advancedQuery = isAdvancedQuery; | ||
} | ||
|
||
resetQuery() { | ||
this.LocationService.clear(); | ||
this.query = ""; | ||
} | ||
} | ||
|
||
angular.module("search.controllers", []) | ||
.controller("SearchBarController", SearchBarController); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module ngApp.components.ui.search.directives { | ||
import IGDCWindowService = ngApp.models.IGDCWindowService; | ||
|
||
/* @ngInject */ | ||
function SearchBar(): ng.IDirective { | ||
return { | ||
restrict: "E", | ||
scope: true, | ||
templateUrl: "components/ui/search/templates/search-bar.html", | ||
controller: "SearchBarController as sb" | ||
}; | ||
} | ||
|
||
angular.module("search.directives", ["search.controllers"]) | ||
.directive("searchBar", SearchBar); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.search-bar { | ||
button { | ||
margin-right: 5px; | ||
|
||
&:first-child { | ||
margin-right: 0; | ||
} | ||
} | ||
|
||
textarea { | ||
resize: none; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
app/scripts/components/ui/search/templates/search-bar.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<div class="row search-bar"> | ||
<div class="col-sm-12 pull-right" | ||
data-ng-class="{ 'col-lg-10 col-md-8 col-sm-12': !$parent.advancedQuery, 'col-lg-12 col-md-12': $parent.advancedQuery }"> | ||
<div class="row"> | ||
<div class="col-lg-10 col-md-9 col-sm-9"> | ||
<div class="row" data-ng-if="!$parent.advancedQuery"> | ||
<div class="col-lg-12 col-md-12 col-sm-12"> | ||
<current-filters class="current-filters"></current-filters> | ||
</div> | ||
</div> | ||
<div class="row" data-ng-if="$parent.advancedQuery" > | ||
<div class="col-lg-11 col-md-11 col-sm-11"> | ||
<textarea class="form-control" | ||
data-ng-model="sb.query" | ||
type="text" | ||
aria-label="Advanced Query" | ||
placeholder="Start Typing Your Query...." | ||
role="search"> | ||
</textarea> | ||
</div> | ||
<div class="col-lg-1 col-md-1 col-sm-1 no-padding-left"> | ||
<button class="btn btn-default" data-ng-if="$parent.advancedQuery" data-translate | ||
data-ng-click="sb.sendQuery()">Search</button> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="col-lg-2 col-md-3 col-sm-3" data-ng-if="sb.isSearchQuery"> | ||
<button class="btn btn-default pull-right" | ||
data-ng-click="sb.resetQuery()" | ||
aria-label="{{ 'Clear Query' | translate }}" data-translate> | ||
Clear | ||
</button> | ||
<button class="btn btn-default pull-right" | ||
aria-label="{{ 'Share Query' | translate }}" data-translate> | ||
Share | ||
</button> | ||
<button class="btn btn-default pull-right" data-ng-click="sb.toggle(true)" | ||
data-ng-if="!$parent.advancedQuery" data-translate> | ||
Advanced | ||
</button> | ||
<button class="btn btn-default pull-right" data-ng-click="sb.toggle(false)" | ||
data-ng-disabled="sb.query" | ||
data-ng-if="$parent.advancedQuery" data-translate> | ||
Basic | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.