diff --git a/docs-parent/TODO b/docs-parent/TODO index 01a28020..8b224fd8 100644 --- a/docs-parent/TODO +++ b/docs-parent/TODO @@ -1,7 +1,7 @@ -- Client side tags creation/deletion (new settings page) - Client side edition of tags on documents - Client side displaying of tags on documents - Client/server side edition of created date - Client/server side search on tags - Client/server side search on creation date +- Client/server side edition of existing tag names - Server side reordering files \ No newline at end of file diff --git a/docs-web/src/main/java/com/sismics/docs/rest/resource/TagResource.java b/docs-web/src/main/java/com/sismics/docs/rest/resource/TagResource.java index 8213dcc7..e0238fd3 100644 --- a/docs-web/src/main/java/com/sismics/docs/rest/resource/TagResource.java +++ b/docs-web/src/main/java/com/sismics/docs/rest/resource/TagResource.java @@ -51,6 +51,7 @@ public class TagResource extends BaseResource { for (Tag tag : tagList) { JSONObject item = new JSONObject(); item.put("id", tag.getId()); + item.put("name", tag.getName()); items.add(item); } response.put("tags", items); diff --git a/docs-web/src/main/webapp/index.html b/docs-web/src/main/webapp/index.html index 36c2dee3..6155d322 100644 --- a/docs-web/src/main/webapp/index.html +++ b/docs-web/src/main/webapp/index.html @@ -32,7 +32,9 @@ + + @@ -40,6 +42,10 @@
diff --git a/docs-web/src/main/webapp/js/app.js b/docs-web/src/main/webapp/js/app.js index 03a6d37e..282dfc48 100644 --- a/docs-web/src/main/webapp/js/app.js +++ b/docs-web/src/main/webapp/js/app.js @@ -3,7 +3,7 @@ /** * Trackino application. */ -var App = angular.module('docs', ['ui.state', 'ui.bootstrap', 'ui.keypress', 'ui.sortable', 'restangular', 'ngSanitize']) +var App = angular.module('docs', ['ui.state', 'ui.bootstrap', 'ui.route', 'ui.keypress', 'ui.sortable', 'restangular', 'ngSanitize']) /** * Configuring modules. @@ -20,6 +20,15 @@ var App = angular.module('docs', ['ui.state', 'ui.bootstrap', 'ui.keypress', 'ui } } }) + .state('tag', { + url: '/tag', + views: { + 'page': { + templateUrl: 'partial/tag.html', + controller: 'Tag' + } + } + }) .state('document', { url: '/document', abstract: true, diff --git a/docs-web/src/main/webapp/js/controller/Tag.js b/docs-web/src/main/webapp/js/controller/Tag.js new file mode 100644 index 00000000..38c87d33 --- /dev/null +++ b/docs-web/src/main/webapp/js/controller/Tag.js @@ -0,0 +1,33 @@ +'use strict'; + +/** + * Tag controller. + */ +App.controller('Tag', function($scope, $state, Tag, Restangular) { + // Retrieve tags + Tag.tags().then(function(data) { + $scope.tags = data.tags; + }); + + /** + * Add a tag. + */ + $scope.addTag = function() { + var name = $scope.tag.name; + $scope.tag.name = ''; + Restangular.one('tag').put({ name: name }).then(function(data) { + $scope.tags.push({ id: data.id, name: name }); + }); + }; + + /** + * Delete a tag. + */ + $scope.deleteTag = function(tag) { + Restangular.one('tag', tag.id).remove().then(function() { + $scope.tags = _.reject($scope.tags, function(t) { + return tag.id == t.id; + }); + }); + }; +}); \ No newline at end of file diff --git a/docs-web/src/main/webapp/js/service/Tag.js b/docs-web/src/main/webapp/js/service/Tag.js new file mode 100644 index 00000000..567fe9d9 --- /dev/null +++ b/docs-web/src/main/webapp/js/service/Tag.js @@ -0,0 +1,28 @@ +'use strict'; + +/** + * Tag service. + */ +App.factory('Tag', function(Restangular) { + var tags = null; + + return { + /** + * Returns tags. + * @param force If true, force reloading data + */ + tags: function(force) { + if (tags == null || force) { + tags = Restangular.one('tag/list').get(); + } + return tags; + }, + + /** + * Login an user. + */ + login: function(user) { + return Restangular.one('user').post('login', user); + } + } +}); \ No newline at end of file diff --git a/docs-web/src/main/webapp/partial/document.default.html b/docs-web/src/main/webapp/partial/document.default.html index 381c5acf..9323d8cd 100644 --- a/docs-web/src/main/webapp/partial/document.default.html +++ b/docs-web/src/main/webapp/partial/document.default.html @@ -1,6 +1,6 @@ -- {{ documents.total }} document{{ documents.total > 1 ? 's' : '' }} in the database -
+There seems to be a kind of order in the universe, in the movement of the stars and the turning of the earth and the changing of the seasons, and even in the cycle of human life. But human life itself is almost pure chaos. Everyone takes his stance, asserts his own rights and feelings, mistaking the motives of others, and his own.
diff --git a/docs-web/src/main/webapp/partial/tag.html b/docs-web/src/main/webapp/partial/tag.html new file mode 100644 index 00000000..c343de39 --- /dev/null +++ b/docs-web/src/main/webapp/partial/tag.html @@ -0,0 +1,29 @@ ++\ No newline at end of file+++ +++ + + +
+ +{{ tags.length }} Tags
+ ++ + +
+ ++ +
+ ++ + +{{ tag.name }} ++