31 <thead> |
31 <thead> |
32 <tr> |
32 <tr> |
33 <th th:text="#{renkanIndex.project_name}">Name</th> |
33 <th th:text="#{renkanIndex.project_name}">Name</th> |
34 <th th:text="#{renkanIndex.project_creation}">Creation</th> |
34 <th th:text="#{renkanIndex.project_creation}">Creation</th> |
35 <th th:text="#{renkanIndex.project_edit}">Edit</th> |
35 <th th:text="#{renkanIndex.project_edit}">Edit</th> |
|
36 <th th:text="#{renkanIndex.project_copy}">Copy</th> |
|
37 <th th:text="#{renkanIndex.project_delete}">Del.</th> |
36 <th th:text="#{renkanIndex.project_render}">View</th> |
38 <th th:text="#{renkanIndex.project_render}">View</th> |
37 </tr> |
39 </tr> |
38 </thead> |
40 </thead> |
39 <tbody> |
41 <tbody> |
40 <tr th:each="project: ${page}"> |
42 <tr th:each="project: ${page}"> |
41 <th th:text="${project.title}">title</th> |
43 <th th:text="${project.title}">title</th> |
42 <td th:text="${#dates.format(project.created, #messages.msg('date.format'))}">date</td> |
44 <td th:text="${#dates.format(project.created, #messages.msg('date.format'))}">date</td> |
43 <td><a href="#" th:href="@{'/p/'+${project.id}(cowebkey=${project.getKey(2)})}" th:text="#{renkanIndex.project_edit_link}">Edit project</a></td> |
45 <td><a href="#" th:href="@{'/p/'+${project.id}(cowebkey=${project.getKey(2)})}" th:text="#{renkanIndex.project_edit_link}">Edit project</a></td> |
|
46 <td><a href="#" th:text="#{renkanIndex.project_copy_link}" th:attr="data-project_id=${project.id}" class="copy_project">Copy project</a></td> |
|
47 <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> |
44 <td><a href="#" th:href="@{'/p/pub/'+${project.id}(cowebkey=${project.getKey(1)})}" th:text="#{renkanIndex.project_render_link}">View project</a></td> |
48 <td><a href="#" th:href="@{'/p/pub/'+${project.id}(cowebkey=${project.getKey(1)})}" th:text="#{renkanIndex.project_render_link}">View project</a></td> |
45 </tr> |
49 </tr> |
46 </tbody> |
50 </tbody> |
47 </table> |
51 </table> |
48 </div> |
52 </div> |
74 }).done(function(project){ |
78 }).done(function(project){ |
75 var template_url = /*[[@{'/p/<%=project_id%>'(cowebkey='')}]]*/"p/<%=project_id%>?cowebkey=<%=project_key%>"; |
79 var template_url = /*[[@{'/p/<%=project_id%>'(cowebkey='')}]]*/"p/<%=project_id%>?cowebkey=<%=project_key%>"; |
76 window.location = _.template(template_url+'<%=project_key%>', {project_id: project.id, project_key: project.key}); |
80 window.location = _.template(template_url+'<%=project_key%>', {project_id: project.id, project_key: project.key}); |
77 }); |
81 }); |
78 |
82 |
79 //? window.location = "p/" + renkantitle : alert(/*[[#{renkanIndex.js.empty_name_error}]]*/"Please enter a name"); |
|
80 } |
83 } |
|
84 |
|
85 function copyProject(project_id) |
|
86 { |
|
87 var post_url = /*[[@{/p/copy}]]*/"#"; |
|
88 $.post(post_url, {"project_id": project_id}) |
|
89 .done(function(p){ |
|
90 window.location.reload(); |
|
91 }); |
|
92 } |
|
93 |
|
94 function deleteProject(project_id, project_title) |
|
95 { |
|
96 var message = /*[[#{renkanIndex.project_delete_confirm}]]*/"Delete project \"<%= title %>\""; |
|
97 if(confirm(_.template(message, {title: project_title}))) { |
|
98 var delete_url = /*[[@{/rest/projects}]]*/"#"; |
|
99 $.ajax(delete_url+"/"+project_id, { |
|
100 type: "DELETE" |
|
101 }).done(function(){ |
|
102 window.location.reload(); |
|
103 }); |
|
104 } |
|
105 } |
|
106 |
|
107 $(function(){ |
|
108 $(".copy_project").click(function(event) { |
|
109 copyProject($(event.target).data("project_id")); |
|
110 }); |
|
111 $(".delete_project").click(function(event) { |
|
112 deleteProject($(event.target).data("project_id"), $(event.target).data("project_title")); |
|
113 }); |
|
114 }); |
81 |
115 |
82 /*]]>*/ |
116 /*]]>*/ |
83 </script> |
117 </script> |
84 </body> |
118 </body> |
85 </html> |
119 </html> |