closes #25: reset query form and refocus it

This commit is contained in:
Davide Alberani 2015-04-19 20:27:49 +02:00
parent ae813cc3b4
commit b2c6b5dd0f
3 changed files with 31 additions and 9 deletions

View file

@ -62,16 +62,16 @@
<p ng-if="person.company || person.job"><i ng-if="person.job">{{person.job}}</i><span ng-if="person.company && person.job">&nbsp;@&nbsp;</span><i ng-if="person.company">{{person.company}}</i></p> <p ng-if="person.company || person.job"><i ng-if="person.job">{{person.job}}</i><span ng-if="person.company && person.job">&nbsp;@&nbsp;</span><i ng-if="person.company">{{person.company}}</i></p>
</td> </td>
<td> <td>
<button class="btn btn-link" name="switch-attended" ng-click="setPersonAttribute(person, 'attended', !person.attended)"><span class="glyphicon {{(person.attended) && 'glyphicon-ok-sign text-success' || 'glyphicon-remove-sign text-danger'}}"></span></button> <button class="btn btn-link" reset-focus name="switch-attended" ng-click="setPersonAttributeAndRefocus(person, 'attended', !person.attended)"><span class="glyphicon {{(person.attended) && 'glyphicon-ok-sign text-success' || 'glyphicon-remove-sign text-danger'}}"></span></button>
</td>
<td ng-repeat="col in customFields">
<span ng-if="col.type == 'boolean'">
<button class="btn btn-link" ng-click="setPersonAttribute(person, col.key, !person[col.key])"><span class="glyphicon {{(person[col.key]) && 'glyphicon-ok-sign text-success' || 'glyphicon-remove-sign text-danger'}}"></span></button>
</span>
<span ng-if="col.type != 'boolean'">
{{person[col.key]}}
</span>
</td> </td>
<td ng-repeat="col in customFields">
<span ng-if="col.type == 'boolean'">
<button class="btn btn-link" ng-click="setPersonAttribute(person, col.key, !person[col.key])"><span class="glyphicon {{(person[col.key]) && 'glyphicon-ok-sign text-success' || 'glyphicon-remove-sign text-danger'}}"></span></button>
</span>
<span ng-if="col.type != 'boolean'">
{{person[col.key]}}
</span>
</td>
<td> <td>
<button ng-click="removeAttendee(person)" type="button" class="btn btn-link glyphicon glyphicon-trash"></button> <button ng-click="removeAttendee(person)" type="button" class="btn btn-link glyphicon glyphicon-trash"></button>
</td> </td>

View file

@ -119,6 +119,8 @@ eventManControllers.controller('EventDetailsCtrl', ['$scope', 'Event', 'Person',
} }
$scope.newPerson = {}; $scope.newPerson = {};
}); });
$scope.query = '';
console.log(angular.element($scope.query));
}; };
$scope.fastAddPerson = function(person, isNew) { $scope.fastAddPerson = function(person, isNew) {
@ -148,6 +150,13 @@ eventManControllers.controller('EventDetailsCtrl', ['$scope', 'Event', 'Person',
}); });
}; };
$scope.focusinControl = {};
$scope.setPersonAttributeAndRefocus = function(person, key, value) {
$scope.setPersonAttribute(person, key, value);
$scope.query = '';
};
$scope.removeAttendee = function(person) { $scope.removeAttendee = function(person) {
Event.deletePerson({ Event.deletePerson({
_id: $stateParams.id, _id: $stateParams.id,

View file

@ -25,3 +25,16 @@ eventManApp.directive('eventmanFocus', function () {
}; };
}); });
eventManApp.directive('resetFocus', function () {
function link(scope, element, attrs) {
element.on('click', function() {
var el = angular.element(document.querySelector('#query-persons'));
el.length && el[0].focus();
});
};
return {
link: link
};
});