From b0bceefc0e83b205f7b5d295fa0f5e1d72845c47 Mon Sep 17 00:00:00 2001 From: Benjamin Gamard Date: Thu, 15 Mar 2018 12:28:55 +0100 Subject: [PATCH] Closes #174, closes #176: add a tag from the navigation --- .../app/docs/controller/document/Document.js | 23 +++++++++++++++++++ .../document/DocumentModalAddTag.js | 11 +++++++++ .../webapp/src/app/docs/controller/tag/Tag.js | 2 +- docs-web/src/main/webapp/src/index.html | 1 + .../src/partial/docs/document.add.tag.html | 19 +++++++++++++++ .../webapp/src/partial/docs/document.html | 10 ++++++++ .../src/main/webapp/src/partial/docs/tag.html | 2 +- .../src/main/webapp/src/style/colorpicker.css | 1 + docs-web/src/main/webapp/src/style/main.less | 10 ++++++++ 9 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 docs-web/src/main/webapp/src/app/docs/controller/document/DocumentModalAddTag.js create mode 100644 docs-web/src/main/webapp/src/partial/docs/document.add.tag.html diff --git a/docs-web/src/main/webapp/src/app/docs/controller/document/Document.js b/docs-web/src/main/webapp/src/app/docs/controller/document/Document.js index e5e45180..4276a661 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/document/Document.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/document/Document.js @@ -338,4 +338,27 @@ angular.module('docs').controller('Document', function ($scope, $rootScope, $tim return _.pluck(children, 'name').join(', ') + (tag.children.length > 2 ? '...' : ''); }; + + /** + * Add a tag in the current navigation context. + */ + $scope.addTagHere = function () { + $uibModal.open({ + templateUrl: 'partial/docs/document.add.tag.html', + controller: 'DocumentModalAddTag' + }).result.then(function (tag) { + if (tag === null) { + return; + } + + // Create the tag + tag.parent = $scope.navigatedTag ? $scope.navigatedTag.id : undefined; + Restangular.one('tag').put(tag).then(function (data) { + // Add the new tag to the list + tag.id = data.id; + tag.children = []; + $scope.tags.push(tag); + }) + }); + }; }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentModalAddTag.js b/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentModalAddTag.js new file mode 100644 index 00000000..e78d0c8f --- /dev/null +++ b/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentModalAddTag.js @@ -0,0 +1,11 @@ +'use strict'; + +/** + * Document modal add tag controller. + */ +angular.module('docs').controller('DocumentModalAddTag', function ($scope, $uibModalInstance) { + $scope.tag = { name: '', color: '#3a87ad' }; + $scope.close = function(tag) { + $uibModalInstance.close(tag); + } +}); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/app/docs/controller/tag/Tag.js b/docs-web/src/main/webapp/src/app/docs/controller/tag/Tag.js index b652b868..86338a63 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/tag/Tag.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/tag/Tag.js @@ -3,7 +3,7 @@ /** * Tag controller. */ -angular.module('docs').controller('Tag', function($scope, Restangular, $state) { +angular.module('docs').controller('Tag', function($scope, Restangular) { $scope.tag = { name: '', color: '#3a87ad' }; // Retrieve tags diff --git a/docs-web/src/main/webapp/src/index.html b/docs-web/src/main/webapp/src/index.html index b63cd652..f6b70f99 100644 --- a/docs-web/src/main/webapp/src/index.html +++ b/docs-web/src/main/webapp/src/index.html @@ -66,6 +66,7 @@ + diff --git a/docs-web/src/main/webapp/src/partial/docs/document.add.tag.html b/docs-web/src/main/webapp/src/partial/docs/document.add.tag.html new file mode 100644 index 00000000..993c9724 --- /dev/null +++ b/docs-web/src/main/webapp/src/partial/docs/document.add.tag.html @@ -0,0 +1,19 @@ + +
+ + +
diff --git a/docs-web/src/main/webapp/src/partial/docs/document.html b/docs-web/src/main/webapp/src/partial/docs/document.html index 7580c0d9..aa13682d 100644 --- a/docs-web/src/main/webapp/src/partial/docs/document.html +++ b/docs-web/src/main/webapp/src/partial/docs/document.html @@ -174,12 +174,22 @@ ng-if="navigatedTag"> + + + diff --git a/docs-web/src/main/webapp/src/partial/docs/tag.html b/docs-web/src/main/webapp/src/partial/docs/tag.html index addc048f..a2f3e2dc 100644 --- a/docs-web/src/main/webapp/src/partial/docs/tag.html +++ b/docs-web/src/main/webapp/src/partial/docs/tag.html @@ -20,7 +20,7 @@ ng-maxlength="36" required ng-model="tag.name" ui-validate="{ space: '!$value || $value.indexOf(\' \') == -1' }"> {{ 'add' | translate }}

- {{ 'validation.no_space' | translate }} + {{ 'validation.no_space' | translate }}