Commit f7ce5a27 by dileep bhimineni

changes for nested looping

parent fbb7582c
......@@ -24,7 +24,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a data-ui-sref="search" data-ui-sref-active="active"><h1>DGI</h1></a>
<a data-ui-sref="search({ query: '' })" data-ui-sref-active="active"><h1>DGI</h1></a>
</div>
<nav class="collapse navbar-collapse" data-collapse="isCollapsed" data-role="navigation">
<ul class="navbar-nav nav" data-ng-if="isLoggedIn()">
......
......@@ -20,7 +20,7 @@
<div class="col-lg-3">
<h4>Tags</h4>
<div class="list-group">
<a ng-repeat="nav in leftnav" ui-sref="search.results({ query: nav })" class="list-group-item">{{nav}} </a>
<a ng-repeat="nav in leftnav" ui-sref="search({ query: nav })" class="list-group-item">{{nav}} </a>
</div>
</div>
......
......@@ -27,7 +27,6 @@ angular.module('dgc.search').controller('SearchController', ['$scope', '$locatio
$scope.isCollapsed = true;
$scope.currentPage = 1;
$scope.itemsPerPage = 10;
$scope.totalItems = 40;
$scope.filteredResults = [];
$scope.resultRows = [];
......@@ -36,11 +35,6 @@ angular.module('dgc.search').controller('SearchController', ['$scope', '$locatio
$scope.loading = true;
}
});
$scope.$on('$stateChangeSuccess', function(event, toState) {
if (toState.resolve) {
$scope.loading = false;
}
});
$scope.setPage = function(pageNo) {
$scope.currentPage = pageNo;
};
......@@ -49,10 +43,12 @@ angular.module('dgc.search').controller('SearchController', ['$scope', '$locatio
NotificationService.reset();
$scope.limit = 4;
$scope.searchMessage = 'searching...';
$scope.$parent.query = query;
SearchResource.search({
query: query
}, function searchSuccess(response) {
$scope.querySuceess = true;
$scope.resultCount = response.count;
$scope.results = response.results;
$scope.resultRows = $scope.results.rows;
......@@ -78,15 +74,10 @@ angular.module('dgc.search').controller('SearchController', ['$scope', '$locatio
$scope.searchMessage = '0 results matching your search query ' + $scope.query + ' were found';
}
});
$state.go('search.results', {
query: query
}, {
location: 'replace'
});
}, function searchError(err) {
NotificationService.error('Error occurred during executing search query, error status code = ' + err.status + ', status text = ' + err.statusText, false);
});
};
$scope.typeAvailable = function() {
......
......@@ -23,13 +23,9 @@ angular.module('dgc.search').config(['$stateProvider',
function($stateProvider) {
// states for my app
$stateProvider.state('search', {
url: '/search',
url: '/search?query',
templateUrl: '/modules/search/views/search.html',
controller: 'SearchController'
}).state('search.results', {
url: '?query',
templateUrl: '/modules/search/views/searchResult.html',
controller: 'SearchController'
});
controller: 'SearchController',
})
}
]);
......@@ -16,14 +16,14 @@
~ limitations under the License.
-->
<div data-ng-controller="SearchController">
<div>
<div class="search">
<form name="form" novalidate class="container">
<div class="col-lg-7 col-lg-offset-3">
<div class="row input-group">
<input type="text" class="form-control" placeholder="Search" data-ng-model="query" required/>
<span class="input-group-btn">
<button class="btn btn-success" type="submit" data-ng-disabled="form.$invalid" ui-sref="search.results({ query: query })">
<button class="btn btn-success" type="submit" data-ng-disabled="form.$invalid" ui-sref="search({ query: query })">
<i class="glyphicon glyphicon-search white "></i>
</button>
</span>
......@@ -39,7 +39,34 @@
<div data-ng-include="'/modules/navigation/views/navigation.html'"></div>
<div class="col-lg-9" data-ui-view="" ></div>
<div class="col-lg-9" >
<h4 ng-show="searchMessage">{{searchMessage}}</h4>
<ul class="list-unstyled">
<li ng-repeat="result in filteredResults" class="searchresults">
<h4><a data-ui-sref="details({id:result['$id$'].id})">{{result.name}}</a></h4>
<p>{{result.description}}</p>
<span ng-repeat="(key, value) in filterSearchResults(result)" >
<span ng-show="$index < 4"><b>{{key}}: </b>{{value}}{{$index+1 === limit ? '' : ', '}}</span>
</span>
<div collapse="isCollapsed">
<span ng-repeat="(key, value) in filterSearchResults(result)" >
<span ng-show="$index > 4"><b>{{key}}: </b>{{value}}{{$last ? '' : ', '}}</span>
</span>
</div>
<a href ng-show="isCollapsed && (keyLength > 4)" ng-click="doToggle($event,isCollapsed)">..show more</a>
<a href ng-show="!isCollapsed" ng-click="doToggle($event,isCollapsed)">..show less</a>
<h5>Tags : <a ng-repeat="(key, value) in result['$traits$']" data-ui-sref="search.results({query: key})">{{key}}</a> </h5>
<div data-ng-if="!searchTypesAvailable" data-ng-include="'/modules/search/views/types/guid.html'"></div>
</li>
</ul>
<div class="resultsPagination" ng-show='filteredResults.length > 0'>
<pagination total-items="totalItems" items-per-page="itemsPerPage" ng-model="currentPage" ng-change="pageChanged()"></pagination>
<p>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment