2004-08-15 Helge Hess <helge.hess@skyrix.com>
+ * v0.9.48
+
+ * UIxAppointmentEditor.m: minor cleanups
+
+ * UIxAppointmentView.m: added -delete action
+
* UIxAppointmentEditor.m: more decoupling from iCal. Added some error
handling UI code (errorText), date selector is broken (v0.9.47)
- (id)saveAction {
SOGoAppointment *apt;
- NSString *uri;
- NSException *ex;
- NSString *content;
+ NSException *ex;
+ NSString *content;
if (![self isWriteableClientObject]) {
/* return 400 == Bad Request */
return self;
}
+#warning TODO: implement proper "multi-saves"
ex = [[self clientObject] saveContentString:content];
if (ex != nil) {
[self setErrorText:[ex reason]];
return self;
}
- uri = [self _completeURIForMethod:@".."];
- return [self redirectToLocation:uri];
+ return [self redirectToLocation:[self _completeURIForMethod:@".."]];
}
@end /* UIxAppointmentEditor */
#include "UIxAppointmentView.h"
#include <NGiCal/NGiCal.h>
#include <SOGoLogic/SOGoAppointment.h>
+#include <Appointments/SOGoAppointmentObject.h>
#include <SOGoUI/SOGoDateFormatter.h>
#include "common.h"
return self;
}
+- (BOOL)isDeletableClientObject {
+ return [[self clientObject] respondsToSelector:@selector(delete)];
+}
+
+- (id)deleteAction {
+ NSException *ex;
+
+ if ([self appointment] == nil) {
+ return [NSException exceptionWithHTTPStatus:404 /* Not Found */
+ reason:@"could not locate appointment"];
+ }
+
+ if (![self isDeletableClientObject]) {
+ /* return 400 == Bad Request */
+ return [NSException exceptionWithHTTPStatus:400
+ reason:@"method cannot be invoked on "
+ @"the specified object"];
+ }
+
+ if ((ex = [[self clientObject] delete]) != nil) {
+ // TODO: improve error handling
+ [self debugWithFormat:@"failed to delete: %@", ex];
+ return ex;
+ }
+
+#warning TODO: fix redirect
+ return [[[self clientObject] container] baseURLInContext:[self context]];
+}
+
@end /* UIxAppointmentView */