From cef2aa1d629bb63d6743632f9bc76a467dd2b098 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 26 Jan 2006 20:45:41 +0000 Subject: [PATCH] Complete overhaul of "Notes" view. Now features AJAX create and edit operations. --- webcit/ChangeLog | 3 ++ webcit/groupdav_put.c | 4 +- webcit/messages.c | 5 +++ webcit/notes.c | 91 ++++++++++++++++++++++++++++++++++++++---- webcit/roomops.c | 2 +- webcit/static/wclib.js | 16 ++++++++ webcit/webcit.c | 2 + webcit/webcit.h | 1 + 8 files changed, 114 insertions(+), 10 deletions(-) diff --git a/webcit/ChangeLog b/webcit/ChangeLog index 57c3f42f4..0d41d0d0b 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,5 +1,8 @@ $Id$ +Thu Jan 26 15:44:56 EST 2006 ajc +* Complete overhaul of "Notes" view. Now features AJAX create and edit operations. + Wed Jan 25 22:25:46 EST 2006 ajc * Fixed some spelling errors * Added en_GB.po translation provided by David Given diff --git a/webcit/groupdav_put.c b/webcit/groupdav_put.c index e2c91fe72..73f9e349f 100644 --- a/webcit/groupdav_put.c +++ b/webcit/groupdav_put.c @@ -12,9 +12,9 @@ /** - * \brief put an item to the server + * \brief GroupDAV PUT an item to the server * \param dav_pathname The pathname is always going to be /groupdav/room_name/euid - * \param dav_ifmatch should we match? + * \param dav_ifmatch ETag of the item we think we're replacing * \param dav_content_type the mime type * \param dav_content the actual data */ diff --git a/webcit/messages.c b/webcit/messages.c index 9af483f6a..3c3770e50 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -2187,6 +2187,11 @@ void readloop(char *oper) ); } + if (is_notes) { + wprintf("
%s
\n", _("Click on any note to edit it.")); + wprintf("
\n"); + } + for (a = 0; a < nummsgs; ++a) { if ((WC->msgarr[a] >= startmsg) && (num_displayed < maxmsgs)) { diff --git a/webcit/notes.c b/webcit/notes.c index 89f2c84ca..667745c7f 100644 --- a/webcit/notes.c +++ b/webcit/notes.c @@ -7,16 +7,19 @@ */ /*@{*/ #include "webcit.h" +#include "groupdav.h" #include "webserver.h" /** * \brief display sticky notes * \param msgnum the citadel mesage number */ -void display_note(long msgnum) { +void display_note(long msgnum) +{ char buf[SIZ]; char notetext[SIZ]; char display_notetext[SIZ]; + char eid[128]; int in_text = 0; int i; @@ -30,28 +33,102 @@ void display_note(long msgnum) { } strcpy(notetext, ""); + strcpy(eid, ""); while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { - /** Fill the buffer to at least 256 characters */ - if ( (in_text) && (strlen(notetext) < 256) ) { + /** Fill the buffer */ + if ( (in_text) && (strlen(notetext) < SIZ-256) ) { strcat(notetext, buf); } + if ( (!in_text) && (!strncasecmp(buf, "exti=", 5)) ) { + safestrncpy(eid, &buf[5], sizeof eid); + } + if ( (!in_text) && (!strcasecmp(buf, "text")) ) { in_text = 1; } } - /** Now sanitize the buffer, and shorten it to just a small snippet */ + /** Now sanitize the buffer */ for (i=0; i\n", display_notetext); + stresc(display_notetext, notetext, 0, 0); + if (strlen(eid) > 0) { + wprintf("%s
\n", eid, display_notetext); + } + else { + wprintf("%s
\n", msgnum, display_notetext); + } + + /** Offer in-place editing. */ + if (strlen(eid) > 0) { + wprintf("\n", + eid, + eid + ); + } } +/** + * \brief This gets called by the Ajax.InPlaceEditor when we save a note. + */ +void updatenote(void) +{ + char buf[SIZ]; + char notetext[SIZ]; + char display_notetext[SIZ]; + long msgnum; + int in_text = 0; + int i; + + serv_printf("ENT0 1||0|0||||||%s", bstr("eid")); + serv_getln(buf, sizeof buf); + if (buf[0] == '4') { + text_to_server(bstr("value"), 0); + serv_puts("000"); + } + + begin_ajax_response(); + msgnum = locate_message_by_uid(bstr("eid")); + if (msgnum >= 0L) { + serv_printf("MSG0 %ld", msgnum); + serv_getln(buf, sizeof buf); + if (buf[0] == '1') { + while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { + + /** Fill the buffer */ + if ( (in_text) && (strlen(notetext) < SIZ-256) ) { + strcat(notetext, buf); + } + + if ( (!in_text) && (!strcasecmp(buf, "text")) ) { + in_text = 1; + } + } + /** Now sanitize the buffer */ + for (i=0; i" + "" "" "%s" diff --git a/webcit/static/wclib.js b/webcit/static/wclib.js index 78e7cc5c8..bf4ae9aa9 100644 --- a/webcit/static/wclib.js +++ b/webcit/static/wclib.js @@ -465,3 +465,19 @@ function ctdl_ts_getInnerText(el) { } + +// This function handles the creation of new notes in the "Notes" view. +// +function add_new_note() { + + new_eid = Math.random() + ''; + new_eid = new_eid.substr(3); + + $('new_notes_here').innerHTML = $('new_notes_here').innerHTML + + '' + + '' + Date() + '
' + ; + + new Ajax.InPlaceEditor('note' + new_eid, + 'updatenote?eid=' + new_eid , {rows:5,cols:72}); +} diff --git a/webcit/webcit.c b/webcit/webcit.c index e1852a901..e03db53de 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -1621,6 +1621,8 @@ void session_loop(struct httprequest *req) dump_vars(); wprintf("
\n"); wDumpContent(1); + } else if (!strcasecmp(action, "updatenote")) { + updatenote(); } /** When all else fais, display the main menu. */ diff --git a/webcit/webcit.h b/webcit/webcit.h index 22ec3a3cf..00c6f1ce2 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -601,6 +601,7 @@ void cal_process_attachment(char *part_source, long msgnum, char *cal_partnum); void display_calendar(long msgnum); void display_task(long msgnum); void display_note(long msgnum); +void updatenote(void); void do_calendar_view(void); void do_tasks_view(void); void free_calendar_buffer(void); -- 2.30.2