|
4 | 4 |
|
5 | 5 | angular.module('dhib.quickstart.service.modal', ['ui.bootstrap']) |
6 | 6 | .service('ModalService', ModalService) |
7 | | - .controller('loadDataModalController', LoadDataModalController); |
| 7 | + .controller('loadDataModalController', LoadDataModalController) |
| 8 | + .controller('entityModalController', EntityModalController) |
| 9 | + .controller('flowModalController', FlowModalController); |
8 | 10 |
|
9 | 11 | function ModalService($uibModal) { |
10 | 12 | var self = this; |
11 | 13 | angular.extend(self, { |
12 | 14 | openLoadDataModal: openLoadDataModal |
| 15 | + ,openEntityModal: openEntityModal |
| 16 | + ,openFlowModal: openFlowModal |
13 | 17 | }); |
14 | 18 |
|
15 | 19 | function openLoadDataModal() { |
|
24 | 28 |
|
25 | 29 | return modalInstance.result; |
26 | 30 | } |
| 31 | + |
| 32 | + function openEntityModal() { |
| 33 | + var modalInstance = $uibModal.open({ |
| 34 | + animation : true, |
| 35 | + templateUrl : 'top/modal/entityModal.html', |
| 36 | + controller : 'entityModalController', |
| 37 | + size : 'md', |
| 38 | + backdrop : 'static', |
| 39 | + keyboard : true |
| 40 | + }); |
| 41 | + |
| 42 | + return modalInstance.result; |
| 43 | + } |
| 44 | + |
| 45 | + function openFlowModal(entityName, flowType, extension) { |
| 46 | + var modalInstance = $uibModal.open({ |
| 47 | + animation : true, |
| 48 | + templateUrl : 'top/modal/flowModal.html', |
| 49 | + controller : 'flowModalController', |
| 50 | + size : 'sm', |
| 51 | + backdrop : 'static', |
| 52 | + keyboard : true, |
| 53 | + resolve : { |
| 54 | + 'entityName' : function () { |
| 55 | + return entityName; |
| 56 | + } |
| 57 | + ,'flowType' : function () { |
| 58 | + return flowType; |
| 59 | + } |
| 60 | + ,'extension' : function () { |
| 61 | + return extension; |
| 62 | + } |
| 63 | + } |
| 64 | + }); |
| 65 | + |
| 66 | + return modalInstance.result; |
| 67 | + } |
27 | 68 | } |
28 | 69 |
|
29 | 70 | function LoadDataModalController($scope, $uibModalInstance) { |
|
43 | 84 | $uibModalInstance.dismiss(); |
44 | 85 | }; |
45 | 86 | } |
| 87 | + |
| 88 | + function EntityModalController($scope, $uibModalInstance, DataHub) { |
| 89 | + $scope.entityForm = {}; |
| 90 | + $scope.errorMessage =null; |
| 91 | + $scope.hasError = false; |
| 92 | + |
| 93 | + $scope.ok = function () { |
| 94 | + DataHub.saveEntity($scope.entityForm) |
| 95 | + .success(function () { |
| 96 | + $scope.hasError = false; |
| 97 | + |
| 98 | + $uibModalInstance.close($scope.entityForm); |
| 99 | + }) |
| 100 | + .error(function (error) { |
| 101 | + $scope.hasError = true; |
| 102 | + $scope.errorMessage = error.message; |
| 103 | + }) |
| 104 | + .finally(function () { |
| 105 | + $scope.loading = false; |
| 106 | + }); |
| 107 | + }; |
| 108 | + |
| 109 | + $scope.cancel = function () { |
| 110 | + $uibModalInstance.dismiss(); |
| 111 | + }; |
| 112 | + } |
| 113 | + |
| 114 | + function FlowModalController($scope, $uibModalInstance, DataHub, entityName, flowType, extension) { |
| 115 | + $scope.flowForm = { |
| 116 | + 'entityName' : entityName |
| 117 | + ,'flowType' : flowType |
| 118 | + ,'extension' : extension |
| 119 | + }; |
| 120 | + $scope.errorMessage =null; |
| 121 | + $scope.hasError = false; |
| 122 | + |
| 123 | + $scope.ok = function () { |
| 124 | + $scope.loading = true; |
| 125 | + |
| 126 | + DataHub.saveFlow($scope.flowForm) |
| 127 | + .success(function () { |
| 128 | + $scope.hasError = false; |
| 129 | + |
| 130 | + $uibModalInstance.close($scope.flowForm); |
| 131 | + }) |
| 132 | + .error(function (error) { |
| 133 | + $scope.hasError = true; |
| 134 | + $scope.errorMessage = error.message; |
| 135 | + }) |
| 136 | + .finally(function () { |
| 137 | + $scope.loading = false; |
| 138 | + }); |
| 139 | + }; |
| 140 | + |
| 141 | + $scope.cancel = function () { |
| 142 | + $uibModalInstance.dismiss(); |
| 143 | + }; |
| 144 | + } |
46 | 145 |
|
47 | 146 | })(); |
0 commit comments