making duedate be optional when creating/editing tasks

This commit is contained in:
pavlov%pavlov.net 2005-06-29 23:39:05 +00:00
parent 356cd7d5ec
commit 84e15d54f6
3 changed files with 33 additions and 10 deletions

View File

@ -65,6 +65,9 @@ function onLoad()
// update the accept button
updateAccept();
// update datetime pickers
updateDuedate();
// update datetime pickers
updateAllDay();
@ -129,7 +132,10 @@ function loadDialog(item)
/* todo specific properties */
if (isToDo(item)) {
setElementValue("todo-duedate", item.dueDate.jsDate);
var hasDueDate = (item.dueDate != null);
setElementValue("todo-has-duedate", hasDueDate, "checked");
if (hasDueDate)
setElementValue("todo-duedate", item.dueDate.jsDate);
setElementValue("todo-completed", (item.percentComplete == 100), "checked");
}
@ -192,7 +198,9 @@ function saveDialog(item)
}
if (isToDo(item)) {
setItemProperty(item, "dueDate", jsDateToDateTime(getElementValue("todo-duedate")));
var dueDate = getElementValue("todo-has-duedate", "checked") ?
jsDateToDateTime(getElementValue("todo-duedate")) : null;
setItemProperty(item, "dueDate", dueDate);
setItemProperty(item, "percentComplete", getElementValue("todo-completed", "checked"));
}
@ -305,6 +313,17 @@ function updateAccept()
acceptButton.removeAttribute("disabled");
}
function updateDuedate()
{
if (!isToDo(window.calendarItem))
return;
// force something to get set if there was nothing there before
setElementValue("todo-duedate", getElementValue("todo-duedate"));
setElementValue("todo-duedate", !getElementValue("todo-has-duedate", "checked"), "disabled");
}
function updateAllDay()
{
@ -417,9 +436,12 @@ function setItemProperty(item, propertyName, value)
case "dueDate":
if (value.compare(item.dueDate) != 0) {
if (value == item.dueDate)
break;
if ((value && !item.dueDate) ||
(!value && item.dueDate) ||
(value.compare(item.dueDate) != 0))
item.dueDate = value;
}
break;
case "percentComplete":
var percent = (value) ? 100 : 0;

View File

@ -44,7 +44,7 @@
<dialog
id="calendar-event-dialog"
title="Edit Event"
title="Edit Item"
buttons="accept,cancel"
ondialogaccept="return onAccept();"
ondialogcancel="return onCancel();"
@ -115,7 +115,10 @@
<row align="center" class="todo-only">
<label value="Due date" class="label"/>
<datetimepicker id="todo-duedate"/>
<hbox>
<checkbox id="todo-has-duedate" oncommand="updateDuedate();"/>
<datetimepicker id="todo-duedate"/>
</hbox>
</row>
<row align="center">

View File

@ -95,10 +95,8 @@ function createTodoWithDialog(calendar, dueDate, summary)
if (summary)
todo.title = summary;
if (!dueDate)
dueDate = jsDateToDateTime(new Date());
todo.dueDate = dueDate;
if (dueDate)
todo.dueDate = dueDate;
var onNewItem = function(item, calendar, originalItem) {
calendar.addItem(item, null);