Add translation on delete message
Add copy method on controler.
--- a/server/src/main/java/org/iri_research/renkan/controller/RenkanController.java Fri Mar 15 14:37:21 2013 +0100
+++ b/server/src/main/java/org/iri_research/renkan/controller/RenkanController.java Fri Mar 15 17:11:44 2013 +0100
@@ -21,6 +21,7 @@
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.bind.annotation.ResponseBody;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.HttpServerErrorException;
import org.springframework.web.servlet.ModelAndView;
@@ -51,7 +52,23 @@
}
}
-
+ @RequestMapping(value="/copy", method = RequestMethod.POST, produces={"application/json;charset=UTF-8"})
+ public @ResponseBody Project copyProject(@RequestParam(value="project_id") String projectId ) {
+
+ if(projectId == null || projectId.length() == 0) {
+ throw new IllegalArgumentException("RenkanContoller.renkanProject.copyProject: Project id is null or empty.");
+ }
+ Project project = this.projectsRepository.findOne(projectId);
+ if(project == null) {
+ throw new HttpClientErrorException(HttpStatus.NOT_FOUND, "Project " + projectId + " not found for copyProject.");
+ }
+
+ Project newProject = this.projectsRepository.copy(project, project.getTitle() + " (copy)");
+
+ return newProject;
+ }
+
+
@RequestMapping(value="/{project_id}", method = RequestMethod.GET, produces={"text/html;charset=UTF-8", "!image/*"})
public ModelAndView renkanProject(
@PathVariable(value="project_id") String project_id,
@@ -109,20 +126,5 @@
return "renkanProjectPublish";
}
- @RequestMapping(value="/copy", method = RequestMethod.POST, params="project_id={project_id}", produces={"application/json;charset=UTF-8"})
- public Project copyProject(@RequestParam(value="project_id") String projectId ) {
-
- if(projectId == null || projectId.length() == 0) {
- throw new IllegalArgumentException("RenkanContoller.renkanProject: Project id is null or empty.");
- }
- Project project = this.projectsRepository.findOne(projectId);
- if(project == null) {
- throw new HttpClientErrorException(HttpStatus.NOT_FOUND, "Project " + projectId + " not found.");
- }
-
- Project newProject = this.projectsRepository.copy(project, project.getTitle() + " (copy)");
-
- return newProject;
- }
}
--- a/server/src/main/java/org/iri_research/renkan/repositories/ProjectsRepositoryImpl.java Fri Mar 15 14:37:21 2013 +0100
+++ b/server/src/main/java/org/iri_research/renkan/repositories/ProjectsRepositoryImpl.java Fri Mar 15 17:11:44 2013 +0100
@@ -69,8 +69,8 @@
res.setTitle(newTitle);
this.nodesRepository.save(p.getNodes());
this.edgesRepository.save(p.getEdges());
- this.projectsRepository.save(p);
- return res;
+
+ return this.projectsRepository.save(p);
}
}
--- a/server/src/main/webapp/WEB-INF/i18n/messages_en.properties Fri Mar 15 14:37:21 2013 +0100
+++ b/server/src/main/webapp/WEB-INF/i18n/messages_en.properties Fri Mar 15 17:11:44 2013 +0100
@@ -8,9 +8,14 @@
renkanIndex.project_name = Name
renkanIndex.project_creation = Creation
renkanIndex.project_edit = Edit
+renkanIndex.project_copy = Copy
+renkanIndex.project_delete = Delete
renkanIndex.project_render = View
renkanIndex.project_edit_link = Edit project
+renkanIndex.project_copy_link = Copy project
+renkanIndex.project_delete_link = Delete project
renkanIndex.project_render_link = View project
+renkanIndex.project_delete_confirm = Delete project "<%= title %>" ?
renkanIndex.space_exp = or create/open a space with the title
renkanIndex.renkan_spaces = Renkan Spaces
--- a/server/src/main/webapp/WEB-INF/i18n/messages_fr.properties Fri Mar 15 14:37:21 2013 +0100
+++ b/server/src/main/webapp/WEB-INF/i18n/messages_fr.properties Fri Mar 15 17:11:44 2013 +0100
@@ -9,9 +9,14 @@
renkanIndex.project_title = Titre
renkanIndex.project_creation = Creation
renkanIndex.project_edit = Edition
+renkanIndex.project_copy = Copier
+renkanIndex.project_delete = Eff.
renkanIndex.project_render = Consult.
renkanIndex.project_edit_link = Editer proj.
+renkanIndex.project_copy_link = Copier proj.
+renkanIndex.project_delete_link = Eff. proj.
renkanIndex.project_render_link = Consult. proj.
+renkanIndex.project_delete_confirm = Voulez-vous effacer le projet "<%= title %>" ?
renkanIndex.space_exp = ou bien créer un espace avec le titre
renkanIndex.renkan_spaces = Espaces Renkan
--- a/server/src/main/webapp/WEB-INF/templates/projectIndex.html Fri Mar 15 14:37:21 2013 +0100
+++ b/server/src/main/webapp/WEB-INF/templates/projectIndex.html Fri Mar 15 17:11:44 2013 +0100
@@ -33,6 +33,8 @@
<th th:text="#{renkanIndex.project_name}">Name</th>
<th th:text="#{renkanIndex.project_creation}">Creation</th>
<th th:text="#{renkanIndex.project_edit}">Edit</th>
+ <th th:text="#{renkanIndex.project_copy}">Copy</th>
+ <th th:text="#{renkanIndex.project_delete}">Del.</th>
<th th:text="#{renkanIndex.project_render}">View</th>
</tr>
</thead>
@@ -41,6 +43,8 @@
<th th:text="${project.title}">title</th>
<td th:text="${#dates.format(project.created, #messages.msg('date.format'))}">date</td>
<td><a href="#" th:href="@{'/p/'+${project.id}(cowebkey=${project.getKey(2)})}" th:text="#{renkanIndex.project_edit_link}">Edit project</a></td>
+ <td><a href="#" th:text="#{renkanIndex.project_copy_link}" th:attr="data-project_id=${project.id}" class="copy_project">Copy project</a></td>
+ <td><a href="#" th:text="#{renkanIndex.project_delete_link}" th:attr="data-project_id=${project.id},data-project_title=${project.title}" class="delete_project">Delete project</a></td>
<td><a href="#" th:href="@{'/p/pub/'+${project.id}(cowebkey=${project.getKey(1)})}" th:text="#{renkanIndex.project_render_link}">View project</a></td>
</tr>
</tbody>
@@ -76,8 +80,38 @@
window.location = _.template(template_url+'<%=project_key%>', {project_id: project.id, project_key: project.key});
});
- //? window.location = "p/" + renkantitle : alert(/*[[#{renkanIndex.js.empty_name_error}]]*/"Please enter a name");
}
+
+ function copyProject(project_id)
+ {
+ var post_url = /*[[@{/p/copy}]]*/"#";
+ $.post(post_url, {"project_id": project_id})
+ .done(function(p){
+ window.location.reload();
+ });
+ }
+
+ function deleteProject(project_id, project_title)
+ {
+ var message = /*[[#{renkanIndex.project_delete_confirm}]]*/"Delete project \"<%= title %>\"";
+ if(confirm(_.template(message, {title: project_title}))) {
+ var delete_url = /*[[@{/rest/projects}]]*/"#";
+ $.ajax(delete_url+"/"+project_id, {
+ type: "DELETE"
+ }).done(function(){
+ window.location.reload();
+ });
+ }
+ }
+
+ $(function(){
+ $(".copy_project").click(function(event) {
+ copyProject($(event.target).data("project_id"));
+ });
+ $(".delete_project").click(function(event) {
+ deleteProject($(event.target).data("project_id"), $(event.target).data("project_title"));
+ });
+ });
/*]]>*/
</script>