forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
editLink.js
54 lines (51 loc) · 1.71 KB
/
editLink.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
'use strict';
angular.module("openshiftConsole")
.directive("editLink", function ($uibModal, Logger) {
return {
restrict: "E",
scope: {
resource: "=",
kind: "@",
alerts: "=?"
},
templateUrl: "views/directives/edit-link.html",
// Replace so ".dropdown-menu > li > a" styles are applied.
replace: true,
link: function(scope) {
scope.openEditModal = function() {
// Clear any previous edit success message to avoid confusion if the edit is cancelled
if (scope.alerts) {
delete scope.alerts['edit-yaml'];
}
var modalInstance = $uibModal.open({
animation: true,
templateUrl: 'views/modals/edit-resource.html',
controller: 'EditModalController',
scope: scope,
size: 'lg',
backdrop: 'static' // don't close modal and lose edits when clicking backdrop
});
modalInstance.result.then(function(result) {
if (scope.alerts) {
switch (result) {
case 'no-changes':
scope.alerts['edit-yaml'] = {
type: "warning",
message: "There were no changes to " + scope.resource.metadata.name + " to save. Edit cancelled."
};
break;
case 'save':
scope.alerts['edit-yaml'] = {
type: "success",
message: scope.resource.metadata.name + " was updated."
};
break;
default:
Logger.warn('Unknown edit modal result: ' + result);
}
}
});
};
}
};
});