Added auto complete for group selection (backend to be implemented soon)

pull/24/head
Jordan 2014-02-24 11:03:20 -06:00
parent 77ea41c2f9
commit 445bdd90a9
3 changed files with 7 additions and 7 deletions

View File

@ -20,7 +20,7 @@ app.factory('GroupService', function($resource) {
}); });
}); });
app.controller('CampaignCtrl', function($scope, CampaignService, ngTableParams) { app.controller('CampaignCtrl', function($scope, CampaignService, ngTableParams, $http) {
$scope.flashes = [] $scope.flashes = []
$scope.mainTableParams = new ngTableParams({ $scope.mainTableParams = new ngTableParams({
page: 1, // show first page page: 1, // show first page
@ -76,14 +76,14 @@ app.controller('CampaignCtrl', function($scope, CampaignService, ngTableParams)
}); });
$scope.getGroups = function(val) { $scope.getGroups = function(val) {
return $http.get('/api/groups/lookup/', { return $http.get('/api/groups/?api_key=' + API_KEY, {
params: { params: {
q: val q: val
} }
}).then(function(res) { }).then(function(res) {
var groups = []; var groups = [];
angular.forEach(res.data.groups, function(item) { angular.forEach(res.data, function(item) {
addresses.push(item.group); groups.push(item);
}); });
return groups; return groups;
}); });

File diff suppressed because one or more lines are too long

View File

@ -70,7 +70,7 @@
<label class="control-label" for="users">Groups:</label> <label class="control-label" for="users">Groups:</label>
<form ng:submit="addGroup()"> <form ng:submit="addGroup()">
<div class="input-group"> <div class="input-group">
<input type="text" class="form-control" placeholder="Group Name" id="users" ng-model="group.name" /> <input type="text" class="form-control" placeholder="Group Name" id="users" typeahead="group.name for group in getGroups($viewValue)" typeahead-editable="false" ng-model="group.name" />
<span class="input-group-btn"> <span class="input-group-btn">
<button class="btn btn-primary"><i class="fa fa-plus"></i> Add</button> <button class="btn btn-primary"><i class="fa fa-plus"></i> Add</button>
</span> </span>