Skip to content
This repository was archived by the owner on Nov 9, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions ui/app/header/header-ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
'use strict';

angular.module('demoCat')
.controller('HeaderCtrl', ['$scope', '$http', '$location', 'AuthenticationService', 'ModalService', HeaderCtrl]);
.controller('HeaderCtrl', ['$scope', '$http', '$location', 'AuthenticationService', 'ModalService', 'SearchModel', HeaderCtrl]);

function HeaderCtrl($scope, $http, $location, AuthenticationService, modal) {
function HeaderCtrl($scope, $http, $location, AuthenticationService, modal, model) {

angular.extend($scope, {
logout: logout,
showHelp: showHelp
showHelp: showHelp,
showAll: showAll
});

$scope.$on('showAll', function(){
showAll();
});

$scope.$watch(AuthenticationService.user, function(newValue) {
Expand All @@ -22,6 +27,14 @@
function showHelp() {
modal.show('/views/modals/help.html', 'Help');
}

function showAll() {
if ($location.path() != '/search') {
model.search.results = null;
}
model.qtext= "";
$location.path('/search').search({q:null, clear:'true'});
}
}

}());
8 changes: 7 additions & 1 deletion ui/app/search/search-ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@

(function init() {
model.qtext = model.qtext || $location.search().q || '';

// wire up remote input subscription
remoteInput.initCtrl($scope, model, mlSearch, search);

var oldParams = mlSearch.getParams();
var newParams = mlSearch.getCurrentParams();

if ($location.search().clear == 'true') {
model.search.results = null;
model.qtext= "";
//TODO: set the search box's text to empty.
}

// restore params, if we have cached results, and no params provided
if (model.search.results && _.isEqual( {}, newParams )) {
Expand Down
2 changes: 1 addition & 1 deletion ui/app/views/header/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div class="navbar-form navbar-left">
<ml-remote-input template="/views/header/ml-input-fa.html"></ml-remote-input>
</div>
<a class="btn btn-danger btn-sm btn-create pull-left" ng-href="/search?q=">Show all demos</a>
<a class="btn btn-danger btn-sm btn-create pull-left" ng-click="showAll()">Show all demos</a>

<ul class="nav navbar-nav navbar-right">
<li ng-show="user.isWriter()"><form><a class="btn btn-danger btn-sm btn-create" ng-href="/create">Create</a></form></li>
Expand Down
2 changes: 1 addition & 1 deletion ui/app/views/header/ml-input-fa.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="input-group">
<input ng-model="qtext" type="text" class="form-control" placeholder="Search..." autocomplete="off"
typeahead="suggestion for suggestion in suggest({ val: $viewValue })" typeahead-suggest-on-select="true" typeahead-loading="loadingSuggestions"/>
<a ng-show="qtext" ng-click="qtext = ''; clear()" class="input-group-addon search-input-icon search-input-clear">
<a ng-show="qtext" ng-click="qtext=''; $emit('showAll', {})" class="input-group-addon search-input-icon search-input-clear">
<i class="glyphicon glyphicon-trash"></i>
</a>
<!--span ng-show="loadingSuggestions" class="search-input-icon search-loading form-control-feedback">
Expand Down