# HG changeset patch # User ymh # Date 1365092459 -7200 # Node ID efc0fce30814a70fb8bb536e01715ea4e7b208ac # Parent a822178766cecbfd0fde596a04d0071a8089be40 Add filter on projects diff -r a822178766ce -r efc0fce30814 server/src/main/java/org/iri_research/renkan/controller/RenkanRootController.java --- a/server/src/main/java/org/iri_research/renkan/controller/RenkanRootController.java Thu Apr 04 15:35:15 2013 +0200 +++ b/server/src/main/java/org/iri_research/renkan/controller/RenkanRootController.java Thu Apr 04 18:20:59 2013 +0200 @@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.servlet.ModelAndView; @@ -52,7 +53,7 @@ } @RequestMapping(value="/s/{space_id}", method = RequestMethod.GET, produces={"text/html;charset=UTF-8"}) - public ModelAndView spaceIndex(@PathVariable("space_id") String spaceId, @PageableDefaults(sort={"updated","created"}, sortDir=Direction.DESC, pageNumber=0, value=Constants.PAGINATION_SIZE) Pageable p, HttpServletRequest request) { + public ModelAndView spaceIndex(@PathVariable("space_id") String spaceId, @RequestParam(required=false) String filter, @PageableDefaults(sort={"updated","created"}, sortDir=Direction.DESC, pageNumber=0, value=Constants.PAGINATION_SIZE) Pageable p, HttpServletRequest request) { logger.debug("SpaceId : " + (spaceId== null ? "null" : spaceId)); @@ -69,9 +70,14 @@ } model.put("space", space); - - Page page = this.projectsRepository.findBySpaceId(spaceId, p); - + Page page; + if(filter != null && !filter.isEmpty()) { + page = this.projectsRepository.findBySpaceIdAndTitleRegex(spaceId, filter, p); + } + else { + page = this.projectsRepository.findBySpaceId(spaceId, p); + } + model.put("page", page); model.put("baseUrl", Utils.buildBaseUrl(request)); diff -r a822178766ce -r efc0fce30814 server/src/main/java/org/iri_research/renkan/repositories/ProjectsRepository.java --- a/server/src/main/java/org/iri_research/renkan/repositories/ProjectsRepository.java Thu Apr 04 15:35:15 2013 +0200 +++ b/server/src/main/java/org/iri_research/renkan/repositories/ProjectsRepository.java Thu Apr 04 18:20:59 2013 +0200 @@ -5,9 +5,15 @@ import org.iri_research.renkan.models.Project; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; +import org.springframework.data.mongodb.repository.Query; public interface ProjectsRepository extends IRenkanRepository, ProjectsRepositoryCustom { List findBySpaceId(String spaceId); Page findBySpaceId(String spaceId, Pageable p); + + @Query("{ 'space_id' : ?0, 'title' : { '$regex':?1, '$options': 'i'} }") + List findBySpaceIdAndTitleRegex(String spaceId, String title); + @Query("{ 'space_id' : ?0, 'title' : { '$regex':?1, '$options': 'i'} }") + Page findBySpaceIdAndTitleRegex(String spaceId, String title, Pageable p); } diff -r a822178766ce -r efc0fce30814 server/src/main/webapp/WEB-INF/i18n/messages_en.properties --- a/server/src/main/webapp/WEB-INF/i18n/messages_en.properties Thu Apr 04 15:35:15 2013 +0200 +++ b/server/src/main/webapp/WEB-INF/i18n/messages_en.properties Thu Apr 04 18:20:59 2013 +0200 @@ -17,6 +17,7 @@ renkanIndex.project_delete_link = Delete renkan renkanIndex.project_render_link = View renkan renkanIndex.project_delete_confirm = Delete renkan "<%= title %>" ? +renkanIndex.project_filter = Filter title renkanIndex.space_exp = Create a space renkanIndex.renkan_spaces = Renkan Spaces diff -r a822178766ce -r efc0fce30814 server/src/main/webapp/WEB-INF/i18n/messages_fr.properties --- a/server/src/main/webapp/WEB-INF/i18n/messages_fr.properties Thu Apr 04 15:35:15 2013 +0200 +++ b/server/src/main/webapp/WEB-INF/i18n/messages_fr.properties Thu Apr 04 18:20:59 2013 +0200 @@ -18,6 +18,7 @@ renkanIndex.project_delete_link = Eff. renkan renkanIndex.project_render_link = Consult. renkan renkanIndex.project_delete_confirm = Voulez-vous effacer le renkan "<%= title %>" ? +renkanIndex.project_filter = Filtre titre renkanIndex.space_exp = Créer un espace renkanIndex.renkan_spaces = Espaces Renkan diff -r a822178766ce -r efc0fce30814 server/src/main/webapp/WEB-INF/templates/projectIndex.html --- a/server/src/main/webapp/WEB-INF/templates/projectIndex.html Thu Apr 04 15:35:15 2013 +0200 +++ b/server/src/main/webapp/WEB-INF/templates/projectIndex.html Thu Apr 04 18:20:59 2013 +0200 @@ -30,46 +30,54 @@ -

Project list

-
-
- << - < - ... - 2 - 3 - 4 - 5 - 6 - ... - > - >> -
-
- - - - - - - - - - - - - - - - - - - - - - - -
Name
Updated
Creation
EditCopyDel.View
titleupdatedateEdit projectCopy projectDelete projectView project
+
+

Project list

+
+
+ + +
+
+
+
+ << + < + ... + 2 + 3 + 4 + 5 + 6 + ... + > + >> +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Name
Updated
Creation
EditCopyDel.View
titleupdatedateEdit projectCopy projectDelete projectView project
+