[Search] Search input using the model

Made the search bar text input go to ngModel.input,
rather than getting the text manually from the DOM
element. Additionally, removed the search service
from the search controller's scope.
This commit is contained in:
shale 2015-07-24 13:04:42 -07:00
parent 9143f5febd
commit 05c43db6fe
4 changed files with 34 additions and 15 deletions

View File

@ -21,7 +21,7 @@
],
"controls": [
{
"key": "searchbar",
"key": "searchbar-control",
"templateUrl": "templates/searchbar.html"
}
],

View File

@ -24,13 +24,26 @@
<!-- Search bar input -->
<div>
<input class="search-input"
id="searchbarinput"
type="text"
value=""
ng-keyup="controller.search('searchbarinput')" />
<!--mct-control key="searchbar"
ng-keyup="controller.search('searchbarinput')">asdf
</mct-control-->
ng-model="ngModel.input"
ng-keyup="controller.search()" />
<!--mct-control key="searchbar-control"
ng-model="ngModel"
structure="{cssclass: search-input, size: 50}">asdf
</mct-control>
<mct-control key="textfield"
ng-model="ngModel"
ng-required="false"
ng-pattern=""
structure="{cssclass: search-input, size: 50}">
</mct-control>
<mct-include key="textfield"
ng-model="ngModel"
ng-required="false"
ng-pattern=""
structure="{cssclass: search-input, size: 50}">
</mct-include-->
</div>
<!-- This div exists to determine scroll bar location -->
@ -39,7 +52,7 @@
<!-- Results list -->
<div class="results">
<mct-representation key="'search-item'"
ng-repeat="result in searchService.latestResults"
ng-repeat="result in results"
mct-object="result.object"
ng-model="ngModel">
</mct-representation>

View File

@ -20,7 +20,15 @@
at runtime from the About dialog for additional information.
-->
<input class="search-input"
<!--input class="search-input"
id="searchbarinput"
type="text"
value="" />
value="" /-->
<span class='form-control shell'>
<span class='field control {{structure.cssclass}}'>
<input type="text"
ng-model="ngModel">
</span>
</span>

View File

@ -40,7 +40,7 @@ define(function () {
// This allows us to directly access the search aggregator's members.
// Most important is latestResults, which is continuously updated. This
// means that this controller does not have to poll for results any more.
$scope.searchService = searchService;
//$scope.searchService = searchService;
// TODO: Modify search aggregator to have a search result array which
// is of a size that can be chosen and modified by this controller.
@ -70,10 +70,10 @@ define(function () {
waitForLatest();
}
function search(inputID) {
function search() {
var date = new Date(),
timestamp = date.getTime(),
inputText = document.getElementById(inputID).value;
inputText = $scope.ngModel.input;//document.getElementById(inputID).value;
// Update whether the file tree should be displayed
if (inputText === '') {
@ -94,9 +94,7 @@ define(function () {
return {
/**
* Search the filetree.
*
* @param inputID The name of the ID property of the html text
* input where this funcion should find the search term.
* Assumes that there will be search text in ngModel.input
*/
search: search,