mirror of
https://github.com/sismics/docs.git
synced 2025-12-29 09:31:45 +00:00
Closes #305: exclude tags from search
This commit is contained in:
@@ -459,11 +459,15 @@ public class DocumentResource extends BaseResource {
|
||||
|
||||
switch (params[0]) {
|
||||
case "tag":
|
||||
case "!tag":
|
||||
// New tag criteria
|
||||
List<TagDto> tagDtoList = TagUtil.findByName(params[1], allTagDtoList);
|
||||
if (documentCriteria.getTagIdList() == null) {
|
||||
documentCriteria.setTagIdList(new ArrayList<>());
|
||||
}
|
||||
if (documentCriteria.getExcludedTagIdList() == null) {
|
||||
documentCriteria.setExcludedTagIdList(new ArrayList<>());
|
||||
}
|
||||
if (tagDtoList.isEmpty()) {
|
||||
// No tag found, the request must returns nothing
|
||||
documentCriteria.getTagIdList().add(Lists.newArrayList(UUID.randomUUID().toString()));
|
||||
@@ -476,7 +480,11 @@ public class DocumentResource extends BaseResource {
|
||||
tagIdList.add(childrenTagDto.getId());
|
||||
}
|
||||
}
|
||||
documentCriteria.getTagIdList().add(tagIdList);
|
||||
if (params[0].startsWith("!")) {
|
||||
documentCriteria.getExcludedTagIdList().add(tagIdList);
|
||||
} else {
|
||||
documentCriteria.getTagIdList().add(tagIdList);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "after":
|
||||
|
||||
@@ -319,9 +319,9 @@ angular.module('docs').controller('Document', function ($scope, $rootScope, $tim
|
||||
*/
|
||||
$scope.extractNavigatedTag = function () {
|
||||
// Find the current tag in the search query
|
||||
var tagFound = /tag:([^ ]*)/.exec($scope.search);
|
||||
var tagFound = /(^| )tag:([^ ]*)/.exec($scope.search);
|
||||
if (tagFound) {
|
||||
tagFound = tagFound[1];
|
||||
tagFound = tagFound[2];
|
||||
// We search only for exact match
|
||||
$scope.navigatedTag = _.findWhere($scope.tags, { name: tagFound });
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user