Skip to content

Commit

Permalink
add missing editUserModal function
Browse files Browse the repository at this point in the history
  • Loading branch information
v1r0x committed Jul 11, 2017
1 parent 806d9ea commit fe51965
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
25 changes: 25 additions & 0 deletions app.js
Expand Up @@ -56,6 +56,31 @@ thesaurexApp.service('modalFactory', ['$uibModal', function($uibModal) {
});
modalInstance.result.then(function() {}, function() {});
};
this.editUserModal = function(onEdit, user, index) {
var modalInstance = $uibModal.open({
templateUrl: 'layouts/edit-user.html',
controller: function($uibModalInstance) {
this.userinfo = angular.copy(user);
this.cancel = function(result) {
$uibModalInstance.dismiss('cancel');
};
this.onEdit = function(userinfo) {
var changes = {};
for(var key in user) {
if(user.hasOwnProperty(key)) {
if(user[key] != userinfo[key]) {
changes[key] = userinfo[key];
}
}
}
onEdit(changes, user.id, index);
$uibModalInstance.dismiss('ok');
};
},
controllerAs: 'mc'
});
modalInstance.result.then(function() {}, function() {});
};
this.errorModal = function(msg) {
var modalInstance = $uibModal.open({
templateUrl: 'layouts/error.html',
Expand Down
44 changes: 44 additions & 0 deletions layouts/edit-user.html
@@ -0,0 +1,44 @@
<div class="modal-header">
<h4>Edit User</h4>
</div>
<div class="modal-body">
<div class="col-md-12">
<form class="form-horizontal" role="form">
<div class="form-group">
<label class="control-label col-md-3" for="name">
Username:
</label>
<!--<div class="col-md-9">
<input class="form-control" type="text" id="name" ng-model="mc.userinfo.name" />
</div>-->
<p class="form-control-static">
{{ mc.userinfo.name }}
</p>
</div>
<div class="form-group">
<label class="control-label col-md-3" for="email">
Email Address
</label>
<!--<div class="col-md-9">
<input class="form-control" type="email" id="email" ng-model="mc.userinfo.email" />
</div>-->
<p class="form-control-static">
{{ mc.userinfo.email }}
</p>
</div>
<div class="form-group">
<label class="control-label col-md-3" for="password">
New Password:
</label>
<div class="col-md-9">
<input class="form-control" type="password" id="password" ng-model="mc.userinfo.password" />
</div>
</div>
</form>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-success" ng-click="mc.onEdit(mc.userinfo)">Save</button>
<button type="button" class="btn btn-danger"
ng-click="mc.cancel()">Cancel</button>
</div>

0 comments on commit fe51965

Please sign in to comment.