updates for reload action when editing project-member.

This commit is contained in:
kunw 2016-05-25 12:13:07 +08:00
parent bab38f2514
commit 8d30879fc2
4 changed files with 13 additions and 14 deletions

View File

@ -31,9 +31,6 @@
AddProjectMemberService(vm.projectId, vm.optRole, pm.username) AddProjectMemberService(vm.projectId, vm.optRole, pm.username)
.success(addProjectMemberComplete) .success(addProjectMemberComplete)
.error(addProjectMemberFailed); .error(addProjectMemberFailed);
vm.username = '';
vm.optRole = 1;
vm.reload();
} }
} }
@ -48,6 +45,7 @@
function addProjectMemberComplete(data, status, header) { function addProjectMemberComplete(data, status, header) {
console.log('addProjectMemberComplete: status:' + status + ', data:' + data); console.log('addProjectMemberComplete: status:' + status + ', data:' + data);
vm.reload();
} }
function addProjectMemberFailed(data, status, headers) { function addProjectMemberFailed(data, status, headers) {

View File

@ -28,7 +28,6 @@
function updateProjectMember(e) { function updateProjectMember(e) {
if(vm.editMode) { if(vm.editMode) {
vm.editMode = false;
console.log('update project member, roleId:' + e.roleId); console.log('update project member, roleId:' + e.roleId);
EditProjectMemberService(e.projectId, e.userId, e.roleId) EditProjectMemberService(e.projectId, e.userId, e.roleId)
.success(editProjectMemberComplete) .success(editProjectMemberComplete)
@ -42,12 +41,13 @@
DeleteProjectMemberService(e.projectId, e.userId) DeleteProjectMemberService(e.projectId, e.userId)
.success(editProjectMemberComplete) .success(editProjectMemberComplete)
.error(editProjectMemberFailed); .error(editProjectMemberFailed);
vm.reload();
} }
function editProjectMemberComplete(data, status, headers) { function editProjectMemberComplete(data, status, headers) {
console.log('edit project member complete: ' + status); console.log('edit project member complete: ' + status);
vm.lastRoleName = vm.roleName; vm.lastRoleName = vm.roleName;
vm.editMode = false;
vm.reload();
} }
function editProjectMemberFailed(e) { function editProjectMemberFailed(e) {
@ -56,7 +56,6 @@
function cancelUpdate() { function cancelUpdate() {
vm.editMode = false; vm.editMode = false;
console.log('lastRoleName:' + vm.lastRoleName);
vm.roleName = vm.lastRoleName; vm.roleName = vm.lastRoleName;
} }

View File

@ -16,6 +16,7 @@
vm.currentRole = getRole({'key': 'roleName', 'value': current}); vm.currentRole = getRole({'key': 'roleName', 'value': current});
} }
}); });
vm.selectRole = selectRole; vm.selectRole = selectRole;
function selectRole(role) { function selectRole(role) {

View File

@ -39,19 +39,20 @@
function link(scope, element, attrs, ctrl) { function link(scope, element, attrs, ctrl) {
var visited = ctrl.url.substring(1); var visited = ctrl.url.substring(1);
if(visited.indexOf('?') >= 0) { if(visited.indexOf('?') >= 0) {
visited = ctrl.url.substring(1, ctrl.url.indexOf('?') - 1); visited = ctrl.url.substring(1, ctrl.url.indexOf('?'));
} }
scope.$watch('vm.selectedProject', function(current) { scope.$watch('vm.selectedProject', function(current) {
if(current) { if(current) {
element.find('a').removeClass('active'); element.find('a').removeClass('active');
if(visited) {
element.find('a[tag="' + visited + '"]').addClass('active');
}else{
element.find('a:first').addClass('active'); element.find('a:first').addClass('active');
} }
}
}); });
element.find('a[tag*="' + visited + '"]').addClass('active');
element.find('a').on('click', click); element.find('a').on('click', click);
function click(event) { function click(event) {