From 39630505e4f34c4484a299d2f8e68acf642e21a7 Mon Sep 17 00:00:00 2001 From: Simon Buckle Date: Thu, 19 Jun 2008 10:04:05 +0000 Subject: [PATCH] Added activity feed templates for event edit. Fixed date display problem. All edited details are now updated. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9512 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../calendar/event-updated.atomentry.ftl | 12 +++ .../alfresco/calendar/event-updated.rss.ftl | 7 ++ .../alfresco/slingshot/calendar/event.put.js | 97 +++++++++++-------- 3 files changed, 77 insertions(+), 39 deletions(-) create mode 100644 config/alfresco/templates/activities/org/alfresco/calendar/event-updated.atomentry.ftl create mode 100644 config/alfresco/templates/activities/org/alfresco/calendar/event-updated.rss.ftl diff --git a/config/alfresco/templates/activities/org/alfresco/calendar/event-updated.atomentry.ftl b/config/alfresco/templates/activities/org/alfresco/calendar/event-updated.atomentry.ftl new file mode 100644 index 0000000000..7bfd90be29 --- /dev/null +++ b/config/alfresco/templates/activities/org/alfresco/calendar/event-updated.atomentry.ftl @@ -0,0 +1,12 @@ + + Event deleted: ${eventName!""} + + ${id} + ${xmldate(date)} + +${firstName!"anon"} ${lastName!""} just updated the event ${eventName}. + + ${userId!""} + + + diff --git a/config/alfresco/templates/activities/org/alfresco/calendar/event-updated.rss.ftl b/config/alfresco/templates/activities/org/alfresco/calendar/event-updated.rss.ftl new file mode 100644 index 0000000000..7031bd6b32 --- /dev/null +++ b/config/alfresco/templates/activities/org/alfresco/calendar/event-updated.rss.ftl @@ -0,0 +1,7 @@ + + Event deleted: ${eventName!""} + + ${id} + ${firstName!"anon"} ${lastName!""} just updated the event ${eventName}. + + diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.put.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.put.js index 4384d66720..de786c90b9 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.put.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.put.js @@ -27,30 +27,30 @@ function getTemplateParams() function main() { - var params = getTemplateParams(); - if (params === null) - { - return status.STATUS_BAD_REQUEST; - } + var params = getTemplateParams(); + if (params === null) + { + return status.STATUS_BAD_REQUEST; + } - // Get the site - var site = siteService.getSite(params.siteid); - if (site === null) - { - return status.STATUS_NOT_FOUND; - } + // Get the site + var site = siteService.getSite(params.siteid); + if (site === null) + { + return status.STATUS_NOT_FOUND; + } - var eventsFolder = site.getContainer("calendar"); - if (eventsFolder === null) - { - return status.STATUS_NOT_FOUND; - } + var eventsFolder = site.getContainer("calendar"); + if (eventsFolder === null) + { + return status.STATUS_NOT_FOUND; + } - var event = eventsFolder.childByNamePath(params.eventname); - if (event === null) - { - return status.STATUS_NOT_FOUND; - } + var event = eventsFolder.childByNamePath(params.eventname); + if (event === null) + { + return status.STATUS_NOT_FOUND; + } var props = [ "what", @@ -58,32 +58,51 @@ function main() "where" ]; - var propsmap = { - "what" : "ia:whatEvent", - "desc" : "ia:descriptionEvent", - "where" : "ia:whereEvent" - }; + var propsmap = { + "what" : "ia:whatEvent", + "desc" : "ia:descriptionEvent", + "where" : "ia:whereEvent" + }; - for (var i=0; i < props.length; i++) - { - var prop = props[i]; - try - { + for (var i=0; i < props.length; i++) + { + var prop = props[i]; + try + { var value = json.get(prop); - // TODO: deal with formatting date strings correctly if (value) { event.properties[ propsmap[prop] ] = value; } - } - catch(e) - { + } + catch(e) + { // Couldn't find the property in the JSON data - } - } + } + } + + try + { + // Handle date formatting as a separate case + var from = new Date(json.get("from") + " " + json.get("start")); + event.properties["ia:fromDate"] = from; + + var to = new Date(json.get("to") + " " + json.get("end")); + event.properties["ia:toDate"] = to; + + var eventName = json.get("what"); + activities.postActivity("org.alfresco.calendar.event-updated", params.siteid, "calendar", '{ "eventName" : ' + eventName + ' }'); + } + catch(e) + { + if (logger.isLoggingEnabled()) + { + logger.log(e); + } + } - event.save(); - return status.STATUS_NO_CONTENT; + event.save(); + return status.STATUS_NO_CONTENT; } var response = main();