Partial work on #36. Created directive and works on Settings page.

This commit is contained in:
kiswa 2014-10-26 21:42:49 -04:00
parent 487985cafc
commit 31aaa0581f
6 changed files with 21 additions and 1 deletions

View File

@ -78,5 +78,6 @@
<script src="js/directives/clickToEdit.js"></script>
<script src="js/directives/onLoadCallback.js"></script>
<script src="js/directives/fileUpload.js"></script>
<script src="js/directives/focus.js"></script>
</body>
</html>

View File

@ -2,6 +2,7 @@ taskBoardControllers.controller('BoardFormSettingsCtrl',
['$scope', 'BoardService',
function ($scope, BoardService) {
$scope.boardFormData = {
setFocus: false,
boardId: 0,
isAdd: true,
name: '',
@ -139,6 +140,7 @@ function ($scope, BoardService) {
$scope.alerts.showAlert({ 'type': 'error', 'text': message });
},
reset: function() {
this.setFocus = true;
this.boardId = 0;
this.isAdd = true;
this.name = '';

View File

@ -2,6 +2,7 @@ taskBoardControllers.controller('UserFormSettingsCtrl',
['$scope', 'UserService',
function ($scope, UserService) {
$scope.userFormData = {
setFocus: false,
userId: 0,
isAdd: true,
username: '',
@ -23,6 +24,7 @@ function ($scope, UserService) {
},
reset: function() {
$('.popover-dismiss').popover();
this.setFocus = true;
this.userId = 0;
this.isAdd = true;
this.username = '';

14
js/directives/focus.js Normal file
View File

@ -0,0 +1,14 @@
taskBoardDirectives.directive('focus', ['$timeout', function($timeout) {
return {
link: function(scope, elem, attrs) {
scope.$watch(attrs.focus, function(val) {
if (angular.isDefined(val) && val) {
$timeout(function() {
elem[0].focus();
scope.$eval(attrs.focus + ' = false');
}, 500);
}
}, true);
}
};
}]);

View File

@ -13,6 +13,7 @@
<div class="form-group" data-ng-class="{ 'has-error': boardFormData.nameError }">
<h5>Board Name</h5>
<input class="form-control" type="text" placeholder="Board Name"
data-focus="boardFormData.setFocus"
data-ng-model="boardFormData.name" data-ng-disabled="boardFormData.isSaving">
</div>
<div class="form-group half-width" data-ng-class="{ 'has-error': boardFormData.lanesError }">

View File

@ -14,7 +14,7 @@
<fieldset data-ng-disabled="userFormData.isSaving">
<div class="form-group" data-ng-class="{ 'has-error': userFormData.usernameError }">
<h5><span data-ng-if="!userFormData.isAdd">Change </span>Username</h5>
<input class="form-control" type="text" placeholder="Username" data-ng-model="userFormData.username">
<input class="form-control" type="text" placeholder="Username" data-ng-model="userFormData.username" data-focus="userFormData.setFocus">
</div>
<div class="form-group" data-ng-class="{ 'has-error': userFormData.passError }">
<h5><span data-ng-if="!userFormData.isAdd">Change </span>Password</h5>