diff --git a/frontend/app/index.html b/frontend/app/index.html index 13fb45716f..21cd7b77a2 100644 --- a/frontend/app/index.html +++ b/frontend/app/index.html @@ -213,6 +213,7 @@ + diff --git a/frontend/app/scripts/components/organisation/OrgCaseTemplateListCmp.js b/frontend/app/scripts/components/organisation/OrgCaseTemplateListCmp.js index 2eca269f62..32164cf4a9 100644 --- a/frontend/app/scripts/components/organisation/OrgCaseTemplateListCmp.js +++ b/frontend/app/scripts/components/organisation/OrgCaseTemplateListCmp.js @@ -3,7 +3,7 @@ angular.module('theHiveComponents') .component('orgCaseTemplateList', { - controller: function($uibModal, $scope, CaseTemplateSrv, TagSrv, UserSrv, AuthenticationSrv, NotificationSrv, UtilsSrv, ModalUtilsSrv) { + controller: function($uibModal, $scope, $filter, CaseTemplateSrv, TagSrv, UserSrv, TaxonomyCacheSrv, AuthenticationSrv, NotificationSrv, UtilsSrv, ModalUtilsSrv) { var self = this; self.task = ''; @@ -121,6 +121,40 @@ }); }; + self.fromTagLibrary = function() { + var modalInstance = $uibModal.open({ + controller: 'TaxonomySelectionModalCtrl', + controllerAs: '$modal', + animation: true, + templateUrl: 'views/partials/misc/taxonomy-selection.modal.html', + size: 'lg', + resolve: { + taxonomies: function() { + return TaxonomyCacheSrv.all(); + } + } + }); + + modalInstance.result + .then(function(selectedTags) { + var filterFn = $filter('tagValue'), + tags = []; + + _.each(selectedTags, function(tag) { + tags.push({ + text: filterFn(tag) + }); + }); + + self.tags = self.tags.concat(tags); + }) + .catch(function(err) { + if (err && !_.isString(err)) { + NotificationSrv.error('Tag selection', err.data, err.status); + } + }); + }; + self.newTemplate = function() { self.template = { name: '', diff --git a/frontend/app/scripts/controllers/case/CaseCreationCtrl.js b/frontend/app/scripts/controllers/case/CaseCreationCtrl.js index ec75824b87..a8e8a4acf6 100644 --- a/frontend/app/scripts/controllers/case/CaseCreationCtrl.js +++ b/frontend/app/scripts/controllers/case/CaseCreationCtrl.js @@ -4,7 +4,7 @@ (function () { 'use strict'; angular.module('theHiveControllers').controller('CaseCreationCtrl', - function ($rootScope, $scope, $uibModalInstance, CaseSrv, NotificationSrv, TagSrv, template) { + function ($rootScope, $scope, $uibModal, $filter, $uibModalInstance, CaseSrv, TaxonomyCacheSrv, NotificationSrv, TagSrv, template) { $rootScope.title = 'New case'; $scope.activeTlp = 'active'; @@ -18,6 +18,8 @@ $scope.template = template; $scope.fromTemplate = angular.isDefined(template) && !_.isEqual($scope.template, {}); + $scope.tags = []; + if ($scope.fromTemplate === true) { // Set basic info from template @@ -37,7 +39,7 @@ $scope.tasks = _.map(template.tasks, function (t) { return t.title; }); - + } else { $scope.tasks = []; $scope.newCase = { @@ -86,6 +88,40 @@ }); }; + $scope.fromTagLibrary = function() { + var modalInstance = $uibModal.open({ + controller: 'TaxonomySelectionModalCtrl', + controllerAs: '$modal', + animation: true, + templateUrl: 'views/partials/misc/taxonomy-selection.modal.html', + size: 'lg', + resolve: { + taxonomies: function() { + return TaxonomyCacheSrv.all(); + } + } + }); + + modalInstance.result + .then(function(selectedTags) { + var filterFn = $filter('tagValue'), + tags = []; + + _.each(selectedTags, function(tag) { + tags.push({ + text: filterFn(tag) + }); + }); + + $scope.tags = $scope.tags.concat(tags); + }) + .catch(function(err) { + if (err && !_.isString(err)) { + NotificationSrv.error('Tag selection', err.data, err.status); + } + }); + }; + $scope.addTask = function (task) { if ($scope.tasks.indexOf(task) === -1) { $scope.tasks.push(task); diff --git a/frontend/app/scripts/controllers/case/ObservableCreationCtrl.js b/frontend/app/scripts/controllers/case/ObservableCreationCtrl.js index 03a3548272..1089978cf1 100644 --- a/frontend/app/scripts/controllers/case/ObservableCreationCtrl.js +++ b/frontend/app/scripts/controllers/case/ObservableCreationCtrl.js @@ -5,7 +5,7 @@ 'use strict'; angular.module('theHiveControllers').controller('ObservableCreationCtrl', - function($scope, $stateParams, $uibModalInstance, clipboard, CaseArtifactSrv, ObservableTypeSrv, NotificationSrv, TagSrv, params) { + function($scope, $stateParams, $uibModal, $uibModalInstance, $filter, TaxonomyCacheSrv, clipboard, CaseArtifactSrv, ObservableTypeSrv, NotificationSrv, TagSrv, params) { $scope.activeTlp = 'active'; $scope.pendingAsync = false; @@ -64,6 +64,40 @@ })), '', null, undefined).length; }; + $scope.fromTagLibrary = function() { + var modalInstance = $uibModal.open({ + controller: 'TaxonomySelectionModalCtrl', + controllerAs: '$modal', + animation: true, + templateUrl: 'views/partials/misc/taxonomy-selection.modal.html', + size: 'lg', + resolve: { + taxonomies: function() { + return TaxonomyCacheSrv.all(); + } + } + }); + + modalInstance.result + .then(function(selectedTags) { + var filterFn = $filter('tagValue'), + tags = []; + + _.each(selectedTags, function(tag) { + tags.push({ + text: filterFn(tag) + }); + }); + + $scope.params.tags = $scope.params.tags.concat(tags); + }) + .catch(function(err) { + if (err && !_.isString(err)) { + NotificationSrv.error('Tag selection', err.data, err.status); + } + }); + }; + $scope.add = function(form) { if (!form.$valid) { return; diff --git a/frontend/app/scripts/controllers/misc/TaxonomySelectionModalCtrl.js b/frontend/app/scripts/controllers/misc/TaxonomySelectionModalCtrl.js new file mode 100644 index 0000000000..4f8c655642 --- /dev/null +++ b/frontend/app/scripts/controllers/misc/TaxonomySelectionModalCtrl.js @@ -0,0 +1,34 @@ +(function() { + 'use strict'; + angular.module('theHiveDirectives') + .controller('TaxonomySelectionModalCtrl', function($uibModalInstance, taxonomies) { + var self = this; + + this.taxonomies = angular.copy(taxonomies); + + this.formData = { + selectedTaxonomy: null, + selectedTags: null + }; + + this.addSelectedTags = function() { + if (!self.formData.selectedTaxonomy) { + return; + } + + var selection = _.filter(self.formData.selectedTaxonomy.tags, function(tag) { + return tag.selected; + }); + + if (selection.length === 0) { + return; + } + + $uibModalInstance.close(selection); + }; + + this.cancel = function() { + $uibModalInstance.dismiss(); + }; + }); +})(); diff --git a/frontend/app/scripts/directives/updatableTagList.js b/frontend/app/scripts/directives/updatableTagList.js index 516de74754..4e68fc36c4 100644 --- a/frontend/app/scripts/directives/updatableTagList.js +++ b/frontend/app/scripts/directives/updatableTagList.js @@ -1,36 +1,6 @@ (function() { 'use strict'; angular.module('theHiveDirectives') - .controller('UpdatableTagListModalCtrl', function($uibModalInstance, taxonomies) { - var self = this; - - this.taxonomies = angular.copy(taxonomies); - - this.formData = { - selectedTaxonomy: null, - selectedTags: null - }; - - this.addSelectedTags = function() { - if (!self.formData.selectedTaxonomy) { - return; - } - - var selection = _.filter(self.formData.selectedTaxonomy.tags, function(tag) { - return tag.selected; - }); - - if (selection.length === 0) { - return; - } - - $uibModalInstance.close(selection); - }; - - this.cancel = function() { - $uibModalInstance.dismiss(); - }; - }) .directive('updatableTagList', function(UtilsSrv, $uibModal, $filter, NotificationSrv, TaxonomyCacheSrv) { return { restrict: 'E', @@ -53,10 +23,10 @@ this.state.type = 'library'; var modalInstance = $uibModal.open({ - controller: 'UpdatableTagListModalCtrl', + controller: 'TaxonomySelectionModalCtrl', controllerAs: '$modal', animation: true, - templateUrl: 'views/directives/updatable-tag-list-modal.html', + templateUrl: 'views/partials/misc/taxonomy-selection.modal.html', size: 'lg', resolve: { taxonomies: function() { diff --git a/frontend/app/views/components/org/case-template/details.html b/frontend/app/views/components/org/case-template/details.html index cf7d7403fa..8c24938b5c 100644 --- a/frontend/app/views/components/org/case-template/details.html +++ b/frontend/app/views/components/org/case-template/details.html @@ -61,10 +61,29 @@
These will be the default case tags
+ + + + + +