Skip to content

Commit 65a8298

Browse files
committed
RK-14200 add clear all
1 parent 3f99788 commit 65a8298

File tree

6 files changed

+26
-1
lines changed

6 files changed

+26
-1
lines changed

src/main/java/com/rookout/tutorial/TodoController.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ public ResponseEntity<?> updateTodo(@RequestBody TodoRecord updatingTodoRecord)
4444
entities.put("status", "ok");
4545
return new ResponseEntity<>(entities, HttpStatus.OK);
4646
}
47+
48+
@RequestMapping(value = "/todos/remove_all", method = RequestMethod.DELETE)
49+
public ResponseEntity<?>deleteAll() {
50+
logger.info("Removing all items");
51+
todos.remove_all();
52+
Map<String, String> entities = new HashMap<>();
53+
entities.put("status", "ok");
54+
return new ResponseEntity<>(entities, HttpStatus.OK);
55+
}
4756

4857
@RequestMapping(value = "/todos/{todoId}", method = RequestMethod.DELETE)
4958
public ResponseEntity<?> deleteTodo(@PathVariable("todoId") String todoId) {
@@ -58,6 +67,7 @@ public ResponseEntity<?> deleteTodo(@PathVariable("todoId") String todoId) {
5867
return new ResponseEntity<>(entities, HttpStatus.OK);
5968
}
6069

70+
6171
@RequestMapping(value = "/todos/clear_completed", method = RequestMethod.DELETE)
6272
public ResponseEntity<?> clearCompletedTodos() throws InterruptedException {
6373
tracingHandler.createChildSpansActivity();

src/main/java/com/rookout/tutorial/TodoStorage.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ public boolean remove(TodoRecord todoRecord) {
2626
return todoStorage.remove(todoRecord);
2727
}
2828

29+
public boolean remove_all() {
30+
return todoStorage.removeAll(todoStorage);
31+
}
32+
2933
public TodoRecord findById(String todoRecordId) {
3034
for (TodoRecord record : todoStorage) {
3135
if (record.getId().equals(todoRecordId)) {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
spring.application.name=tutorial-java
2-
opentracing.jaeger.udp-sender.host=jaeger-agent
2+
opentracing.jaeger.udp-sender.host=localhost
33
opentracing.jaeger.udp-sender.port=6831

src/main/resources/static/css/style.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,9 @@ html .clear-completed:active {
372372
.info a:hover {
373373
text-decoration: underline;
374374
}
375+
.clear-all-items {
376+
cursor: pointer;
377+
}
375378

376379
/*
377380
Hack to remove background from Mobile Safari.

src/main/resources/static/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ <h1>todos</h1>
4242
</section>
4343
<footer class="info">
4444
<p>Double-click to edit a todo</p>
45+
<p class="clear-all-items" v-on:click="removeAll()">Click here to remove all items</p>
46+
4547
</footer>
4648

4749
</div>

src/main/resources/static/js/app.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ $().ready(() => {
5656
break;
5757
}
5858
},
59+
removeAll() {
60+
const action = $.ajax('/todos/remove_all', {
61+
method: 'DELETE'
62+
});
63+
this.reloadOnFinish(action);
64+
},
5965
clearCompleted(e) {
6066
const action = $.ajax('/todos/clear_completed', {
6167
method: 'DELETE'

0 commit comments

Comments
 (0)