Commit 1a43838d authored by Gabriel Monnerat's avatar Gabriel Monnerat

refactor code to allow update the dates and title of event

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42768 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 154bb107
......@@ -97,7 +97,7 @@ if request_type == "list":\n
start,\n
end,\n
0, display_minimized, 0,\n
random.randrange(-1,13), 1, \'\', event.getPortalType()])\n
random.randrange(-1,13), 1, event.getId(), event.getPortalType()])\n
return dumps(event_dict)\n
\n
elif request_type == "remove":\n
......@@ -108,13 +108,16 @@ elif request_type == "remove":\n
return dumps({"IsSuccess": True})\n
\n
elif request_type == "update":\n
event_id = form.get("event_id")\n
if not event_id:\n
return dumps({"IsSuccess": False})\n
title = form.get("title")\n
if not title:\n
return None\n
end_date = convertToERP5DateTime(form.get("CalendarEndTime"))\n
start_date = convertToERP5DateTime(form.get("CalendarStartTime"))\n
catalog_object = portal.portal_catalog.getResultValue(portal_type=portal_type_list, title=title)\n
catalog_object = portal.portal_catalog.getResultValue(portal_type=portal_type_list, id=event_id)\n
event = context.restrictedTraverse(catalog_object.getPath())\n
if title and event.getTitle() != title:\n
event.setTitle(title)\n
event.setStartDate(start_date)\n
event.setStopDate(end_date)\n
return dumps({"IsSuccess": True})\n
......
......@@ -65,9 +65,37 @@ function Edit(data){\n
var url ="WebSection_newEvent";\n
$("div#new_event_dialog").dialog({\n
title: "Update Event",\n
buttons: {},\n
buttons: {\n
"Save": function(){\n
data = $("form#create_new_event").serializeArray();\n
var dataHash = {};\n
for (var i=0; i<data.length; i++)\n
dataHash[data[i].name] = data[i].value;\n
start_date = dataHash.start_date_day + "/" + \n
dataHash.start_date_month + "/" + \n
dataHash.start_date_year + " " + \n
dataHash.start_date_hour + ":" + \n
dataHash.start_date_minute;\n
\n
stop_date = dataHash.stop_date_day + "/" + \n
dataHash.stop_date_month + "/" + \n
dataHash.stop_date_year + " " + \n
dataHash.stop_date_hour + ":" + \n
dataHash.stop_date_minute;\n
\n
var paramList = [{name : \'CalendarEndTime\', \'value\': stop_date},\n
{name : \'CalendarStartTime\', \'value\': start_date},\n
{name : \'title\', \'value\': dataHash.title},\n
{name : \'request_type\', \'value\': \'update\'},\n
{name : \'event_id\', \'value\': $("input#event_id").attr("value")}]\n
\n
$.post("Base_updateCalendarEventList", paramList);\n
},\n
},\n
});\n
$("div#new_event_dialog").load(url, {}, function(){\n
$("form#create_new_event").append("<input type=\'hidden\' id=\'event_id\'/>");\n
$("input#event_id").attr("value", data[9]);\n
$("form#create_new_event select").val(data[10]);\n
$("input[name=\'title\']").attr("value", data[1]);\n
$("input.start_date_field[name=\'start_date_year\']").attr("value", data[2].getFullYear());\n
......
200
\ No newline at end of file
201
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment