Monotone-Parent: 7ccd1ab7beef95f5bf3ce66708988dbf11332387
Monotone-Revision: 9775cc0ae35a853e8915b4d80257272df826dfeb Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-06-07T20:49:06 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
1b3f33a605
commit
7ee1d69013
|
@ -1,5 +1,9 @@
|
|||
2007-06-07 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* UI/Scheduler/UIxCalListingActions.[hm]: new subclass of
|
||||
WODirectAction that returns WOResponse objects with the events or
|
||||
todos satisfying the parameters passed in the url.
|
||||
|
||||
* UI/Scheduler/UIxAppointmentEditor.m ([UIxAppointmentEditor
|
||||
-takeValuesFromRequest:_rqinContext:_ctx]): take the new ivar
|
||||
"isAllDay" into account and compute the amount of days to pass to
|
||||
|
|
|
@ -20,8 +20,6 @@ SchedulerUI_OBJC_FILES = \
|
|||
\
|
||||
UIxComponent+Scheduler.m \
|
||||
UIxCalView.m \
|
||||
UIxCalAptListView.m \
|
||||
UIxCalTasksListView.m \
|
||||
UIxCalDayView.m \
|
||||
UIxCalMulticolumnDayView.m \
|
||||
UIxCalWeekView.m \
|
||||
|
@ -29,6 +27,8 @@ SchedulerUI_OBJC_FILES = \
|
|||
UIxCalMonthViewOld.m \
|
||||
UIxAptTableView.m \
|
||||
\
|
||||
UIxCalListingActions.m \
|
||||
\
|
||||
UIxAttendeesEditor.m \
|
||||
UIxComponentEditor.m \
|
||||
UIxCalendarSelector.m \
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
/* UIxCalAptListView.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2006 Inverse groupe conseil
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef UIXCALAPTLISTVIEW_H
|
||||
#define UIXCALAPTLISTVIEW_H
|
||||
|
||||
#import "UIxCalView.h"
|
||||
|
||||
@class NSDictionary;
|
||||
|
||||
@interface UIxCalAptListView : UIxCalView
|
||||
{
|
||||
NSCalendarDate *startDate;
|
||||
NSCalendarDate *endDate;
|
||||
|
||||
NSDictionary *currentAppointment;
|
||||
}
|
||||
|
||||
- (void) setCurrentAppointment: (NSDictionary *) apt;
|
||||
- (NSDictionary *) currentAppointment;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* UIXCALAPTLIST_H */
|
|
@ -1,183 +0,0 @@
|
|||
/* UIxCalAptListView.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2006 Inverse groupe conseil
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#import <Foundation/NSDate.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
#import <NGExtensions/NSCalendarDate+misc.h>
|
||||
#import <Appointments/SOGoAppointmentFolder.h>
|
||||
|
||||
#import <SOGoUI/SOGoDateFormatter.h>
|
||||
|
||||
#import "UIxCalAptListView.h"
|
||||
|
||||
@implementation UIxCalAptListView
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
startDate = nil;
|
||||
endDate = nil;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) setCurrentAppointment: (NSDictionary *) apt
|
||||
{
|
||||
currentAppointment = apt;
|
||||
}
|
||||
|
||||
- (NSDictionary *) currentAppointment
|
||||
{
|
||||
return currentAppointment;
|
||||
}
|
||||
|
||||
- (NSCalendarDate *) startDate
|
||||
{
|
||||
NSCalendarDate *today;
|
||||
NSString *filterPopup;
|
||||
|
||||
if (!startDate)
|
||||
{
|
||||
filterPopup = [self queryParameterForKey: @"filterpopup"];
|
||||
today = [[NSCalendarDate date] beginOfDay];
|
||||
if (!filterPopup || ![filterPopup length])
|
||||
startDate = today;
|
||||
else if ([filterPopup isEqualToString: @"view_selectedday"])
|
||||
startDate = [[self selectedDate] beginOfDay];
|
||||
else if ([filterPopup isEqualToString: @"view_thismonth"])
|
||||
startDate = [today firstDayOfMonth];
|
||||
else if ([filterPopup isEqualToString: @"view_all"])
|
||||
startDate = [NSCalendarDate dateWithTimeIntervalSince1970: 0];
|
||||
else
|
||||
startDate = today;
|
||||
}
|
||||
|
||||
return startDate;
|
||||
}
|
||||
|
||||
- (NSCalendarDate *) endDate
|
||||
{
|
||||
NSCalendarDate *today;
|
||||
NSString *filterPopup;
|
||||
|
||||
if (!endDate)
|
||||
{
|
||||
filterPopup = [self queryParameterForKey: @"filterpopup"];
|
||||
|
||||
today = [[NSCalendarDate date] endOfDay];
|
||||
if (!filterPopup || ![filterPopup length]
|
||||
|| [filterPopup isEqualToString: @"view_today"])
|
||||
endDate = today;
|
||||
else if ([filterPopup isEqualToString: @"view_all"]
|
||||
|| [filterPopup isEqualToString: @"view_future"])
|
||||
endDate = [NSCalendarDate dateWithTimeIntervalSince1970: 0x7fffffff];
|
||||
else if ([filterPopup isEqualToString: @"view_thismonth"])
|
||||
endDate = [today lastDayOfMonth];
|
||||
else if ([filterPopup isEqualToString: @"view_selectedday"])
|
||||
endDate = [[self selectedDate] endOfDay];
|
||||
else if ([filterPopup isEqualToString: @"view_next7"])
|
||||
endDate = [today dateByAddingYears: 0 months: 0 days: 7];
|
||||
else if ([filterPopup isEqualToString: @"view_next14"])
|
||||
endDate = [today dateByAddingYears: 0 months: 0 days: 14];
|
||||
else if ([filterPopup isEqualToString: @"view_next31"])
|
||||
endDate = [today dateByAddingYears: 0 months: 1 days: 0];
|
||||
else
|
||||
endDate = today;
|
||||
}
|
||||
|
||||
return endDate;
|
||||
}
|
||||
|
||||
- (SOGoDateFormatter *) itemDateFormatter
|
||||
{
|
||||
SOGoDateFormatter *fmt;
|
||||
|
||||
fmt = [[SOGoDateFormatter alloc] initWithLocale: [self locale]];
|
||||
[fmt autorelease];
|
||||
[fmt setFullWeekdayNameAndDetails];
|
||||
|
||||
return fmt;
|
||||
}
|
||||
|
||||
- (NSString *) currentStartTime
|
||||
{
|
||||
NSCalendarDate *date;
|
||||
|
||||
date = [NSCalendarDate dateWithTimeIntervalSince1970:
|
||||
[[currentAppointment objectForKey: @"startdate"]
|
||||
intValue]];
|
||||
[date setTimeZone: timeZone];
|
||||
|
||||
return [[self itemDateFormatter] stringForObjectValue: date];
|
||||
}
|
||||
|
||||
- (NSString *) currentEndTime
|
||||
{
|
||||
NSCalendarDate *date;
|
||||
|
||||
date = [NSCalendarDate dateWithTimeIntervalSince1970:
|
||||
[[currentAppointment objectForKey: @"enddate"]
|
||||
intValue]];
|
||||
[date setTimeZone: timeZone];
|
||||
|
||||
return [[self itemDateFormatter] stringForObjectValue: date];
|
||||
}
|
||||
|
||||
- (NSString *) currentLocation
|
||||
{
|
||||
return [currentAppointment objectForKey: @"location"];
|
||||
}
|
||||
|
||||
- (NSString *) currentSerialDay
|
||||
{
|
||||
NSCalendarDate *date;
|
||||
int intDate;
|
||||
|
||||
intDate = [[currentAppointment objectForKey: @"startdate"] intValue];
|
||||
date = [NSCalendarDate dateWithTimeIntervalSince1970: intDate];
|
||||
[date setTimeZone: timeZone];
|
||||
|
||||
return [NSString stringWithFormat: @"%d%.2d%.2d",
|
||||
[date yearOfCommonEra],
|
||||
[date monthOfYear],
|
||||
[date dayOfMonth]];
|
||||
}
|
||||
|
||||
- (NSString *) currentSerialHour
|
||||
{
|
||||
NSCalendarDate *date;
|
||||
int intDate;
|
||||
|
||||
intDate = [[currentAppointment objectForKey: @"startdate"] intValue];
|
||||
date = [NSCalendarDate dateWithTimeIntervalSince1970: intDate];
|
||||
[date setTimeZone: timeZone];
|
||||
|
||||
return [NSString stringWithFormat: @"%.2d%.2d",
|
||||
[date hourOfDay],
|
||||
[date minuteOfHour]];
|
||||
}
|
||||
|
||||
@end
|
|
@ -1,4 +1,4 @@
|
|||
/* UIxCalTasksListView.h - this file is part of SOGo
|
||||
/* UIxCalListingActions.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2006 Inverse groupe conseil
|
||||
*
|
||||
|
@ -20,29 +20,32 @@
|
|||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef UIXCALTASKSLISTVIEW_H
|
||||
#define UIXCALTASKSLISTVIEW_H
|
||||
#ifndef UIXCALLISTINGACTIONVIEW_H
|
||||
#define UIXCALLISTINGACTIONVIEW_H
|
||||
|
||||
#import "UIxCalView.h"
|
||||
|
||||
@class NSDictionary;
|
||||
#import <NGObjWeb/WODirectAction.h>
|
||||
|
||||
@class NSCalendarDate;
|
||||
@class NSMutableDictionary;
|
||||
@class NSString;
|
||||
@class NSTimeZone;
|
||||
|
||||
@interface UIxCalTasksListView : UIxCalView
|
||||
@class WOResponse;
|
||||
@class WORequest;
|
||||
|
||||
@interface UIxCalListingActions : WODirectAction
|
||||
{
|
||||
NSMutableDictionary *componentsData;
|
||||
NSCalendarDate *startDate;
|
||||
NSCalendarDate *endDate;
|
||||
|
||||
BOOL knowsToShow;
|
||||
BOOL showCompleted;
|
||||
|
||||
NSDictionary *currentTask;
|
||||
NSString *userLogin;
|
||||
WORequest *request;
|
||||
}
|
||||
|
||||
- (void) setCurrentTask: (NSDictionary *) task;
|
||||
- (NSDictionary *) currentTask;
|
||||
- (WOResponse *) eventsListAction;
|
||||
- (WOResponse *) tasksListAction;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* UIXCALTASKSLIST_H */
|
||||
#endif /* UIXCALLISTINGACTION_H */
|
|
@ -0,0 +1,328 @@
|
|||
/* UIxCalListingActions.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2006 Inverse groupe conseil
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSEnumerator.h>
|
||||
#import <Foundation/NSNull.h>
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
#import <NGObjWeb/WOContext.h>
|
||||
#import <NGObjWeb/WOContext+SoObjects.h>
|
||||
#import <NGObjWeb/WORequest.h>
|
||||
#import <NGObjWeb/WOResponse.h>
|
||||
#import <NGExtensions/NSCalendarDate+misc.h>
|
||||
|
||||
#import <SoObjects/SOGo/SOGoUser.h>
|
||||
#import <SoObjects/SOGo/NSCalendarDate+SOGo.h>
|
||||
#import <SoObjects/SOGo/NSArray+Utilities.h>
|
||||
#import <SoObjects/SOGo/NSObject+Utilities.h>
|
||||
#import <SoObjects/Appointments/SOGoAppointmentFolder.h>
|
||||
|
||||
#import "UIxCalListingActions.h"
|
||||
|
||||
@implementation UIxCalListingActions
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
componentsData = [NSMutableDictionary new];
|
||||
startDate = nil;
|
||||
endDate = nil;
|
||||
request = nil;
|
||||
// knowsToShow = NO;
|
||||
// showCompleted = NO;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[componentsData release];
|
||||
[startDate release];
|
||||
[endDate release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) _setupContext
|
||||
{
|
||||
SOGoUser *user;
|
||||
NSTimeZone *userTZ;
|
||||
NSString *param;
|
||||
|
||||
user = [context activeUser];
|
||||
userLogin = [user login];
|
||||
userTZ = [user timeZone];
|
||||
|
||||
request = [context request];
|
||||
param = [request formValueForKey: @"sd"];
|
||||
if ([param length] > 0)
|
||||
startDate = [[NSCalendarDate dateFromShortDateString: param
|
||||
andShortTimeString: nil
|
||||
inTimeZone: userTZ] beginOfDay];
|
||||
else
|
||||
startDate = nil;
|
||||
|
||||
param = [request formValueForKey: @"sd"];
|
||||
if ([param length] > 0)
|
||||
endDate = [[NSCalendarDate dateFromShortDateString: param
|
||||
andShortTimeString: nil
|
||||
inTimeZone: userTZ] endOfDay];
|
||||
else
|
||||
endDate = nil;
|
||||
}
|
||||
|
||||
- (void) _updatePrivacyInComponent: (NSMutableDictionary *) component
|
||||
fromFolder: (SOGoAppointmentFolder *) folder
|
||||
{
|
||||
int privacyFlag;
|
||||
NSString *roleString;
|
||||
|
||||
privacyFlag = [[component objectForKey: @"classification"] intValue];
|
||||
roleString = [folder roleForComponentsWithAccessClass: privacyFlag
|
||||
forUser: userLogin];
|
||||
if ([roleString isEqualToString: @"ComponentDAndTViewer"])
|
||||
{
|
||||
[component setObject: @"" forKey: @"title"];
|
||||
[component setObject: @"" forKey: @"location"];
|
||||
}
|
||||
}
|
||||
|
||||
- (SOGoAppointmentFolder *) _aptFolder: (NSString *) folder
|
||||
withClientObject: (SOGoAppointmentFolder *) clientObject
|
||||
{
|
||||
SOGoAppointmentFolder *aptFolder;
|
||||
NSArray *folderParts;
|
||||
|
||||
if ([folder isEqualToString: @"/"])
|
||||
aptFolder = clientObject;
|
||||
else
|
||||
{
|
||||
folderParts = [folder componentsSeparatedByString: @":"];
|
||||
aptFolder
|
||||
= [clientObject lookupCalendarFolderForUID:
|
||||
[folderParts objectAtIndex: 0]];
|
||||
}
|
||||
|
||||
return aptFolder;
|
||||
}
|
||||
|
||||
- (NSArray *) _activeCalendarFolders
|
||||
{
|
||||
NSMutableArray *activeFolders;
|
||||
NSEnumerator *folders;
|
||||
NSDictionary *currentFolderDict;
|
||||
SOGoAppointmentFolder *currentFolder, *clientObject;
|
||||
|
||||
activeFolders = [NSMutableArray new];
|
||||
[activeFolders autorelease];
|
||||
|
||||
clientObject = [self clientObject];
|
||||
|
||||
folders = [[clientObject calendarFolders] objectEnumerator];
|
||||
currentFolderDict = [folders nextObject];
|
||||
while (currentFolderDict)
|
||||
{
|
||||
if ([[currentFolderDict objectForKey: @"active"] boolValue])
|
||||
{
|
||||
currentFolder
|
||||
= [self _aptFolder: [currentFolderDict objectForKey: @"folder"]
|
||||
withClientObject: clientObject];
|
||||
[activeFolders addObject: currentFolder];
|
||||
}
|
||||
|
||||
currentFolderDict = [folders nextObject];
|
||||
}
|
||||
|
||||
return activeFolders;
|
||||
}
|
||||
|
||||
- (NSArray *) _fetchFields: (NSArray *) fields
|
||||
forComponentOfType: (NSString *) component
|
||||
{
|
||||
NSEnumerator *folders, *currentInfos;
|
||||
SOGoAppointmentFolder *currentFolder;
|
||||
NSMutableDictionary *infos, *currentInfo, *newInfo;
|
||||
NSString *owner, *uid;
|
||||
NSNull *marker;
|
||||
|
||||
marker = [NSNull null];
|
||||
|
||||
infos = [NSMutableDictionary dictionary];
|
||||
folders = [[self _activeCalendarFolders] objectEnumerator];
|
||||
currentFolder = [folders nextObject];
|
||||
while (currentFolder)
|
||||
{
|
||||
owner = [currentFolder ownerInContext: context];
|
||||
currentInfos = [[currentFolder fetchCoreInfosFrom: startDate
|
||||
to: endDate
|
||||
component: component] objectEnumerator];
|
||||
newInfo = [currentInfos nextObject];
|
||||
while (newInfo)
|
||||
{
|
||||
uid = [newInfo objectForKey: @"uid"];
|
||||
currentInfo = [infos objectForKey: uid];
|
||||
if (!currentInfo
|
||||
|| [owner isEqualToString: userLogin])
|
||||
{
|
||||
[self _updatePrivacyInComponent: newInfo
|
||||
fromFolder: currentFolder];
|
||||
[newInfo setObject: owner forKey: @"owner"];
|
||||
[infos setObject: [newInfo objectsForKeys: fields
|
||||
notFoundMarker: marker]
|
||||
forKey: uid];
|
||||
}
|
||||
newInfo = [currentInfos nextObject];
|
||||
}
|
||||
currentFolder = [folders nextObject];
|
||||
}
|
||||
|
||||
return [infos allValues];
|
||||
}
|
||||
|
||||
- (WOResponse *) _responseWithData: (NSArray *) data
|
||||
{
|
||||
WOResponse *response;
|
||||
|
||||
response = [context response];
|
||||
[response setHeader: @"text/plain; charset=utf-8"
|
||||
forKey: @"content-type"];
|
||||
[response setStatus: 200];
|
||||
[response appendContentString: [data jsonRepresentation]];
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
- (WOResponse *) eventsListAction
|
||||
{
|
||||
NSArray *fields;
|
||||
NSArray *events;
|
||||
|
||||
[self _setupContext];
|
||||
|
||||
fields = [NSArray arrayWithObjects: @"c_name", @"owner", @"status",
|
||||
@"startdate", @"enddate", @"location", nil];
|
||||
events = [self _fetchFields: fields forComponentOfType: @"vevent"];
|
||||
|
||||
return [self _responseWithData: events];
|
||||
}
|
||||
|
||||
- (NSString *) _getStatusClassForStatusCode: (int) statusCode
|
||||
andEndDateStamp: (unsigned int) endDateStamp
|
||||
{
|
||||
NSCalendarDate *taskDate, *now;
|
||||
NSString *statusClass;
|
||||
|
||||
if (statusCode == 1)
|
||||
statusClass = @"completed";
|
||||
else
|
||||
{
|
||||
if (endDateStamp)
|
||||
{
|
||||
now = [NSCalendarDate calendarDate];
|
||||
taskDate
|
||||
= [NSCalendarDate dateWithTimeIntervalSince1970: endDateStamp];
|
||||
if ([taskDate earlierDate: now] == taskDate)
|
||||
statusClass = @"overdue";
|
||||
else
|
||||
{
|
||||
if ([taskDate isToday])
|
||||
statusClass = @"duetoday";
|
||||
else
|
||||
statusClass = @"duelater";
|
||||
}
|
||||
}
|
||||
else
|
||||
statusClass = @"duelater";
|
||||
}
|
||||
|
||||
return statusClass;
|
||||
}
|
||||
|
||||
- (WOResponse *) tasksListAction
|
||||
{
|
||||
NSEnumerator *tasks;
|
||||
NSMutableArray *filteredTasks, *filteredTask;
|
||||
BOOL showCompleted;
|
||||
NSArray *fields, *task;
|
||||
int statusCode;
|
||||
unsigned int endDateStamp;
|
||||
NSString *statusFlag;
|
||||
|
||||
filteredTasks = [NSMutableArray array];
|
||||
|
||||
[self _setupContext];
|
||||
|
||||
fields = [NSArray arrayWithObjects: @"c_name", @"owner", @"status",
|
||||
@"title", @"enddate", nil];
|
||||
|
||||
tasks = [[self _fetchFields: fields
|
||||
forComponentOfType: @"vtodo"] objectEnumerator];
|
||||
showCompleted = [[request formValueForKey: @"show-completed"] intValue];
|
||||
|
||||
task = [tasks nextObject];
|
||||
while (task)
|
||||
{
|
||||
statusCode = [[task objectAtIndex: 2] intValue];
|
||||
if (statusCode != 1 || showCompleted)
|
||||
{
|
||||
filteredTask = [NSMutableArray arrayWithArray: task];
|
||||
endDateStamp = [[task objectAtIndex: 4] intValue];
|
||||
statusFlag = [self _getStatusClassForStatusCode: statusCode
|
||||
andEndDateStamp: endDateStamp];
|
||||
[filteredTask addObject: statusFlag];
|
||||
[filteredTasks addObject: filteredTask];
|
||||
}
|
||||
task = [tasks nextObject];
|
||||
}
|
||||
|
||||
return [self _responseWithData: filteredTasks];
|
||||
}
|
||||
|
||||
// - (BOOL) shouldDisplayCurrentTask
|
||||
// {
|
||||
// if (!knowsToShow)
|
||||
// {
|
||||
// showCompleted
|
||||
// = [[self queryParameterForKey: @"show-completed"] intValue];
|
||||
// knowsToShow = YES;
|
||||
// }
|
||||
|
||||
// return ([[currentTask objectForKey: @"status"] intValue] != 1
|
||||
// || showCompleted);
|
||||
// }
|
||||
|
||||
// - (BOOL) shouldShowCompletedTasks
|
||||
// {
|
||||
// if (!knowsToShow)
|
||||
// {
|
||||
// showCompleted
|
||||
// = [[self queryParameterForKey: @"show-completed"] intValue];
|
||||
// knowsToShow = YES;
|
||||
// }
|
||||
|
||||
// return showCompleted;
|
||||
// }
|
||||
|
||||
@end
|
|
@ -1,177 +0,0 @@
|
|||
/* UIxCalTasksListView.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2006 Inverse groupe conseil
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#import <Foundation/NSDate.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
|
||||
#import <NGExtensions/NSCalendarDate+misc.h>
|
||||
#import <Appointments/SOGoAppointmentFolder.h>
|
||||
#import <SOGoUI/SOGoDateFormatter.h>
|
||||
|
||||
#import "UIxCalTasksListView.h"
|
||||
|
||||
@implementation UIxCalTasksListView
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
startDate = nil;
|
||||
endDate = nil;
|
||||
knowsToShow = NO;
|
||||
showCompleted = NO;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) setCurrentTask: (NSDictionary *) task
|
||||
{
|
||||
currentTask = task;
|
||||
}
|
||||
|
||||
- (NSDictionary *) currentTask
|
||||
{
|
||||
return currentTask;
|
||||
}
|
||||
|
||||
- (NSCalendarDate *) startDate
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSCalendarDate *) endDate
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSString *) getStatusClassForTask: (NSDictionary *) task
|
||||
{
|
||||
NSCalendarDate *taskDate, *now;
|
||||
NSString *statusClass, *allClasses;
|
||||
NSNumber *taskDueStamp;
|
||||
|
||||
if ([[task objectForKey: @"status"] intValue] == 1)
|
||||
statusClass = @"completed";
|
||||
else
|
||||
{
|
||||
taskDueStamp = [task objectForKey: @"enddate"];
|
||||
if ([taskDueStamp intValue])
|
||||
{
|
||||
now = [NSCalendarDate calendarDate];
|
||||
taskDate = [NSCalendarDate dateWithTimeIntervalSince1970:
|
||||
[taskDueStamp intValue]];
|
||||
if ([taskDate earlierDate: now] == taskDate)
|
||||
statusClass = @"overdue";
|
||||
else
|
||||
{
|
||||
if ([taskDate isToday])
|
||||
statusClass = @"duetoday";
|
||||
else
|
||||
statusClass = @"duelater";
|
||||
}
|
||||
}
|
||||
else
|
||||
statusClass = @"duelater";
|
||||
}
|
||||
|
||||
allClasses = [NSString stringWithFormat: @"%@ ownerIs%@",
|
||||
statusClass,
|
||||
[task objectForKey: @"owner"]];
|
||||
|
||||
return allClasses;
|
||||
}
|
||||
|
||||
- (WOResponse *) tasksListAction
|
||||
{
|
||||
WOResponse *response;
|
||||
NSDictionary *tasks;
|
||||
NSMutableArray *filteredTasks;
|
||||
BOOL showCompleted;
|
||||
unsigned i, count;
|
||||
|
||||
response = [context response];
|
||||
filteredTasks = [NSMutableArray new];
|
||||
[filteredTasks autorelease];
|
||||
tasks = [self _fetchCoreInfosForComponent: @"vtodo"];
|
||||
showCompleted = [[self queryParameterForKey: @"show-completed"] intValue];
|
||||
|
||||
count = [tasks count];
|
||||
for (i = 0; i < count; i++) {
|
||||
NSDictionary *task;
|
||||
NSArray *filteredTask;
|
||||
|
||||
task = [tasks objectAtIndex: i];
|
||||
|
||||
if ([[task objectForKey: @"status"] intValue] != 1
|
||||
|| showCompleted)
|
||||
{
|
||||
filteredTask = [NSArray arrayWithObjects:
|
||||
[task objectForKey: @"c_name"],
|
||||
[task objectForKey: @"owner"],
|
||||
[task objectForKey: @"status"],
|
||||
[task objectForKey: @"title"],
|
||||
[self getStatusClassForTask: task],
|
||||
nil];
|
||||
[filteredTasks addObject: filteredTask];
|
||||
}
|
||||
}
|
||||
|
||||
[response setStatus: 200];
|
||||
[response appendContentString: [filteredTasks jsonRepresentation]];
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
- (BOOL) shouldDisplayCurrentTask
|
||||
{
|
||||
if (!knowsToShow)
|
||||
{
|
||||
showCompleted
|
||||
= [[self queryParameterForKey: @"show-completed"] intValue];
|
||||
knowsToShow = YES;
|
||||
}
|
||||
|
||||
return ([[currentTask objectForKey: @"status"] intValue] != 1
|
||||
|| showCompleted);
|
||||
}
|
||||
|
||||
- (BOOL) shouldShowCompletedTasks
|
||||
{
|
||||
if (!knowsToShow)
|
||||
{
|
||||
showCompleted
|
||||
= [[self queryParameterForKey: @"show-completed"] intValue];
|
||||
knowsToShow = YES;
|
||||
}
|
||||
|
||||
return showCompleted;
|
||||
}
|
||||
|
||||
- (BOOL) isCurrentTaskCompleted
|
||||
{
|
||||
return ([[currentTask objectForKey: @"status"] intValue] == 1);
|
||||
}
|
||||
|
||||
@end
|
|
@ -1,224 +1,226 @@
|
|||
{
|
||||
{ /* -*-javascript-*- */
|
||||
requires = ( MAIN, MainUI, CommonUI, Appointments, Contacts, ContactsUI );
|
||||
|
||||
publicResources = (
|
||||
previous_week.gif,
|
||||
next_week.gif,
|
||||
icon_view_overview.gif,
|
||||
icon_view_overview_inactive.gif,
|
||||
icon_view_chart.gif,
|
||||
icon_view_chart_inactive.gif,
|
||||
icon_view_list.gif,
|
||||
icon_view_list_inactive.gif,
|
||||
icon_view_columns.gif,
|
||||
icon_view_columns_inactive.gif,
|
||||
icon_popupcalendar.gif,
|
||||
first.gif,
|
||||
previous.gif,
|
||||
next.gif,
|
||||
last.gif,
|
||||
skycalendar.html,
|
||||
skycalendar.js,
|
||||
green_corner.gif,
|
||||
invisible_space_2.gif,
|
||||
cycles.plist,
|
||||
previous_week.gif,
|
||||
next_week.gif,
|
||||
icon_view_overview.gif,
|
||||
icon_view_overview_inactive.gif,
|
||||
icon_view_chart.gif,
|
||||
icon_view_chart_inactive.gif,
|
||||
icon_view_list.gif,
|
||||
icon_view_list_inactive.gif,
|
||||
icon_view_columns.gif,
|
||||
icon_view_columns_inactive.gif,
|
||||
icon_popupcalendar.gif,
|
||||
first.gif,
|
||||
previous.gif,
|
||||
next.gif,
|
||||
last.gif,
|
||||
skycalendar.html,
|
||||
skycalendar.js,
|
||||
green_corner.gif,
|
||||
invisible_space_2.gif,
|
||||
cycles.plist,
|
||||
);
|
||||
|
||||
factories = {
|
||||
};
|
||||
|
||||
categories = {
|
||||
SOGoAppointmentFolder = {
|
||||
slots = {
|
||||
toolbar = {
|
||||
protectedBy = "View";
|
||||
value = "SOGoAppointmentFolder.toolbar";
|
||||
};
|
||||
};
|
||||
methods = {
|
||||
view = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxCalMainView";
|
||||
};
|
||||
dateselector = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxCalDateSelector";
|
||||
};
|
||||
aptlist = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxCalAptListView";
|
||||
};
|
||||
taskslist = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxCalTasksListView";
|
||||
};
|
||||
dayview = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxCalDayView";
|
||||
};
|
||||
multicolumndayview = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxCalMulticolumnDayView";
|
||||
};
|
||||
weekview = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxCalWeekView";
|
||||
};
|
||||
monthview = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxCalMonthView";
|
||||
};
|
||||
newevent = {
|
||||
protectedBy = "Add Documents, Images, and Files";
|
||||
pageName = "UIxAppointmentEditor";
|
||||
actionName = "new";
|
||||
};
|
||||
newtask = {
|
||||
protectedBy = "Add Documents, Images, and Files";
|
||||
pageName = "UIxTaskEditor";
|
||||
actionName = "new";
|
||||
};
|
||||
show = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxCalView";
|
||||
actionName = "redirectForUIDs";
|
||||
};
|
||||
proposal = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxAppointmentProposal";
|
||||
};
|
||||
proposalSearch = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxAppointmentProposal";
|
||||
actionName = "proposalSearch";
|
||||
};
|
||||
batchDelete = {
|
||||
protectedBy = "Delete Objects";
|
||||
pageName = "UIxCalMainView";
|
||||
actionName = "batchDelete";
|
||||
};
|
||||
updateCalendars = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxCalMainView";
|
||||
actionName = "updateCalendars";
|
||||
};
|
||||
editAttendees = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxAttendeesEditor";
|
||||
SOGoAppointmentFolder = {
|
||||
slots = {
|
||||
toolbar = {
|
||||
protectedBy = "View";
|
||||
value = "SOGoAppointmentFolder.toolbar";
|
||||
};
|
||||
};
|
||||
userRights = {
|
||||
protectedBy = "ReadAcls";
|
||||
pageName = "UIxCalUserRightsEditor";
|
||||
};
|
||||
saveUserRights = {
|
||||
protectedBy = "SaveAcls";
|
||||
pageName = "UIxCalUserRightsEditor";
|
||||
actionName = "saveUserRights";
|
||||
methods = {
|
||||
view = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxCalMainView";
|
||||
};
|
||||
dateselector = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxCalDateSelector";
|
||||
};
|
||||
eventslist = {
|
||||
protectedBy = "View";
|
||||
actionClass = "UIxCalListingActions";
|
||||
actionName = "eventsList";
|
||||
};
|
||||
taskslist = {
|
||||
protectedBy = "View";
|
||||
actionClass = "UIxCalListingActions";
|
||||
actionName = "tasksList";
|
||||
};
|
||||
dayview = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxCalDayView";
|
||||
};
|
||||
multicolumndayview = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxCalMulticolumnDayView";
|
||||
};
|
||||
weekview = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxCalWeekView";
|
||||
};
|
||||
monthview = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxCalMonthView";
|
||||
};
|
||||
newevent = {
|
||||
protectedBy = "Add Documents, Images, and Files";
|
||||
pageName = "UIxAppointmentEditor";
|
||||
actionName = "new";
|
||||
};
|
||||
newtask = {
|
||||
protectedBy = "Add Documents, Images, and Files";
|
||||
pageName = "UIxTaskEditor";
|
||||
actionName = "new";
|
||||
};
|
||||
show = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxCalView";
|
||||
actionName = "redirectForUIDs";
|
||||
};
|
||||
proposal = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxAppointmentProposal";
|
||||
};
|
||||
proposalSearch = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxAppointmentProposal";
|
||||
actionName = "proposalSearch";
|
||||
};
|
||||
batchDelete = {
|
||||
protectedBy = "Delete Objects";
|
||||
pageName = "UIxCalMainView";
|
||||
actionName = "batchDelete";
|
||||
};
|
||||
updateCalendars = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxCalMainView";
|
||||
actionName = "updateCalendars";
|
||||
};
|
||||
editAttendees = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxAttendeesEditor";
|
||||
};
|
||||
userRights = {
|
||||
protectedBy = "ReadAcls";
|
||||
pageName = "UIxCalUserRightsEditor";
|
||||
};
|
||||
saveUserRights = {
|
||||
protectedBy = "SaveAcls";
|
||||
pageName = "UIxCalUserRightsEditor";
|
||||
actionName = "saveUserRights";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
SOGoCalendarComponent = {
|
||||
};
|
||||
};
|
||||
SOGoCalendarComponent = {
|
||||
};
|
||||
|
||||
SOGoAppointmentObject = {
|
||||
slots = {
|
||||
toolbar = {
|
||||
protectedBy = "View";
|
||||
value = "SOGoAppointmentObject.toolbar";
|
||||
};
|
||||
};
|
||||
methods = {
|
||||
view = {
|
||||
protectedBy = "ViewAllComponent";
|
||||
pageName = "UIxAppointmentView";
|
||||
};
|
||||
delete = {
|
||||
protectedBy = "Delete Objects";
|
||||
pageName = "UIxAppointmentView";
|
||||
actionName = "delete";
|
||||
};
|
||||
edit = {
|
||||
protectedBy = "ViewAllComponent";
|
||||
pageName = "UIxAppointmentEditor";
|
||||
};
|
||||
editAsAppointment = {
|
||||
protectedBy = "ViewAllComponent";
|
||||
pageName = "UIxAppointmentEditor";
|
||||
};
|
||||
save = {
|
||||
protectedBy = "ModifyComponent";
|
||||
pageName = "UIxAppointmentEditor";
|
||||
actionName = "save";
|
||||
};
|
||||
saveAsAppointment = {
|
||||
protectedBy = "ModifyComponent";
|
||||
pageName = "UIxAppointmentEditor";
|
||||
actionName = "save";
|
||||
};
|
||||
accept = {
|
||||
protectedBy = "RespondToComponent";
|
||||
pageName = "UIxAppointmentEditor";
|
||||
actionName = "accept";
|
||||
};
|
||||
decline = {
|
||||
protectedBy = "RespondToComponent";
|
||||
pageName = "UIxAppointmentEditor";
|
||||
actionName = "decline";
|
||||
};
|
||||
};
|
||||
};
|
||||
SOGoAppointmentObject = {
|
||||
slots = {
|
||||
toolbar = {
|
||||
protectedBy = "View";
|
||||
value = "SOGoAppointmentObject.toolbar";
|
||||
};
|
||||
};
|
||||
methods = {
|
||||
view = {
|
||||
protectedBy = "ViewAllComponent";
|
||||
pageName = "UIxAppointmentView";
|
||||
};
|
||||
delete = {
|
||||
protectedBy = "Delete Objects";
|
||||
pageName = "UIxAppointmentView";
|
||||
actionName = "delete";
|
||||
};
|
||||
edit = {
|
||||
protectedBy = "ViewAllComponent";
|
||||
pageName = "UIxAppointmentEditor";
|
||||
};
|
||||
editAsAppointment = {
|
||||
protectedBy = "ViewAllComponent";
|
||||
pageName = "UIxAppointmentEditor";
|
||||
};
|
||||
save = {
|
||||
protectedBy = "ModifyComponent";
|
||||
pageName = "UIxAppointmentEditor";
|
||||
actionName = "save";
|
||||
};
|
||||
saveAsAppointment = {
|
||||
protectedBy = "ModifyComponent";
|
||||
pageName = "UIxAppointmentEditor";
|
||||
actionName = "save";
|
||||
};
|
||||
accept = {
|
||||
protectedBy = "RespondToComponent";
|
||||
pageName = "UIxAppointmentEditor";
|
||||
actionName = "accept";
|
||||
};
|
||||
decline = {
|
||||
protectedBy = "RespondToComponent";
|
||||
pageName = "UIxAppointmentEditor";
|
||||
actionName = "decline";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
SOGoTaskObject = {
|
||||
slots = {
|
||||
toolbar = {
|
||||
protectedBy = "View";
|
||||
value = "SOGoAppointmentObject.toolbar";
|
||||
};
|
||||
};
|
||||
methods = {
|
||||
view = {
|
||||
protectedBy = "ViewAllComponent";
|
||||
pageName = "UIxTaskView";
|
||||
};
|
||||
delete = {
|
||||
protectedBy = "Delete Objects";
|
||||
pageName = "UIxTaskView";
|
||||
actionName = "delete";
|
||||
};
|
||||
edit = {
|
||||
protectedBy = "ViewAllComponent";
|
||||
pageName = "UIxTaskEditor";
|
||||
};
|
||||
editAsTask = {
|
||||
protectedBy = "ViewAllComponent";
|
||||
pageName = "UIxTaskEditor";
|
||||
};
|
||||
save = {
|
||||
protectedBy = "ModifyComponent";
|
||||
pageName = "UIxTaskEditor";
|
||||
actionName = "save";
|
||||
};
|
||||
saveAsTask = {
|
||||
protectedBy = "ModifyComponent";
|
||||
pageName = "UIxTaskEditor";
|
||||
actionName = "save";
|
||||
};
|
||||
changeStatus = {
|
||||
protectedBy = "ModifyComponent";
|
||||
pageName = "UIxTaskEditor";
|
||||
actionName = "changeStatus";
|
||||
};
|
||||
accept = {
|
||||
protectedBy = "RespondToComponent";
|
||||
pageName = "UIxTaskEditor";
|
||||
actionName = "accept";
|
||||
};
|
||||
decline = {
|
||||
protectedBy = "RespondToComponent";
|
||||
pageName = "UIxTaskEditor";
|
||||
actionName = "decline";
|
||||
};
|
||||
};
|
||||
};
|
||||
SOGoTaskObject = {
|
||||
slots = {
|
||||
toolbar = {
|
||||
protectedBy = "View";
|
||||
value = "SOGoAppointmentObject.toolbar";
|
||||
};
|
||||
};
|
||||
methods = {
|
||||
view = {
|
||||
protectedBy = "ViewAllComponent";
|
||||
pageName = "UIxTaskView";
|
||||
};
|
||||
delete = {
|
||||
protectedBy = "Delete Objects";
|
||||
pageName = "UIxTaskView";
|
||||
actionName = "delete";
|
||||
};
|
||||
edit = {
|
||||
protectedBy = "ViewAllComponent";
|
||||
pageName = "UIxTaskEditor";
|
||||
};
|
||||
editAsTask = {
|
||||
protectedBy = "ViewAllComponent";
|
||||
pageName = "UIxTaskEditor";
|
||||
};
|
||||
save = {
|
||||
protectedBy = "ModifyComponent";
|
||||
pageName = "UIxTaskEditor";
|
||||
actionName = "save";
|
||||
};
|
||||
saveAsTask = {
|
||||
protectedBy = "ModifyComponent";
|
||||
pageName = "UIxTaskEditor";
|
||||
actionName = "save";
|
||||
};
|
||||
changeStatus = {
|
||||
protectedBy = "ModifyComponent";
|
||||
pageName = "UIxTaskEditor";
|
||||
actionName = "changeStatus";
|
||||
};
|
||||
accept = {
|
||||
protectedBy = "RespondToComponent";
|
||||
pageName = "UIxTaskEditor";
|
||||
actionName = "accept";
|
||||
};
|
||||
decline = {
|
||||
protectedBy = "RespondToComponent";
|
||||
pageName = "UIxTaskEditor";
|
||||
actionName = "decline";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue