Added ability to delete a task; modified scripts to share standard error
messages. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1034 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# -*- mode: makefile -*-
|
||||
#
|
||||
# $Id: messages.properties,v 1.3 2002/11/09 01:40:01 mdb Exp $
|
||||
# $Id: messages.properties,v 1.4 2003/01/23 21:22:56 mdb Exp $
|
||||
#
|
||||
# Translation messages for Two Due application
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
app_name=Two Due
|
||||
|
||||
error.no_such_task = No task exists with that task id.
|
||||
|
||||
#
|
||||
# header.wm
|
||||
|
||||
@@ -30,7 +32,6 @@ task.error.missing_complexity = No complexity selection for task.
|
||||
task.error.invalid_priority = No priority selection for task.
|
||||
task.error.invalid_creator = Creator not specified.
|
||||
task.error.missing_taskid = Internal error. No task id provided.
|
||||
task.error.no_such_task = No task exists with that task id.
|
||||
|
||||
#
|
||||
# index.wm
|
||||
@@ -52,6 +53,7 @@ edit.title = Edit Task
|
||||
edit.message.task_updated = Task updated.
|
||||
edit.message.note_added = Note added.
|
||||
edit.message.notes_updated = Notes updated.
|
||||
edit.message.task_deleted = Task deleted.
|
||||
|
||||
edit.error.missing_note = Can\'t add blank note.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: TaskRepository.java,v 1.4 2002/11/12 22:32:02 mdb Exp $
|
||||
// $Id: TaskRepository.java,v 1.5 2003/01/23 21:22:56 mdb Exp $
|
||||
|
||||
package com.samskivert.twodue.data;
|
||||
|
||||
@@ -249,6 +249,33 @@ public class TaskRepository extends JORARepository
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the specified task.
|
||||
*/
|
||||
public void deleteTask (final int taskId)
|
||||
throws PersistenceException
|
||||
{
|
||||
execute(new Operation () {
|
||||
public Object invoke (Connection conn, DatabaseLiaison liaison)
|
||||
throws PersistenceException, SQLException
|
||||
{
|
||||
String query = "delete from TASKS where TASK_ID = ?";
|
||||
PreparedStatement stmt = null;
|
||||
|
||||
try {
|
||||
stmt = conn.prepareStatement(query);
|
||||
stmt.setInt(1, taskId);
|
||||
JDBCUtil.checkedUpdate(stmt, 1);
|
||||
|
||||
} finally {
|
||||
JDBCUtil.close(stmt);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a task that was previously loaded from the repository.
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: detail.java,v 1.1 2002/11/08 21:49:17 mdb Exp $
|
||||
// $Id: detail.java,v 1.2 2003/01/23 21:22:56 mdb Exp $
|
||||
|
||||
package com.samskivert.twodue.logic;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class detail extends UserLogic
|
||||
// load up the task in question
|
||||
Task task = app.getRepository().loadTask(taskId);
|
||||
if (task == null) {
|
||||
ctx.put("error", "task.error.no_such_task");
|
||||
ctx.put("error", "error.no_such_task");
|
||||
} else {
|
||||
// format the notes and stuff those in the context
|
||||
ctx.put("notes", formatNotes(task.notes));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: edit.java,v 1.1 2002/11/08 21:49:17 mdb Exp $
|
||||
// $Id: edit.java,v 1.2 2003/01/23 21:22:56 mdb Exp $
|
||||
|
||||
package com.samskivert.twodue.logic;
|
||||
|
||||
@@ -36,12 +36,13 @@ public class edit extends UserLogic
|
||||
// load up the task in question
|
||||
Task task = app.getRepository().loadTask(taskId);
|
||||
if (task == null) {
|
||||
ctx.put("error", "edit.error.no_such_task");
|
||||
} else {
|
||||
// stick the task in the context
|
||||
ctx.put("task", task);
|
||||
ctx.put("error", "error.no_such_task");
|
||||
return;
|
||||
}
|
||||
|
||||
// stick the task in the context
|
||||
ctx.put("task", task);
|
||||
|
||||
// if they've submitted the form, we update the task database
|
||||
if (ParameterUtil.parameterEquals(
|
||||
ctx.getRequest(), "action", "update")) {
|
||||
@@ -72,6 +73,12 @@ public class edit extends UserLogic
|
||||
app.getRepository().updateTask(task);
|
||||
ctx.put("error", "edit.message.task_updated");
|
||||
|
||||
} else if (ParameterUtil.parameterEquals(
|
||||
ctx.getRequest(), "action", "delete")) {
|
||||
app.getRepository().deleteTask(taskId);
|
||||
ctx.put("error", "edit.message.task_deleted");
|
||||
ctx.remove("task"); // clear out the task
|
||||
|
||||
} else if (ParameterUtil.parameterEquals(
|
||||
ctx.getRequest(), "action", "reopen")) {
|
||||
// clear out the completor and completion dates
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
#set ($title = $i18n.xlate("edit.title"))
|
||||
#import ("/header.wm")
|
||||
|
||||
<p>
|
||||
#if ($task)
|
||||
|
||||
<p>
|
||||
<table cellpadding="0" cellspacing="10"> <!-- two colum layout table -->
|
||||
<tr><td valign="top">
|
||||
|
||||
<table cellpadding="2" cellspacing="0" border="0">
|
||||
|
||||
#if ($task && $task.completor)
|
||||
#if ($task.completor)
|
||||
<form action="edit.wm">
|
||||
$form.fixedHidden("action", "reopen")
|
||||
<input type="hidden" name="task" value="$task.taskId">
|
||||
@@ -27,9 +28,7 @@ $form.fixedHidden("action", "update")
|
||||
|
||||
<tr><td colspan="3">Summary:<br>
|
||||
<textarea name="summary" rows="5" cols="50">
|
||||
#if ($task)
|
||||
$task.summary
|
||||
#end
|
||||
</textarea>
|
||||
</td></tr>
|
||||
|
||||
@@ -73,6 +72,18 @@ $form.text("owner", "size='10'", "")
|
||||
<tr><td colspan="3" align="right" bgcolor="$scolor">
|
||||
$form.submit("submit", "Update")</td></tr>
|
||||
</form>
|
||||
|
||||
<tr><td colspan="3"> </td></tr>
|
||||
<tr><td colspan="3">Other actions:</td></tr>
|
||||
<tr><td colspan="3" align="right" bgcolor="$scolor">
|
||||
|
||||
<form action="edit.wm">
|
||||
$form.fixedHidden("action", "delete")
|
||||
<input type="hidden" name="task" value="$task.taskId">
|
||||
$form.submit("submit", "Delete")
|
||||
</form>
|
||||
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
</td><td valign="top"> <!-- two colum layout table -->
|
||||
@@ -98,9 +109,7 @@ $form.fixedHidden("action", "editnotes")
|
||||
|
||||
<tr><td>Notes:<br>
|
||||
<textarea name="notes" rows="10" cols="50">
|
||||
#if ($task)
|
||||
$task.notes
|
||||
#end
|
||||
</textarea>
|
||||
</td></tr>
|
||||
|
||||
@@ -113,4 +122,6 @@ $form.submit("submit", "Update")</td></tr>
|
||||
</td></tr> <!-- two colum layout table -->
|
||||
</table>
|
||||
|
||||
#end
|
||||
|
||||
#import ("/footer.wm")
|
||||
|
||||
Reference in New Issue
Block a user