|
1 | 1 | (function() {
|
2 | 2 | 'use strict';
|
3 | 3 |
|
4 |
| - angular.module('theHiveControllers').controller('CaseDetailsCtrl', |
5 |
| - function($scope, $state, $uibModal, CaseTabsSrv, UserInfoSrv, PSearchSrv) { |
| 4 | + angular.module('theHiveControllers').controller('CaseDetailsCtrl', function($scope, $state, $uibModal, CaseTabsSrv, UserInfoSrv, PSearchSrv) { |
6 | 5 |
|
7 |
| - CaseTabsSrv.activateTab($state.current.data.tab); |
| 6 | + CaseTabsSrv.activateTab($state.current.data.tab); |
8 | 7 |
|
9 |
| - $scope.isDefined = false; |
10 |
| - $scope.state = { |
11 |
| - 'editing': false, |
12 |
| - 'isCollapsed': true |
13 |
| - }; |
| 8 | + $scope.isDefined = false; |
| 9 | + $scope.state = { |
| 10 | + 'editing': false, |
| 11 | + 'isCollapsed': true |
| 12 | + }; |
14 | 13 |
|
15 |
| - $scope.attachments = PSearchSrv($scope.caseId, 'case_task_log', { |
16 |
| - scope: $scope, |
17 |
| - filter: { |
18 |
| - '_and': [{ |
| 14 | + $scope.attachments = PSearchSrv($scope.caseId, 'case_task_log', { |
| 15 | + scope: $scope, |
| 16 | + filter: { |
| 17 | + '_and': [ |
| 18 | + { |
19 | 19 | '_not': {
|
20 | 20 | 'status': 'Deleted'
|
21 | 21 | }
|
|
33 | 33 | }
|
34 | 34 | }
|
35 | 35 | }
|
36 |
| - }] |
37 |
| - }, |
38 |
| - pageSize: 100, |
39 |
| - nparent: 1 |
40 |
| - }); |
41 |
| - |
42 |
| - $scope.hasNoMetrics = function(caze) { |
43 |
| - return !caze.metrics || _.keys(caze.metrics).length === 0 || caze.metrics.length === 0; |
44 |
| - }; |
45 |
| - |
46 |
| - $scope.addMetric = function(metric) { |
47 |
| - var modalInstance = $uibModal.open({ |
48 |
| - scope: $scope, |
49 |
| - templateUrl: 'views/partials/case/case.add.metric.html', |
50 |
| - controller: 'CaseAddMetricConfirmCtrl', |
51 |
| - size: '', |
52 |
| - resolve: { |
53 |
| - metric: function() { |
54 |
| - return metric; |
55 |
| - } |
56 | 36 | }
|
57 |
| - }); |
| 37 | + ] |
| 38 | + }, |
| 39 | + pageSize: 100, |
| 40 | + nparent: 1 |
| 41 | + }); |
58 | 42 |
|
59 |
| - modalInstance.result.then(function() { |
60 |
| - if (!$scope.caze.metrics) { |
61 |
| - $scope.caze.metrics = {}; |
| 43 | + $scope.hasNoMetrics = function(caze) { |
| 44 | + return !caze.metrics || _.keys(caze.metrics).length === 0 || caze.metrics.length === 0; |
| 45 | + }; |
| 46 | + |
| 47 | + $scope.addMetric = function(metric) { |
| 48 | + var modalInstance = $uibModal.open({ |
| 49 | + scope: $scope, |
| 50 | + templateUrl: 'views/partials/case/case.add.metric.html', |
| 51 | + controller: 'CaseAddMetadataConfirmCtrl', |
| 52 | + size: '', |
| 53 | + resolve: { |
| 54 | + data: function() { |
| 55 | + return metric; |
62 | 56 | }
|
63 |
| - $scope.caze.metrics[metric.name] = null; |
64 |
| - $scope.updateField('metrics', $scope.caze.metrics); |
65 |
| - $scope.updateMetricsList(); |
66 |
| - }); |
67 |
| - }; |
68 |
| - |
69 |
| - $scope.openAttachment = function(attachment) { |
70 |
| - $state.go('app.case.tasks-item', { |
71 |
| - caseId: $scope.caze.id, |
72 |
| - itemId: attachment.case_task.id |
73 |
| - }); |
74 |
| - }; |
| 57 | + } |
| 58 | + }); |
| 59 | + |
| 60 | + modalInstance.result.then(function() { |
| 61 | + if (!$scope.caze.metrics) { |
| 62 | + $scope.caze.metrics = {}; |
| 63 | + } |
| 64 | + $scope.caze.metrics[metric.name] = null; |
| 65 | + $scope.updateField('metrics', $scope.caze.metrics); |
| 66 | + $scope.updateMetricsList(); |
| 67 | + }); |
| 68 | + }; |
| 69 | + |
| 70 | + $scope.openAttachment = function(attachment) { |
| 71 | + $state.go('app.case.tasks-item', { |
| 72 | + caseId: $scope.caze.id, |
| 73 | + itemId: attachment.case_task.id |
| 74 | + }); |
| 75 | + }; |
| 76 | + }); |
| 77 | + |
| 78 | + angular.module('theHiveControllers').controller('CaseCustomFieldsCtrl', function($scope, $uibModal, CustomFieldsCacheSrv) { |
| 79 | + var getTemplateCustomFields = function(customFields) { |
| 80 | + var result = []; |
| 81 | + |
| 82 | + result = _.pluck(_.sortBy(_.map(customFields, function(definition, name){ |
| 83 | + return { |
| 84 | + name: name, |
| 85 | + order: definition.order |
| 86 | + } |
| 87 | + }), function(item){ |
| 88 | + return item.order; |
| 89 | + }), 'name'); |
| 90 | + |
| 91 | + return result; |
75 | 92 | }
|
76 |
| - ); |
77 | 93 |
|
78 |
| - angular.module('theHiveControllers').controller('CaseAddMetricConfirmCtrl', function($scope, $uibModalInstance, metric) { |
79 |
| - $scope.metric = metric; |
| 94 | + $scope.getCustomFieldName = function(fieldDef) { |
| 95 | + return 'customFields.' + fieldDef.name + '.' + fieldDef.type; |
| 96 | + }; |
| 97 | + |
| 98 | + $scope.addCustomField = function(customField) { |
| 99 | + var modalInstance = $uibModal.open({ |
| 100 | + scope: $scope, |
| 101 | + templateUrl: 'views/partials/case/case.add.field.html', |
| 102 | + controller: 'CaseAddMetadataConfirmCtrl', |
| 103 | + size: '', |
| 104 | + resolve: { |
| 105 | + data: function() { |
| 106 | + return customField; |
| 107 | + } |
| 108 | + } |
| 109 | + }); |
| 110 | + |
| 111 | + modalInstance.result.then(function() { |
| 112 | + var temp = $scope.caze.customFields || {}; |
| 113 | + |
| 114 | + temp[customField.name] = {}; |
| 115 | + temp[customField.name][customField.type] = null; |
| 116 | + temp[customField.name].order = _.keys(temp).length; |
| 117 | + |
| 118 | + $scope.caze.customFields = temp; |
| 119 | + |
| 120 | + $scope.updateField('customFields.', $scope.caze.customFields); |
| 121 | + $scope.updateCustomFieldsList(); |
| 122 | + }); |
| 123 | + }; |
| 124 | + |
| 125 | + $scope.updateCustomFieldsList = function() { |
| 126 | + CustomFieldsCacheSrv.all().then(function(fields) { |
| 127 | + $scope.orderedFields = getTemplateCustomFields($scope.caze.customFields); |
| 128 | + $scope.allCustomFields = _.omit(fields, _.keys($scope.caze.customFields)); |
| 129 | + $scope.customFieldsAvailable = _.keys($scope.allCustomFields).length > 0; |
| 130 | + }); |
| 131 | + }; |
| 132 | + |
| 133 | + $scope.updateCustomFieldsList(); |
| 134 | + }); |
| 135 | + |
| 136 | + angular.module('theHiveControllers').controller('CaseAddMetadataConfirmCtrl', function($scope, $uibModalInstance, data) { |
| 137 | + $scope.data = data; |
80 | 138 |
|
81 | 139 | $scope.cancel = function() {
|
82 |
| - $uibModalInstance.dismiss(metric); |
| 140 | + $uibModalInstance.dismiss(data); |
83 | 141 | };
|
84 | 142 |
|
85 | 143 | $scope.confirm = function() {
|
86 |
| - $uibModalInstance.close(metric); |
| 144 | + $uibModalInstance.close(data); |
87 | 145 | };
|
88 | 146 | });
|
89 | 147 |
|
|
0 commit comments