diff --git a/ChangeLog b/ChangeLog index e28e3bcf2..b5003f0ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2009-09-03 Cyril Robert * UI/Contacts/UIxContactsListView.m: Added ldif / vcard import + * UI/Contacts/UIxContactsListView.m: Changed return types to know how many + cards were imported. 2009-09-02 Cyril Robert diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.h b/SoObjects/Appointments/SOGoAppointmentFolder.h index 9bec32fea..cd96ed6e8 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.h +++ b/SoObjects/Appointments/SOGoAppointmentFolder.h @@ -144,7 +144,7 @@ - (NSException *) setProxySubscribers: (NSArray *) newSubscribers withWriteAccess: (BOOL) hasWriteAccess; -- (void) importComponent: (iCalEntityObject *) event; +- (BOOL) importComponent: (iCalEntityObject *) event; @end diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 3538e5d00..a449f8cce 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -3173,7 +3173,7 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir return error; } -- (void) importComponent: (iCalEntityObject *) event +- (BOOL) importComponent: (iCalEntityObject *) event { SOGoAppointmentObject *object; NSString *uid; @@ -3186,7 +3186,7 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir content = [NSString stringWithFormat: @"BEGIN:VCALENDAR\n%@END:VCALENDAR\n", [event versitString]]; - [object saveContentString: content]; + return ([object saveContentString: content] == nil); } @end /* SOGoAppointmentFolder */ diff --git a/UI/Contacts/BrazilianPortuguese.lproj/Localizable.strings b/UI/Contacts/BrazilianPortuguese.lproj/Localizable.strings index f17f7ac4d..95ac11274 100644 --- a/UI/Contacts/BrazilianPortuguese.lproj/Localizable.strings +++ b/UI/Contacts/BrazilianPortuguese.lproj/Localizable.strings @@ -183,3 +183,7 @@ "Import cards" = "Import cards"; "Select file..." = "Select file..."; "Upload" = "Upload"; +"Import" = "Import"; +"OK" = "OK"; +"An error occured while importing contacts." = "An error occured while importing contacts."; +"Imported contacts:" = "Imported contacts:"; diff --git a/UI/Contacts/Czech.lproj/Localizable.strings b/UI/Contacts/Czech.lproj/Localizable.strings index 2a5183cfb..2210dad5e 100644 --- a/UI/Contacts/Czech.lproj/Localizable.strings +++ b/UI/Contacts/Czech.lproj/Localizable.strings @@ -183,3 +183,7 @@ "Import cards" = "Import cards"; "Select file..." = "Select file..."; "Upload" = "Upload"; +"Import" = "Import"; +"OK" = "OK"; +"An error occured while importing contacts." = "An error occured while importing contacts."; +"Imported contacts:" = "Imported contacts:"; diff --git a/UI/Contacts/Dutch.lproj/Localizable.strings b/UI/Contacts/Dutch.lproj/Localizable.strings index df8c96642..d3ae31f12 100644 --- a/UI/Contacts/Dutch.lproj/Localizable.strings +++ b/UI/Contacts/Dutch.lproj/Localizable.strings @@ -183,3 +183,7 @@ "Import cards" = "Import cards"; "Select file..." = "Select file..."; "Upload" = "Upload"; +"Import" = "Import"; +"OK" = "OK"; +"An error occured while importing contacts." = "An error occured while importing contacts."; +"Imported contacts:" = "Imported contacts:"; diff --git a/UI/Contacts/English.lproj/Localizable.strings b/UI/Contacts/English.lproj/Localizable.strings index b6fda56d6..d4378d317 100644 --- a/UI/Contacts/English.lproj/Localizable.strings +++ b/UI/Contacts/English.lproj/Localizable.strings @@ -183,3 +183,7 @@ "Import cards" = "Import cards"; "Select file..." = "Select file..."; "Upload" = "Upload"; +"Import" = "Import"; +"OK" = "OK"; +"An error occured while importing contacts." = "An error occured while importing contacts."; +"Imported contacts:" = "Imported contacts:"; diff --git a/UI/Contacts/French.lproj/Localizable.strings b/UI/Contacts/French.lproj/Localizable.strings index a56978581..747de55e5 100644 --- a/UI/Contacts/French.lproj/Localizable.strings +++ b/UI/Contacts/French.lproj/Localizable.strings @@ -183,3 +183,7 @@ "Import cards" = "Importer des contacts"; "Select file..." = "Sélectionner un fichier..."; "Upload" = "Ajouter"; +"Import" = "Import"; +"OK" = "OK"; +"An error occured while importing contacts." = "Une erreur s'est produite lors de l'importation."; +"Imported contacts:" = "Contacts importés:"; diff --git a/UI/Contacts/German.lproj/Localizable.strings b/UI/Contacts/German.lproj/Localizable.strings index acae593b8..c20cda49c 100644 --- a/UI/Contacts/German.lproj/Localizable.strings +++ b/UI/Contacts/German.lproj/Localizable.strings @@ -183,3 +183,7 @@ "Import cards" = "Import cards"; "Select file..." = "Select file..."; "Upload" = "Upload"; +"Import" = "Import"; +"OK" = "OK"; +"An error occured while importing contacts." = "An error occured while importing contacts."; +"Imported contacts:" = "Imported contacts:"; diff --git a/UI/Contacts/Hungarian.lproj/Localizable.strings b/UI/Contacts/Hungarian.lproj/Localizable.strings index 7d7023604..899793924 100644 --- a/UI/Contacts/Hungarian.lproj/Localizable.strings +++ b/UI/Contacts/Hungarian.lproj/Localizable.strings @@ -183,3 +183,7 @@ "Import cards" = "Import cards"; "Select file..." = "Select file..."; "Upload" = "Upload"; +"Import" = "Import"; +"OK" = "OK"; +"An error occured while importing contacts." = "An error occured while importing contacts."; +"Imported contacts:" = "Imported contacts:"; diff --git a/UI/Contacts/Italian.lproj/Localizable.strings b/UI/Contacts/Italian.lproj/Localizable.strings index 5927f923d..0d7b6546a 100644 --- a/UI/Contacts/Italian.lproj/Localizable.strings +++ b/UI/Contacts/Italian.lproj/Localizable.strings @@ -183,3 +183,7 @@ "Import cards" = "Import cards"; "Select file..." = "Select file..."; "Upload" = "Upload"; +"Import" = "Import"; +"OK" = "OK"; +"An error occured while importing contacts." = "An error occured while importing contacts."; +"Imported contacts:" = "Imported contacts:"; diff --git a/UI/Contacts/Russian.lproj/Localizable.strings b/UI/Contacts/Russian.lproj/Localizable.strings index e610c1ae3..ab35b80bd 100644 --- a/UI/Contacts/Russian.lproj/Localizable.strings +++ b/UI/Contacts/Russian.lproj/Localizable.strings @@ -168,3 +168,7 @@ "Import cards" = "Import cards"; "Select file..." = "Select file..."; "Upload" = "Upload"; +"Import" = "Import"; +"OK" = "OK"; +"An error occured while importing contacts." = "An error occured while importing contacts."; +"Imported contacts:" = "Imported contacts:"; diff --git a/UI/Contacts/Spanish.lproj/Localizable.strings b/UI/Contacts/Spanish.lproj/Localizable.strings index 6efb49792..33645e5a9 100644 --- a/UI/Contacts/Spanish.lproj/Localizable.strings +++ b/UI/Contacts/Spanish.lproj/Localizable.strings @@ -183,3 +183,7 @@ "Import cards" = "Import cards"; "Select file..." = "Select file..."; "Upload" = "Upload"; +"Import" = "Import"; +"OK" = "OK"; +"An error occured while importing contacts." = "An error occured while importing contacts."; +"Imported contacts:" = "Imported contacts:"; diff --git a/UI/Contacts/UIxContactsListView.h b/UI/Contacts/UIxContactsListView.h index 34bca4593..e10c10601 100644 --- a/UI/Contacts/UIxContactsListView.h +++ b/UI/Contacts/UIxContactsListView.h @@ -35,9 +35,9 @@ NSArray *contactInfos; } -- (void) importLdifData: (NSString *) ldifData; -- (void) importVcardData: (NSString *) vcardData; -- (void) importVcard: (NGVCard *) card; +- (int) importLdifData: (NSString *) ldifData; +- (int) importVcardData: (NSString *) vcardData; +- (BOOL) importVcard: (NGVCard *) card; @end diff --git a/UI/Contacts/UIxContactsListView.m b/UI/Contacts/UIxContactsListView.m index ff3928e58..3a39c4f35 100644 --- a/UI/Contacts/UIxContactsListView.m +++ b/UI/Contacts/UIxContactsListView.m @@ -230,26 +230,47 @@ - (id ) importAction { WORequest *request; + WOResponse *response; NSData *data; + NSMutableDictionary *rc; NSString *fileContent; + int imported = 0; request = [context request]; + rc = [NSMutableDictionary dictionary]; data = (NSData *)[request formValueForKey: @"contactsFile"]; - fileContent = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding]; + fileContent = [[NSString alloc] initWithData: data + encoding: NSUTF8StringEncoding]; [fileContent autorelease]; if (fileContent && [fileContent length]) { if ([fileContent hasPrefix: @"dn:"]) - [self importLdifData: fileContent]; + imported = [self importLdifData: fileContent]; + else if ([fileContent hasPrefix: @"BEGIN:"]) + imported = [self importVcardData: fileContent]; else - [self importVcardData: fileContent]; + imported = 0; } - return [self redirectToLocation: @"../view"]; + + [rc setObject: [NSNumber numberWithInt: imported] + forKey: @"imported"]; + if (imported <= 0) + [rc setObject: [self labelForKey: @"An error occured while importing contacts."] + forKey: @"message"]; + else + [rc setObject: [NSString stringWithFormat: @"%@ %d", + [self labelForKey: @"Imported contacts:"], imported] + forKey: @"message"]; + + response = [self responseWithStatus: 200]; + [(WOResponse*)response appendContentString: [rc jsonRepresentation]]; + + return response; } -- (void) importLdifData: (NSString *) ldifData +- (int) importLdifData: (NSString *) ldifData { SOGoContactGCSFolder *folder; NSString *key, *value; @@ -258,6 +279,7 @@ NGVCard *vCard; NSString *uid; int i,j,count,linesCount; + int rc = 0; folder = [self clientObject]; ldifContacts = [ldifData componentsSeparatedByString: @"\ndn"]; @@ -297,25 +319,33 @@ if (ldifEntry) { vCard = [ldifEntry vCard]; - [self importVcard: vCard]; + if ([self importVcard: vCard]) + rc++; } } + return rc; } -- (void) importVcardData: (NSString *) vcardData +- (int) importVcardData: (NSString *) vcardData { NGVCard *card; + int rc; + rc = 0; card = [NGVCard parseSingleFromSource: vcardData]; - [self importVcard: card]; + if ([self importVcard: card]) + rc = 1; + + return rc; } -- (void) importVcard: (NGVCard *) card +- (BOOL) importVcard: (NGVCard *) card { NSString *uid, *name; SOGoContactGCSFolder *folder; NSException *ex; + BOOL rc = NO; if (card) { @@ -328,7 +358,11 @@ baseVersion: 0]; if (ex) NSLog (@"write failed: %@", ex); + else + rc = YES; } + + return rc; } diff --git a/UI/Contacts/Welsh.lproj/Localizable.strings b/UI/Contacts/Welsh.lproj/Localizable.strings index 194344dc8..811c2b667 100644 --- a/UI/Contacts/Welsh.lproj/Localizable.strings +++ b/UI/Contacts/Welsh.lproj/Localizable.strings @@ -167,3 +167,7 @@ "Import cards" = "Import cards"; "Select file..." = "Select file..."; "Upload" = "Upload"; +"Import" = "Import"; +"OK" = "OK"; +"An error occured while importing contacts." = "An error occured while importing contacts."; +"Imported contacts:" = "Imported contacts:"; diff --git a/UI/Scheduler/BrazilianPortuguese.lproj/Localizable.strings b/UI/Scheduler/BrazilianPortuguese.lproj/Localizable.strings index 2ab4030cf..94020d22b 100644 --- a/UI/Scheduler/BrazilianPortuguese.lproj/Localizable.strings +++ b/UI/Scheduler/BrazilianPortuguese.lproj/Localizable.strings @@ -111,6 +111,10 @@ "Publish Calendar..." = "Publicar Calendário..."; "Reload Remote Calendars" = "Recarregar Calendários Remotos"; "Properties" = "Propriedades"; +"Import" = "Import"; +"OK" = "OK"; +"An error occured while importing calendar." = "An error occured while importing calendar."; +"Imported events:" = "Imported events:"; "Compose E-Mail to All Attendees" = "Compor E-Mail para Todos os Participantes"; "Compose E-Mail to Undecided Attendees" = "Compor E-Mail para os Participantes não confirmados"; diff --git a/UI/Scheduler/Czech.lproj/Localizable.strings b/UI/Scheduler/Czech.lproj/Localizable.strings index d226ba3fa..4cf9d4c65 100644 --- a/UI/Scheduler/Czech.lproj/Localizable.strings +++ b/UI/Scheduler/Czech.lproj/Localizable.strings @@ -111,6 +111,10 @@ "Publish Calendar..." = "Publikovat kalendář..."; "Reload Remote Calendars" = "Nahrát vzdálené kalendáře"; "Properties" = "Vlastnosti"; +"Import" = "Import"; +"OK" = "OK"; +"An error occured while importing calendar." = "An error occured while importing calendar."; +"Imported events:" = "Imported events:"; "Compose E-Mail to All Attendees" = "Vytvořit e-mail pro všechny účastníky"; "Compose E-Mail to Undecided Attendees" = "Vytvořit e-mail pro nerozhodnuté účastníky"; diff --git a/UI/Scheduler/Dutch.lproj/Localizable.strings b/UI/Scheduler/Dutch.lproj/Localizable.strings index 40fef0f93..3e27c1065 100644 --- a/UI/Scheduler/Dutch.lproj/Localizable.strings +++ b/UI/Scheduler/Dutch.lproj/Localizable.strings @@ -111,6 +111,10 @@ "Publish Calendar..." = "Agenda publiceren..."; "Reload Remote Calendars" = "Externe agenda vernieuwen"; "Properties" = "Instellingen"; +"Import" = "Import"; +"OK" = "OK"; +"An error occured while importing calendar." = "An error occured while importing calendar."; +"Imported events:" = "Imported events:"; "Compose E-Mail to All Attendees" = "E-mail aan alle deelnemers opstellen"; "Compose E-Mail to Undecided Attendees" = "E-mail aan deelnemers opstellen die nog niet hebben gereageerd"; diff --git a/UI/Scheduler/English.lproj/Localizable.strings b/UI/Scheduler/English.lproj/Localizable.strings index b782bc10a..d05a1581e 100644 --- a/UI/Scheduler/English.lproj/Localizable.strings +++ b/UI/Scheduler/English.lproj/Localizable.strings @@ -111,6 +111,10 @@ "Publish Calendar..." = "Publish Calendar..."; "Reload Remote Calendars" = "Reload Remote Calendars"; "Properties" = "Properties"; +"Import" = "Import"; +"OK" = "OK"; +"An error occured while importing calendar." = "An error occured while importing calendar."; +"Imported events:" = "Imported events:"; "Compose E-Mail to All Attendees" = "Compose E-Mail to All Attendees"; "Compose E-Mail to Undecided Attendees" = "Compose E-Mail to Undecided Attendees"; diff --git a/UI/Scheduler/French.lproj/Localizable.strings b/UI/Scheduler/French.lproj/Localizable.strings index b9c6ae2db..855395e5d 100644 --- a/UI/Scheduler/French.lproj/Localizable.strings +++ b/UI/Scheduler/French.lproj/Localizable.strings @@ -111,6 +111,10 @@ "Publish Calendar..." = "Publier l'agenda..."; "Reload Remote Calendars" = "Recharger les agendas distants"; "Properties" = "Propriétés"; +"Import" = "Import"; +"OK" = "OK"; +"An error occured while importing calendar." = "Une erreur s'est produite lors de l'importation."; +"Imported events:" = "Événements importés:"; "Compose E-Mail to All Attendees" = "Rédiger un courriel pour tous les participants"; "Compose E-Mail to Undecided Attendees" = "Rédiger un courriel pour les participants indécis"; diff --git a/UI/Scheduler/German.lproj/Localizable.strings b/UI/Scheduler/German.lproj/Localizable.strings index 6fa49c57c..bc5a55049 100644 --- a/UI/Scheduler/German.lproj/Localizable.strings +++ b/UI/Scheduler/German.lproj/Localizable.strings @@ -111,6 +111,10 @@ "Publish Calendar..." = "Kalender publizieren..."; "Reload Remote Calendars" = "Externe Kalender neu laden"; "Properties" = "Einstellungen"; +"Import" = "Import"; +"OK" = "OK"; +"An error occured while importing calendar." = "An error occured while importing calendar."; +"Imported events:" = "Imported events:"; "Compose E-Mail to All Attendees" = "E-Mail an alle Teilnehmer erstellen"; "Compose E-Mail to Undecided Attendees" = "E-Mail an unentschlossene Teilnehmer erstellen"; diff --git a/UI/Scheduler/Hungarian.lproj/Localizable.strings b/UI/Scheduler/Hungarian.lproj/Localizable.strings index 60feff351..8d2102056 100644 --- a/UI/Scheduler/Hungarian.lproj/Localizable.strings +++ b/UI/Scheduler/Hungarian.lproj/Localizable.strings @@ -111,6 +111,10 @@ "Publish Calendar..." = "Naptár közzététele..."; "Reload Remote Calendars" = "Távoli naptárak frissítése"; "Properties" = "Tulajdonságok"; +"Import" = "Import"; +"OK" = "OK"; +"An error occured while importing calendar." = "An error occured while importing calendar."; +"Imported events:" = "Imported events:"; "Compose E-Mail to All Attendees" = "Üzenet küldése az összes résztvevőnek"; "Compose E-Mail to Undecided Attendees" = "Üzenet küldése az bizonytalan résztvevőnek"; diff --git a/UI/Scheduler/Italian.lproj/Localizable.strings b/UI/Scheduler/Italian.lproj/Localizable.strings index 049383646..f87e944ad 100644 --- a/UI/Scheduler/Italian.lproj/Localizable.strings +++ b/UI/Scheduler/Italian.lproj/Localizable.strings @@ -111,6 +111,10 @@ "Publish Calendar..." = "Pubblica calendario..."; "Reload Remote Calendars" = "Aggiorna calendari remoti"; "Properties" = "Proprietà"; +"Import" = "Import"; +"OK" = "OK"; +"An error occured while importing calendar." = "An error occured while importing calendar."; +"Imported events:" = "Imported events:"; "Compose E-Mail to All Attendees" = "Invia Email a tutti gli invitati"; "Compose E-Mail to Undecided Attendees" = "Invia Email agli invitati indecisi"; diff --git a/UI/Scheduler/Russian.lproj/Localizable.strings b/UI/Scheduler/Russian.lproj/Localizable.strings index 97c4522c9..412209c4a 100644 --- a/UI/Scheduler/Russian.lproj/Localizable.strings +++ b/UI/Scheduler/Russian.lproj/Localizable.strings @@ -111,6 +111,10 @@ "Publish Calendar..." = "Опубликовать календарь..."; "Reload Remote Calendars" = "Обновить удаленные календари"; "Properties" = "Свойства"; +"Import" = "Import"; +"OK" = "OK"; +"An error occured while importing calendar." = "An error occured while importing calendar."; +"Imported events:" = "Imported events:"; "Compose E-Mail to All Attendees" = "Составить сообщение ко всем приглашенным"; "Compose E-Mail to Undecided Attendees" = "Составить сообщение ко всем не решившим приглашенным"; diff --git a/UI/Scheduler/Spanish.lproj/Localizable.strings b/UI/Scheduler/Spanish.lproj/Localizable.strings index 98fc2f3a6..ac65b65db 100644 --- a/UI/Scheduler/Spanish.lproj/Localizable.strings +++ b/UI/Scheduler/Spanish.lproj/Localizable.strings @@ -111,6 +111,10 @@ "Publish Calendar..." = "Publicar calendario..."; "Reload Remote Calendars" = "Recargar calendarios remotos"; "Properties" = "Propiedades"; +"Import" = "Import"; +"OK" = "OK"; +"An error occured while importing calendar." = "An error occured while importing calendar."; +"Imported events:" = "Imported events:"; "Compose E-Mail to All Attendees" = "Crear correo para todos los asistentes"; "Compose E-Mail to Undecided Attendees" = "Crear correo para todos los asistentes indecisos (sin confirmación)"; diff --git a/UI/Scheduler/UIxCalView.m b/UI/Scheduler/UIxCalView.m index b0bfd7617..88f480c37 100644 --- a/UI/Scheduler/UIxCalView.m +++ b/UI/Scheduler/UIxCalView.m @@ -20,6 +20,11 @@ * Boston, MA 02111-1307, USA. */ +#import +#import +#import +#import + #import #import #import @@ -697,20 +702,25 @@ static BOOL shouldDisplayWeekend = NO; - (WOResponse *) importAction { SOGoAppointmentFolder *folder; + NSMutableDictionary *rc; NSArray *components; WORequest *request; + WOResponse *response; NSString *fileContent; NSData *data; iCalCalendar *additions; - int i, count; + int i, count, imported; + imported = 0; + rc = [NSMutableDictionary dictionary]; request = [context request]; folder = [self clientObject]; data = (NSData *)[request formValueForKey: @"calendarFile"]; fileContent = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding]; [fileContent autorelease]; - if (fileContent && [fileContent length]) + if (fileContent && [fileContent length] + && [fileContent hasPrefix: @"BEGIN:"]) { additions = [iCalCalendar parseSingleFromSource: fileContent]; if (additions) @@ -718,22 +728,39 @@ static BOOL shouldDisplayWeekend = NO; components = [additions events]; count = [components count]; for (i = 0; i < count; i++) - [folder importComponent: [components objectAtIndex: i]]; + if ([folder importComponent: [components objectAtIndex: i]]) + imported++; components = [additions todos]; count = [components count]; for (i = 0; i < count; i++) - [folder importComponent: [components objectAtIndex: i]]; + if ([folder importComponent: [components objectAtIndex: i]]) + imported++; components = [additions journals]; count = [components count]; for (i = 0; i < count; i++) - [folder importComponent: [components objectAtIndex: i]]; + if ([folder importComponent: [components objectAtIndex: i]]) + imported++; components = [additions freeBusys]; count = [components count]; for (i = 0; i < count; i++) - [folder importComponent: [components objectAtIndex: i]]; + if ([folder importComponent: [components objectAtIndex: i]]) + imported++; } } - return [self redirectToLocation: @"../view"]; + + [rc setObject: [NSNumber numberWithInt: imported] + forKey: @"imported"]; + if (imported <= 0) + [rc setObject: [self labelForKey: @"An error occured while importing calendar."] + forKey: @"message"]; + else + [rc setObject: [NSString stringWithFormat: @"%@ %d", + [self labelForKey: @"Imported events:"], imported] + forKey: @"message"]; + + response = [self responseWithStatus: 200]; + [(WOResponse*)response appendContentString: [rc jsonRepresentation]]; + return response; } @end /* UIxCalView */ diff --git a/UI/Scheduler/Welsh.lproj/Localizable.strings b/UI/Scheduler/Welsh.lproj/Localizable.strings index 7ecd7d081..f9fc6ad79 100644 --- a/UI/Scheduler/Welsh.lproj/Localizable.strings +++ b/UI/Scheduler/Welsh.lproj/Localizable.strings @@ -111,6 +111,10 @@ "Publish Calendar..." = "Cyhoeddi Calendr..."; "Reload Remote Calendars" = "Ail-lwytho Calendrau Anghysbell"; "Properties" = "Dewisiadau"; +"Import" = "Import"; +"OK" = "OK"; +"An error occured while importing calendar." = "An error occured while importing calendar."; +"Imported events:" = "Imported events:"; "Compose E-Mail to All Attendees" = "Cyfansoddi Ebost i bawb sy'n mynychu"; "Compose E-Mail to Undecided Attendees" = "Cyfansoddi Ebost i bawb sydd heb benderfynu"; diff --git a/UI/Templates/ContactsUI/UIxContactFoldersView.wox b/UI/Templates/ContactsUI/UIxContactFoldersView.wox index d25761729..bf9a964e9 100644 --- a/UI/Templates/ContactsUI/UIxContactFoldersView.wox +++ b/UI/Templates/ContactsUI/UIxContactFoldersView.wox @@ -30,13 +30,23 @@

+ onsubmit="return AIM.submit(this, {'onStart' : validateUploadForm, + 'onComplete' : uploadCompleted})">

+ + + +
    diff --git a/UI/WebServerResources/ContactsUI.js b/UI/WebServerResources/ContactsUI.js index b078aa02a..47ed21292 100644 --- a/UI/WebServerResources/ContactsUI.js +++ b/UI/WebServerResources/ContactsUI.js @@ -670,19 +670,40 @@ function onAddressBookImport(event) { var top = cellPosition[1]; var div = $("uploadDialog"); + var res = $("uploadResults"); div.style.top = top + "px"; + res.style.top = top + "px"; div.style.left = left + "px"; + res.style.left = left + "px"; div.style.display = "block"; } function hideContactsImport () { $("uploadDialog").style.display = "none"; } +function hideImportResults () { + $("uploadResults").style.display = "none"; +} function validateUploadForm () { rc = false; if ($("contactsFile").value.length) rc = true; return rc; } +function uploadCompleted (response) { + response = response.replace (/
    /, "");
    +    response = response.replace (/<\/pre>/, "");
    +    data = response.evalJSON (true);
    +
    +    var div = $("uploadResults");
    +    $("uploadOK").onclick = hideImportResults;
    +    $("uploadResultsContent").update (data.message);
    +
    +    if (data.imported > 0)
    +      refreshCurrentFolder ();
    +
    +    hideContactsImport ();
    +    $("uploadResults").style.display = "block";
    +}
     
     function onAddressBookRemove(event) {
         var selector = $("contactFolders");
    diff --git a/UI/WebServerResources/SchedulerUI.js b/UI/WebServerResources/SchedulerUI.js
    index 9e6e3faf0..8639726d6 100644
    --- a/UI/WebServerResources/SchedulerUI.js
    +++ b/UI/WebServerResources/SchedulerUI.js
    @@ -1904,19 +1904,40 @@ function onCalendarImport(event) {
         var top = cellPosition[1];
     
         var div = $("uploadDialog");
    +    var res = $("uploadResults");
         div.style.top = top + "px";
    +    res.style.top = top + "px";
         div.style.left = left + "px";
    +    res.style.left = left + "px";
         div.style.display = "block";
     }
     function hideCalendarImport () {
         $("uploadDialog").style.display = "none";
     }
    +function hideImportResults () {
    +    $("uploadResults").style.display = "none";
    +}
     function validateUploadForm () {
         rc = false;
         if ($("calendarFile").value.length)
           rc = true;
         return rc;
     }
    +function uploadCompleted (response) {
    +    response = response.replace (/
    /, "");
    +    response = response.replace (/<\/pre>/, "");
    +    data = response.evalJSON (true);
    +
    +    var div = $("uploadResults");
    +    $("uploadOK").onclick = hideImportResults;
    +    $("uploadResultsContent").update (data.message);
    +
    +    if (data.imported > 0)
    +      refreshCurrentFolder ();
    +
    +    hideCalendarImport ();
    +    $("uploadResults").style.display = "block";
    +}
     
     function setEventsOnCalendar(checkBox, li) {
         li.observe("mousedown", listRowMouseDownHandler);
    diff --git a/UI/WebServerResources/generic.css b/UI/WebServerResources/generic.css
    index fb3301d01..1df673d01 100644
    --- a/UI/WebServerResources/generic.css
    +++ b/UI/WebServerResources/generic.css
    @@ -783,11 +783,13 @@ DIV.resize-handle
       color: #000000 !important;
     }
     
    -DIV#uploadDialog
    +DIV#uploadDialog,DIV#uploadResults
     { border-width: 1px;
       width: 260px;
    -  height: 118px;
    -  }
    +  height: 127px; }
    +DIV#uploadDialog DIV,DIV#uploadResults DIV
    +{ width: 260px;
    +  height: 115px; }
     
     DIV.dialog 
     { position: absolute;
    diff --git a/UI/WebServerResources/generic.js b/UI/WebServerResources/generic.js
    index 40698cb7f..035bf304a 100644
    --- a/UI/WebServerResources/generic.js
    +++ b/UI/WebServerResources/generic.js
    @@ -1672,4 +1672,54 @@ function onHeaderClick(event) {
         window.alert("generic headerClick");
     }
     
    +/**
    +*
    +*  AJAX IFRAME METHOD (AIM)
    +*  http://www.webtoolkit.info/
    +*
    +**/
    + 
    +AIM = {
    +	frame : function(c) {
    +		var d = new Element ('div');
    +    var n = d.identify ();
    +		d.innerHTML = '';
    +		document.body.appendChild(d);
    +		var i = $(n); // TODO: useful?
    +		if (c && typeof(c.onComplete) == 'function')
    +      i.onComplete = c.onComplete;
    +		return n;
    +	},
    + 
    +	form : function(f, name) {
    +		f.writeAttribute('target', name);
    +	},
    + 
    +	submit : function(f, c) {
    +		AIM.form(f, AIM.frame(c));
    +		if (c && typeof(c.onStart) == 'function')
    +			return c.onStart();
    +		else
    +			return true;
    +	},
    + 
    +	loaded : function(id) {
    +		var i = $(id);
    +		if (i.contentDocument)
    +			var d = i.contentDocument;
    +		else if (i.contentWindow)
    +			var d = i.contentWindow.document;
    +		else
    +			var d = window.frames[id].document;
    +		if (d.location.href == "about:blank")
    +			return;
    + 
    +		if (typeof(i.onComplete) == 'function')
    +			i.onComplete(d.body.innerHTML);
    +	}
    + 
    +}
    +
    +
     document.observe("dom:loaded", onLoadHandler);