Revision 58410
Added by Michele Artini about 4 years ago
organizations.js | ||
---|---|---|
43 | 43 |
} |
44 | 44 |
}); |
45 | 45 |
|
46 |
orgsModule.directive('resolveConflictsModal', function($http) { |
|
46 |
orgsModule.directive('resolveConflictsModal', function($http, $route) {
|
|
47 | 47 |
return { |
48 | 48 |
restrict: 'E', |
49 | 49 |
scope: { |
50 |
'modalId' : '@', |
|
51 |
'orgs' : '=', |
|
52 |
'selectedOrgs': '=' |
|
50 |
'modalId' : '@',
|
|
51 |
'orgs' : '=',
|
|
52 |
'selectedOrgs' : '='
|
|
53 | 53 |
}, |
54 | 54 |
templateUrl: 'resources/html/modals/resolve_conflicts.html', |
55 | 55 |
link: function(scope, element, attrs, ctrl) { |
... | ... | |
67 | 67 |
} |
68 | 68 |
|
69 | 69 |
scope.createGroup = function() { |
70 |
alert('todo'); |
|
70 |
var masterId = ''; |
|
71 |
var otherIds = []; |
|
72 |
angular.forEach(scope.selectedOrgs, function(o, pos) { |
|
73 |
if (pos == 0) { masterId = o.id; } |
|
74 |
else { otherIds.push(o.id); } |
|
75 |
}); |
|
76 |
if (masterId && otherIds.length > 0) { |
|
77 |
$http.defaults.headers.post["Content-Type"] = "application/json;charset=UTF-8"; |
|
78 |
$http.post('api/organizations/conflicts/fix/' + masterId, otherIds).then(function successCallback(res) { |
|
79 |
if ((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); } |
|
80 |
$('#' + scope.modalId).modal('hide'); |
|
81 |
$('#' + scope.modalId).on('hidden.bs.modal', function (e) { |
|
82 |
$route.reload(); |
|
83 |
}); |
|
84 |
}, function errorCallback(res) { |
|
85 |
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')'); |
|
86 |
}); |
|
87 |
} |
|
71 | 88 |
} |
72 | 89 |
} |
73 | 90 |
} |
Also available in: Unified diff
save relations