Commit 8d755d3e authored by Gabriel Monnerat's avatar Gabriel Monnerat

refactor code to open the dialog to create new event and update event correctly.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42758 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent dc989cf5
......@@ -93,14 +93,16 @@ if request_type == "list":\n
start,\n
end,\n
random.randrange(0,1),1,0,\n
random.randrange(-1,13),1,\'\',\'\',])\n
random.randrange(-1,13), 1, \'\', event.getPortalType()])\n
return dumps(event_dict)\n
\n
elif request_type == "remove":\n
title = form.get("title")\n
catalog_object = portal.portal_catalog.getResultValue(portal_type=portal_type_list, title=title)\n
event = context.restrictedTraverse(catalog_object.getPath())\n
portal.event_module.deleteContent(event.getId())\n
return dumps({"IsSuccess": True})\n
\n
elif request_type == "update":\n
title = form.get("title")\n
if not title:\n
......@@ -112,6 +114,7 @@ elif request_type == "update":\n
event.setStartDate(start_date)\n
event.setStopDate(end_date)\n
return dumps({"IsSuccess": True})\n
\n
elif request_type == "add":\n
end_date = convertToERP5DateTime(form.get("CalendarEndTime"))\n
start_date = convertToERP5DateTime(form.get("CalendarStartTime"))\n
......
......@@ -56,7 +56,9 @@ form = context.REQUEST.form\n
portal_type = form.get("portal_type")\n
event_title = form.get("title")\n
start_date = DateTime("%(start_date_year)s/%(start_date_month)s/%(start_date_day)s %(start_date_hour)s:%(start_date_minute)s" % form)\n
context.log(start_date)\n
stop_date = DateTime("%(stop_date_year)s/%(stop_date_month)s/%(stop_date_day)s %(stop_date_hour)s:%(stop_date_minute)s" % form)\n
context.log(stop_date)\n
portal = context.getPortalObject()\n
event = portal.event_module.newContent(portal_type=portal_type, title=event_title)\n
event.setStartDate(start_date)\n
......
......@@ -123,7 +123,7 @@
<div class="t2 chromeColor">&nbsp;</div>\n
<div class="t1 chromeColor">&nbsp;</div>\n
</div>\n
<div id="new_event_dialog" title="Create New Event"></div>\n
<div id="new_event_dialog"/>\n
</div>\n
</html>
......
......@@ -63,13 +63,26 @@ function callOnError(type, data){\n
\n
function Edit(data){\n
var url ="WebSection_newEvent";\n
var editUrl="WebSection_newEvent?id={0}&start={2}&end={3}&isallday={4}&title={1}";\n
if(data){\n
var url = StrFormat(editUrl, data);\n
OpenModelWindow(url,{width: 400, height: 200, caption:"Manage The Event", onclose:function(){\n
$("#gridcontainer").reload();\n
}});\n
}\n
$("div#new_event_dialog").dialog({\n
title: "Update Event",\n
buttons: {},\n
});\n
$("div#new_event_dialog").load(url, {}, function(){\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
$("input.start_date_field[name=\'start_date_month\']").attr("value", ""+data[2].getMonth() + 1);\n
$("input.start_date_field[name=\'start_date_day\']").attr("value", data[2].getDate());\n
$("input.start_date_field[name=\'start_date_hour\']").attr("value", data[2].getHours());\n
$("input.start_date_field[name=\'start_date_minute\']").attr("value", data[2].getMinutes());\n
\n
$("input.stop_date_field[name=\'stop_date_year\']").attr("value", data[3].getFullYear());\n
$("input.stop_date_field[name=\'stop_date_month\']").attr("value", ""+data[3].getMonth() + 1);\n
$("input.stop_date_field[name=\'stop_date_day\']").attr("value", data[3].getDate());\n
$("input.stop_date_field[name=\'stop_date_hour\']").attr("value", data[3].getHours());\n
$("input.stop_date_field[name=\'stop_date_minute\']").attr("value", data[3].getMinutes());\n
});\n
$("div#new_event_dialog").dialog(\'open\');\n
}\n
\n
function View(data){\n
......@@ -163,6 +176,19 @@ $(document).ready(function() { \n
}); \n
//Add a new event\n
$("#faddbtn").click(function() {\n
$("div#new_event_dialog").dialog({\n
title: "Create New Event",\n
buttons: {\n
"Create": function(){\n
$.post("EventModule_createNewEvent",\n
$("form#create_new_event").serialize(),\n
function(){\n
$("div#new_event_dialog").dialog("close");\n
$("div#showreflashbtn.fbutton").click();\n
});\n
}\n
},\n
});\n
var url ="WebSection_newEvent";\n
var date = new Date();\n
$("div#new_event_dialog").load(url, {}, function(){\n
......@@ -171,8 +197,6 @@ $(document).ready(function() { \n
$("input.start_date_field[name=\'start_date_hour\'], input.stop_date_field[name=\'stop_date_hour\']").attr("value", date.getHours());\n
$("input.start_date_field[name=\'start_date_minute\'], input.stop_date_field[name=\'stop_date_minute\']").attr("value", date.getMinutes());\n
});\n
//$("input.start_date_field[name=\'start_date_month\'],\n
// input.stop_date_field[name=\'stop_date_month\']").attr("value", ""+date.getMonth()+1);\n
$("div#new_event_dialog").dialog("open");\n
});\n
//go to today\n
......@@ -201,17 +225,6 @@ $(document).ready(function() { \n
height: 192,\n
width: 410,\n
modal: true,\n
buttons: {\n
"Create": function(){\n
$.post("EventModule_createNewEvent",\n
$("form#create_new_event").serialize(),\n
function(){\n
$("div#new_event_dialog").dialog("close");\n
$("div#showreflashbtn.fbutton").click();\n
}\n
);\n
}\n
},\n
});\n
$( "#datepicker" ).datepicker({\n
onSelect: function(dateText, inst){\n
......
197
\ No newline at end of file
198
\ 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