From a87cdeae73f2cff2c44dc2ce38cd938e7f23de9a Mon Sep 17 00:00:00 2001 From: Nabil Adouani Date: Wed, 27 Jan 2021 14:47:59 +0100 Subject: [PATCH] #1670 Add a UpdatableTagList component to include selection of taxonomy tags --- frontend/app/index.html | 3 + .../scripts/directives/updatableTagList.js | 91 +++++++++++++++++++ frontend/app/scripts/filters/tag-value.js | 18 ++++ .../scripts/services/api/TaxonomyCacheSrv.js | 50 ++++++++++ .../directives/updatable-tag-list-modal.html | 53 +++++++++++ .../views/directives/updatable-tag-list.html | 37 ++++++++ .../app/views/partials/case/case.details.html | 2 +- 7 files changed, 253 insertions(+), 1 deletion(-) create mode 100644 frontend/app/scripts/directives/updatableTagList.js create mode 100644 frontend/app/scripts/filters/tag-value.js create mode 100644 frontend/app/scripts/services/api/TaxonomyCacheSrv.js create mode 100644 frontend/app/views/directives/updatable-tag-list-modal.html create mode 100644 frontend/app/views/directives/updatable-tag-list.html diff --git a/frontend/app/index.html b/frontend/app/index.html index 4768bf07e1..d244e6bc19 100644 --- a/frontend/app/index.html +++ b/frontend/app/index.html @@ -254,6 +254,7 @@ + @@ -276,6 +277,7 @@ + @@ -297,6 +299,7 @@ + diff --git a/frontend/app/scripts/directives/updatableTagList.js b/frontend/app/scripts/directives/updatableTagList.js new file mode 100644 index 0000000000..516de74754 --- /dev/null +++ b/frontend/app/scripts/directives/updatableTagList.js @@ -0,0 +1,91 @@ +(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', + link: UtilsSrv.updatableLink, + templateUrl: 'views/directives/updatable-tag-list.html', + scope: { + value: '=?', + onUpdate: '&', + active: '=?', + source: '=', + clearable: ' + + + + diff --git a/frontend/app/views/directives/updatable-tag-list.html b/frontend/app/views/directives/updatable-tag-list.html new file mode 100644 index 0000000000..83a59e3e15 --- /dev/null +++ b/frontend/app/views/directives/updatable-tag-list.html @@ -0,0 +1,37 @@ +
+ + Not Specified + + {{tag.text}} + + + + + + + +
+ + + +
+
+ + + +
+ +
+ +
+
+
diff --git a/frontend/app/views/partials/case/case.details.html b/frontend/app/views/partials/case/case.details.html index bb252c4fd4..c1f873355e 100644 --- a/frontend/app/views/partials/case/case.details.html +++ b/frontend/app/views/partials/case/case.details.html @@ -71,7 +71,7 @@

Basic Information

Tags
- +