parent
acf24a26ee
commit
e06b4db664
@ -944,40 +944,89 @@ angular.module('OpenSlidesApp.core.site', [
|
||||
.controller('SearchBarCtrl', [
|
||||
'$scope',
|
||||
'$state',
|
||||
function ($scope, $state) {
|
||||
$scope.search = function(query) {
|
||||
$scope.query = '';
|
||||
'$sanitize',
|
||||
function ($scope, $state, $sanitize) {
|
||||
$scope.search = function() {
|
||||
var query = _.escape($scope.querybar);
|
||||
$scope.querybar = '';
|
||||
$state.go('search', {q: query});
|
||||
};
|
||||
}
|
||||
])
|
||||
|
||||
// Search Controller
|
||||
.controller('SearchCtrl', [
|
||||
'$scope',
|
||||
'$http',
|
||||
'$stateParams',
|
||||
'$location',
|
||||
'$sanitize',
|
||||
'DS',
|
||||
function ($scope, $http, $stateParams, DS) {
|
||||
function ($scope, $http, $stateParams, $location, $sanitize, DS) {
|
||||
$scope.fullword = false;
|
||||
$scope.filterAgenda = true;
|
||||
$scope.filterMotion = true;
|
||||
$scope.filterAssignment = true;
|
||||
$scope.filterUser = true;
|
||||
$scope.filterMedia = true;
|
||||
|
||||
// search function
|
||||
$scope.search = function(query) {
|
||||
$http.get('/core/search_api/?q=' + query).then(function(success) {
|
||||
var elements = success.data.elements;
|
||||
$scope.results = [];
|
||||
angular.forEach(elements, function(element) {
|
||||
DS.find(element.collection, element.id).then(function(data) {
|
||||
data.urlState = element.collection.replace('/','.')+'.detail';
|
||||
data.urlParam = {id: element.id};
|
||||
$scope.results.push(data);
|
||||
$scope.search = function() {
|
||||
var query = _.escape($scope.query);
|
||||
if (query !== '') {
|
||||
var lastquery = query;
|
||||
// attach asterisks if search is not for full words only
|
||||
if (!$scope.fullword) {
|
||||
if (query.charAt(0) != '*'){
|
||||
query = "*" + query;
|
||||
}
|
||||
if (query.charAt(query.length - 1) != '*'){
|
||||
query = query + "*";
|
||||
}
|
||||
}
|
||||
$scope.query = lastquery;
|
||||
$http.get('/core/search_api/?q=' + query).then(function(success) {
|
||||
$scope.results = [];
|
||||
var elements = success.data.elements;
|
||||
angular.forEach(elements, function(element) {
|
||||
DS.find(element.collection, element.id).then(function(data) {
|
||||
data.urlState = element.collection.replace('/','.')+'.detail';
|
||||
data.urlParam = {id: element.id};
|
||||
$scope.results.push(data);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
$location.url('/search/?q=' + lastquery);
|
||||
}
|
||||
};
|
||||
|
||||
// run search with get parameter from url
|
||||
//get search string from parameters submitted from outside the scope
|
||||
if ($stateParams.q) {
|
||||
$scope.search($stateParams.q);
|
||||
$scope.query = $stateParams.q;
|
||||
$scope.search();
|
||||
}
|
||||
|
||||
// returns element if part of the current search selection
|
||||
$scope.filterresult = function() {
|
||||
return function(result) {
|
||||
if ($scope.filterUser && result.urlState == 'users.user.detail') {
|
||||
return result;
|
||||
}
|
||||
if ($scope.filterMotion && result.urlState == 'motions.motion.detail') {
|
||||
return result;
|
||||
}
|
||||
if ($scope.filterAgenda && result.urlState == 'core.customslide.detail') {
|
||||
return result;
|
||||
}
|
||||
if ($scope.filterAssignment && result.urlState == 'assignments.assignment.detail') {
|
||||
return result;
|
||||
}
|
||||
if ($scope.filterMedia && result.urlState== 'mediafiles.mediafile.detail') {
|
||||
return result;
|
||||
}
|
||||
return;
|
||||
};
|
||||
};
|
||||
}
|
||||
])
|
||||
|
||||
|
@ -139,9 +139,9 @@
|
||||
</ul>
|
||||
<!-- Search bar -->
|
||||
<div class="searchbar pull-right" ng-controller="SearchBarCtrl">
|
||||
<form ng-submit="search(query); closeMenu()">
|
||||
<form ng-submit="search(); closeMenu()">
|
||||
<div class="input-group">
|
||||
<input ng-model="query" class="form-control" type="text" placeholder="{{ 'Search' | translate}}">
|
||||
<input ng-model="querybar" class="form-control" type="text" placeholder="{{ 'Search' | translate}}">
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" class="btn btn-default">
|
||||
<i class="fa fa-search"></i>
|
||||
|
@ -5,16 +5,43 @@
|
||||
</div>
|
||||
|
||||
<div class="details">
|
||||
<form class="input-group" ng-submit="search(query)">
|
||||
<form class="input-group" ng-submit="search()">
|
||||
<input type="text" ng-model="query" class="form-control">
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" class="btn btn-default" translate>Search</button>
|
||||
</span>
|
||||
</form>
|
||||
|
||||
<div class="searchfilter spacer-top">
|
||||
<label class="checkbox-inline">
|
||||
<input type="checkbox" ng-model="filterAgenda">
|
||||
<translate>Agenda items</translate>
|
||||
</label>
|
||||
<label class="checkbox-inline">
|
||||
<input type="checkbox" ng-model="filterMotion">
|
||||
<translate>Motions</translate>
|
||||
</label>
|
||||
<label class="checkbox-inline">
|
||||
<input type="checkbox" ng-model="filterAssignment">
|
||||
<translate>Elections</translate>
|
||||
</label>
|
||||
<label class="checkbox-inline">
|
||||
<input type="checkbox" ng-model="filterUser">
|
||||
<translate>Participants</translate>
|
||||
</label>
|
||||
<label class="checkbox-inline">
|
||||
<input type="checkbox" ng-model="filterMedia">
|
||||
<translate>Files</translate>
|
||||
</label>
|
||||
<div>
|
||||
<label class="checkbox-inline">
|
||||
<input type="checkbox" ng-model="fullword" ng-change="search()">
|
||||
<translate>Only whole words</translate>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="searchresults spacer-top-lg">
|
||||
<ol ng-show="results">
|
||||
<li ng-repeat="result in results">
|
||||
<li ng-repeat="result in results | filter:filterresult()">
|
||||
<a ng-if="!result.mediafileUrl" ui-sref="{{ result.urlState }}({{ result.urlParam }})">
|
||||
{{ result.getSearchResultName() }}
|
||||
</a>
|
||||
@ -24,6 +51,6 @@
|
||||
<br>
|
||||
<span class="grey">{{ result.getSearchResultSubtitle() | translate }}</span>
|
||||
</ol>
|
||||
<p ng-show="!results" translate>No results.</p>
|
||||
<p ng-show="!results || results.length == 0" translate>No results.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -8,7 +8,7 @@
|
||||
<form name="mediafileForm" ng-submit="save(mediafile)">
|
||||
<!-- file -->
|
||||
<div class="form-group">
|
||||
<label for="inputTitle" translate>File *</label>
|
||||
<label for="inputTitle"><translate>File</translate>*</label>
|
||||
<!-- create view: show file select field -->
|
||||
<input ng-if="!mediafile.id" type="file" ngf-select ng-model="mediafile.newFile" required>
|
||||
<!-- update view: show filename only -->
|
||||
|
Loading…
Reference in New Issue
Block a user