diff --git a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/DocumentDao.java b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/DocumentDao.java index c0d8c670..266f196e 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/DocumentDao.java +++ b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/DocumentDao.java @@ -109,16 +109,21 @@ public class DocumentDao { */ public void findByCriteria(PaginatedList paginatedList, DocumentCriteria criteria, SortCriteria sortCriteria) { Map parameterMap = new HashMap(); + List criteriaList = new ArrayList(); StringBuilder sb = new StringBuilder("select d.DOC_ID_C c0, d.DOC_TITLE_C c1, d.DOC_DESCRIPTION_C c2, d.DOC_CREATEDATE_D c3"); sb.append(" from T_DOCUMENT d "); if (criteria.getTagIdList() != null && !criteria.getTagIdList().isEmpty()) { - sb.append(" left join T_DOCUMENT_TAG dt on dt.DOT_IDDOCUMENT_C = d.DOC_ID_C "); + int index = 0; + for (String tagId : criteria.getTagIdList()) { + sb.append(" left join T_DOCUMENT_TAG dt" + index + " on dt" + index + ".DOT_IDDOCUMENT_C = d.DOC_ID_C and dt" + index + ".DOT_IDTAG_C = :tagId" + index + " "); + criteriaList.add("dt" + index + ".DOT_ID_C is not null"); + parameterMap.put("tagId" + index, tagId); + index++; + } } // Adds search criteria - List criteriaList = new ArrayList(); - if (criteria.getUserId() != null) { criteriaList.add("d.DOC_IDUSER_C = :userId"); parameterMap.put("userId", criteria.getUserId()); @@ -135,10 +140,6 @@ public class DocumentDao { criteriaList.add("d.DOC_CREATEDATE_D <= :createDateMax"); parameterMap.put("createDateMax", criteria.getCreateDateMax()); } - if (criteria.getTagIdList() != null && !criteria.getTagIdList().isEmpty()) { - criteriaList.add("dt.DOT_IDTAG_C in :tagIdList"); - parameterMap.put("tagIdList", criteria.getTagIdList()); - } criteriaList.add("d.DOC_DELETEDATE_D is null"); diff --git a/docs-parent/TODO b/docs-parent/TODO index 7816cdce..ede7892f 100644 --- a/docs-parent/TODO +++ b/docs-parent/TODO @@ -1,2 +1 @@ -- Client side search on tags - Server side reordering files \ No newline at end of file diff --git a/docs-web/src/main/webapp/js/controller/Document.js b/docs-web/src/main/webapp/js/controller/Document.js index 9ac30679..d3158bac 100644 --- a/docs-web/src/main/webapp/js/controller/Document.js +++ b/docs-web/src/main/webapp/js/controller/Document.js @@ -22,6 +22,7 @@ App.controller('Document', function($scope, $state, Restangular) { query: '', createDateMin: null, createDateMax: null, + tags: [] }; }; $scope.initSearch(); @@ -38,7 +39,8 @@ App.controller('Document', function($scope, $state, Restangular) { asc: $scope.asc, search: $scope.search.query, create_date_min: $scope.isAdvancedSearchCollapsed || !$scope.search.createDateMin ? null : $scope.search.createDateMin.getTime(), - create_date_max: $scope.isAdvancedSearchCollapsed || !$scope.search.createDateMax ? null : $scope.search.createDateMax.getTime() + create_date_max: $scope.isAdvancedSearchCollapsed || !$scope.search.createDateMax ? null : $scope.search.createDateMax.getTime(), + 'tags[]': $scope.isAdvancedSearchCollapsed ? null : _.pluck($scope.search.tags, 'id') }) .then(function(data) { $scope.documents = data.documents; diff --git a/docs-web/src/main/webapp/partial/directive.selecttag.html b/docs-web/src/main/webapp/partial/directive.selecttag.html index a98fe3ae..5d74d5e9 100644 --- a/docs-web/src/main/webapp/partial/directive.selecttag.html +++ b/docs-web/src/main/webapp/partial/directive.selecttag.html @@ -2,8 +2,5 @@
  • {{ tag.name }}
-

- - -

+ \ No newline at end of file diff --git a/docs-web/src/main/webapp/partial/document.html b/docs-web/src/main/webapp/partial/document.html index 5c40ef0e..3a3c20a9 100644 --- a/docs-web/src/main/webapp/partial/document.html +++ b/docs-web/src/main/webapp/partial/document.html @@ -20,6 +20,12 @@ +
+ +
+ +
+