From 2cef5383385611fd5abd919332405e78a2de5501 Mon Sep 17 00:00:00 2001 From: wolfgang Date: Fri, 28 Mar 2008 14:33:07 +0000 Subject: [PATCH] git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1393 d1b88da0-ebda-0310-925b-ed51d893ca5b --- ChangeLog | 12 + NEWS | 2 + .../Appointments/SOGoAppointmentFolder.m | 32 +- SoObjects/SOGo/AgenorUserDefaults.m | 4 + SoObjects/SOGo/SOGoPermissions.m | 1 - .../English.lproj/Localizable.strings | 2 + UI/Scheduler/French.lproj/Localizable.strings | 2 + .../SchedulerUI/UIxAttendeesEditor.wox | 4 +- UI/WebServerResources/ContactsUI.js | 737 +++++++++--------- UI/WebServerResources/SchedulerUI.js | 151 +++- UI/WebServerResources/UIxAppointmentEditor.js | 26 +- UI/WebServerResources/UIxAttendeesEditor.css | 3 +- UI/WebServerResources/UIxAttendeesEditor.js | 310 +++++--- UI/WebServerResources/UIxComponentEditor.js | 10 +- UI/WebServerResources/UIxTaskEditor.js | 224 +++--- 15 files changed, 906 insertions(+), 614 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5d07f8d5..d960475d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ +2008-03-28 Wolfgang Sourdeau + + * SoObjects/Appointments/SOGoAppointmentFolder.m + ([SOGoAppointmentFolder + -appendObject:objectproperties:propertieswithBaseURL:baseURLtoComplexResponse:r]): + check whether the current user has access to the objects returned + before including their properties. + 2008-03-27 Wolfgang Sourdeau + * SoObjects/SOGo/AgenorUserDefaults.m ([AgenorUserDefaults + -primaryFetchProfile]): we unescape the fetched value before + constructing the NSDictionary. + * UI/Scheduler/UIxComponentEditor.m ([UIxComponentEditor -setComponent:newComponent]): the weeks start on sunday in OpenStep and are indexed from 0. diff --git a/NEWS b/NEWS index a2ed8f1d..63ed59f2 100644 --- a/NEWS +++ b/NEWS @@ -5,8 +5,10 @@ - pressing enter in the contact edition dialog will perform the creation/update operation - implemented more of the CalDAV specification for compatibility with Lightning 0.8 - added Italian translation, thanks to Marco Lertora +- added initial logic for splitting overlapping events - improved restoration of drag handles state - improved contextual menu handling of Address Book module +- fixed time/date control widget of attendees editor - fixed various bugs occuring with Safari 3.1 - monthly events would not be returned properly - bi-weekly events would appear every week instead diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 173b9c0f..7824aca9 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -246,26 +246,32 @@ static NSNumber *sharedYes = nil; NSMutableDictionary *currentValue; SOGoObject *sogoObject; NSString *content; + SoSecurityManager *mgr; values = [NSMutableArray array]; -// if ([[object objectForKey: @"c_name"] isEqualToString: @"176A-4E8BDE62-5-B73ECD10"]) -// NSLog(@"breajpoint"); +#warning this check should be done directly in the query... we should fix this sometime + mgr = [SoSecurityManager sharedSecurityManager]; sogoObject = [self lookupName: [object objectForKey: @"c_name"] inContext: context acquire: NO]; - list = [properties objectEnumerator]; - while ((currentProperty = [list nextObject])) + if (!([mgr validatePermission: SOGoPerm_AccessObject + onObject: sogoObject + inContext: context])) { - currentValue = [NSMutableDictionary dictionary]; - [currentValue setObject: currentProperty - forKey: @"property"]; - content = [self _property: currentProperty - ofObject: sogoObject]; - if (content) - [currentValue setObject: content - forKey: @"content"]; - [values addObject: currentValue]; + list = [properties objectEnumerator]; + while ((currentProperty = [list nextObject])) + { + currentValue = [NSMutableDictionary dictionary]; + [currentValue setObject: currentProperty + forKey: @"property"]; + content = [self _property: currentProperty + ofObject: sogoObject]; + if (content) + [currentValue setObject: content + forKey: @"content"]; + [values addObject: currentValue]; + } } return values; diff --git a/SoObjects/SOGo/AgenorUserDefaults.m b/SoObjects/SOGo/AgenorUserDefaults.m index 156b4ffe..590b1a55 100644 --- a/SoObjects/SOGo/AgenorUserDefaults.m +++ b/SoObjects/SOGo/AgenorUserDefaults.m @@ -153,6 +153,10 @@ static NSString *uidColumnName = @"c_uid"; value = [row objectForKey: fieldName]; if ([value isNotNull]) { + value = [value stringByReplacingString: @"''" + withString: @"'"]; + value = [value stringByReplacingString: @"\\\\" + withString: @"\\"]; plistData = [value dataUsingEncoding: NSUTF8StringEncoding]; values = [NSPropertyListSerialization propertyListFromData: plistData diff --git a/SoObjects/SOGo/SOGoPermissions.m b/SoObjects/SOGo/SOGoPermissions.m index fc98f0d1..740ef718 100644 --- a/SoObjects/SOGo/SOGoPermissions.m +++ b/SoObjects/SOGo/SOGoPermissions.m @@ -69,7 +69,6 @@ NSString *SOGoMailRole_Writer = @"MailWriter"; NSString *SOGoMailRole_Poster = @"MailPoster"; NSString *SOGoMailRole_Expunger = @"MailExpunger"; NSString *SOGoMailRole_Administrator = @"MailAdministrator"; -NSString *SOGoMailRole_MessageEraser = @"MailMessageEraser"; /* permissions */ NSString *SOGoPerm_AccessObject= @"Access Object"; diff --git a/UI/Scheduler/English.lproj/Localizable.strings b/UI/Scheduler/English.lproj/Localizable.strings index 21caedce..3c755832 100644 --- a/UI/Scheduler/English.lproj/Localizable.strings +++ b/UI/Scheduler/English.lproj/Localizable.strings @@ -247,6 +247,8 @@ "Browse URL" = "Browse URL"; +"newAttendee" = "Add attendee"; + /* calendar modes */ "Overview" = "Overview"; diff --git a/UI/Scheduler/French.lproj/Localizable.strings b/UI/Scheduler/French.lproj/Localizable.strings index 2ade4874..e6ebaac8 100644 --- a/UI/Scheduler/French.lproj/Localizable.strings +++ b/UI/Scheduler/French.lproj/Localizable.strings @@ -245,6 +245,8 @@ "Browse URL" = "Visiter l'URL"; +"newAttendee" = "Nouvel invité"; + /* calendar modes */ "Overview" = "Vue synthétique"; diff --git a/UI/Templates/SchedulerUI/UIxAttendeesEditor.wox b/UI/Templates/SchedulerUI/UIxAttendeesEditor.wox index 1302971b..ae58f71f 100644 --- a/UI/Templates/SchedulerUI/UIxAttendeesEditor.wox +++ b/UI/Templates/SchedulerUI/UIxAttendeesEditor.wox @@ -56,7 +56,7 @@
diff --git a/UI/WebServerResources/ContactsUI.js b/UI/WebServerResources/ContactsUI.js index 696034e6..4879afa2 100644 --- a/UI/WebServerResources/ContactsUI.js +++ b/UI/WebServerResources/ContactsUI.js @@ -7,22 +7,22 @@ var usersRightsWindowHeight = 200; var usersRightsWindowWidth = 450; function validateEditorInput(sender) { - var errortext = ""; - var field; + var errortext = ""; + var field; - field = document.pageform.subject; - if (field.value == "") - errortext = errortext + labels.error_missingsubject + "\n"; + field = document.pageform.subject; + if (field.value == "") + errortext = errortext + labels.error_missingsubject + "\n"; - if (!hasRecipients()) - errortext = errortext + labels.error_missingrecipients + "\n"; + if (!hasRecipients()) + errortext = errortext + labels.error_missingrecipients + "\n"; - if (errortext.length > 0) { - alert(labels.error_validationfailed + ":\n" - + errortext); - return false; - } - return true; + if (errortext.length > 0) { + alert(labels.error_validationfailed + ":\n" + + errortext); + return false; + } + return true; } function openContactsFolder(contactsFolder, reload, idx) { @@ -62,15 +62,15 @@ function openContactsFolder(contactsFolder, reload, idx) { } function openContactsFolderAtIndex(element) { - var idx = element.getAttribute("idx"); - var url = URLForFolderID(currentContactFolder) + "/view?noframe=1&idx=" + idx; + var idx = element.getAttribute("idx"); + var url = URLForFolderID(currentContactFolder) + "/view?noframe=1&idx=" + idx; - if (document.contactsListAjaxRequest) { - document.contactsListAjaxRequest.aborted = true; - document.contactsListAjaxRequest.abort(); - } - document.contactsListAjaxRequest - = triggerAjaxRequest(url, contactsListCallback); + if (document.contactsListAjaxRequest) { + document.contactsListAjaxRequest.aborted = true; + document.contactsListAjaxRequest.abort(); + } + document.contactsListAjaxRequest + = triggerAjaxRequest(url, contactsListCallback); } function contactsListCallback(http) { @@ -163,104 +163,104 @@ function contactsListCallback(http) { } function onContactFoldersContextMenu(event) { - var menu = $("contactFoldersMenu"); - Event.observe(menu, "mousedown", onContactFoldersContextMenuHide, false); - popupMenu(event, "contactFoldersMenu", this); + var menu = $("contactFoldersMenu"); + Event.observe(menu, "mousedown", onContactFoldersContextMenuHide, false); + popupMenu(event, "contactFoldersMenu", this); - var topNode = $("contactFolders"); - var selectedNodes = topNode.getSelectedRows(); - topNode.menuSelectedRows = selectedNodes; - for (var i = 0; i < selectedNodes.length; i++) - $(selectedNodes[i]).deselect(); - topNode.menuSelectedEntry = this; - $(this).selectElement(); + var topNode = $("contactFolders"); + var selectedNodes = topNode.getSelectedRows(); + topNode.menuSelectedRows = selectedNodes; + for (var i = 0; i < selectedNodes.length; i++) + $(selectedNodes[i]).deselect(); + topNode.menuSelectedEntry = this; + $(this).selectElement(); } function onContactContextMenu(event) { - var menu = $("contactMenu"); - var topNode = $('contactsList'); - var selectedNodes = topNode.getSelectedRows(); + var menu = $("contactMenu"); + var topNode = $('contactsList'); + var selectedNodes = topNode.getSelectedRows(); - if (selectedNodes.length > 1) { - // TODO: Add support for selection of multiple contacts - } - else { - Event.observe(menu, "hideMenu", onContactContextMenuHide); - popupMenu(event, "contactMenu", this); - } + if (selectedNodes.length > 1) { + // TODO: Add support for selection of multiple contacts + } + else { + Event.observe(menu, "hideMenu", onContactContextMenuHide); + popupMenu(event, "contactMenu", this); + } } function onContactContextMenuHide(event) { - var topNode = $("contactsList"); + var topNode = $("contactsList"); - if (topNode.menuSelectedEntry) { - $(topNode.menuSelectedEntry).deselect(); - topNode.menuSelectedEntry = null; - } - if (topNode.menuSelectedRows) { - var nodes = topNode.menuSelectedRows; - for (var i = 0; i < nodes.length; i++) - $(nodes[i]).selectElement(); - topNode.menuSelectedRows = null; - } + if (topNode.menuSelectedEntry) { + $(topNode.menuSelectedEntry).deselect(); + topNode.menuSelectedEntry = null; + } + if (topNode.menuSelectedRows) { + var nodes = topNode.menuSelectedRows; + for (var i = 0; i < nodes.length; i++) + $(nodes[i]).selectElement(); + topNode.menuSelectedRows = null; + } } function onContactFoldersContextMenuHide(event) { - var topNode = $("contactFolders"); + var topNode = $("contactFolders"); - if (topNode.menuSelectedEntry) { - topNode.menuSelectedEntry.deselect(); - topNode.menuSelectedEntry = null; - } - if (topNode.menuSelectedRows) { - var nodes = topNode.menuSelectedRows; - for (var i = 0; i < nodes.length; i++) - nodes[i].selectElement(); - topNode.menuSelectedRows = null; - } + if (topNode.menuSelectedEntry) { + topNode.menuSelectedEntry.deselect(); + topNode.menuSelectedEntry = null; + } + if (topNode.menuSelectedRows) { + var nodes = topNode.menuSelectedRows; + for (var i = 0; i < nodes.length; i++) + nodes[i].selectElement(); + topNode.menuSelectedRows = null; + } } function onFolderMenuHide(event) { - var topNode = $('d'); + var topNode = $('d'); - if (topNode.menuSelectedEntry) { - topNode.menuSelectedEntry.deselect(); - topNode.menuSelectedEntry = null; - } - if (topNode.selectedEntry) - topNode.selectedEntry.selectElement(); + if (topNode.menuSelectedEntry) { + topNode.menuSelectedEntry.deselect(); + topNode.menuSelectedEntry = null; + } + if (topNode.selectedEntry) + topNode.selectedEntry.selectElement(); } function loadContact(idx) { - if (document.contactAjaxRequest) { - document.contactAjaxRequest.aborted = true; - document.contactAjaxRequest.abort(); - } - - if (cachedContacts[currentContactFolder + "/" + idx]) { - var div = $('contactView'); - div.innerHTML = cachedContacts[currentContactFolder + "/" + idx]; - } - else { - var url = (URLForFolderID(currentContactFolder) - + "/" + idx + "/view?noframe=1"); - document.contactAjaxRequest - = triggerAjaxRequest(url, contactLoadCallback, idx); - } + if (document.contactAjaxRequest) { + document.contactAjaxRequest.aborted = true; + document.contactAjaxRequest.abort(); + } + + if (cachedContacts[currentContactFolder + "/" + idx]) { + var div = $('contactView'); + div.innerHTML = cachedContacts[currentContactFolder + "/" + idx]; + } + else { + var url = (URLForFolderID(currentContactFolder) + + "/" + idx + "/view?noframe=1"); + document.contactAjaxRequest + = triggerAjaxRequest(url, contactLoadCallback, idx); + } } function contactLoadCallback(http) { - var div = $('contactView'); - - if (http.readyState == 4 - && http.status == 200) { - document.contactAjaxRequest = null; - var content = http.responseText; - cachedContacts[currentContactFolder + "/" + http.callbackData] = content; - div.innerHTML = content; - } - else - log ("ajax problem 2: " + http.status); + var div = $('contactView'); + + if (http.readyState == 4 + && http.status == 200) { + document.contactAjaxRequest = null; + var content = http.responseText; + cachedContacts[currentContactFolder + "/" + http.callbackData] = content; + div.innerHTML = content; + } + else + log ("ajax problem 2: " + http.status); } var rowSelectionCount = 0; @@ -268,177 +268,177 @@ var rowSelectionCount = 0; validateControls(); function showElement(e, shouldShow) { - e.style.display = shouldShow ? "" : "none"; + e.style.display = shouldShow ? "" : "none"; } function enableElement(e, shouldEnable) { - if(!e) - return; - if(shouldEnable) { - if(e.hasAttribute("disabled")) - e.removeAttribute("disabled"); - } - else { - e.setAttribute("disabled", "1"); - } + if(!e) + return; + if(shouldEnable) { + if(e.hasAttribute("disabled")) + e.removeAttribute("disabled"); + } + else { + e.setAttribute("disabled", "1"); + } } function validateControls() { - var e = $("moveto"); - this.enableElement(e, rowSelectionCount > 0); + var e = $("moveto"); + this.enableElement(e, rowSelectionCount > 0); } function moveTo(uri) { - alert("MoveTo: " + uri); + alert("MoveTo: " + uri); } /* contact menu entries */ function onContactRowDblClick(event) { - var contactId = this.getAttribute('id'); + var contactId = this.getAttribute('id'); - openContactWindow(URLForFolderID(currentContactFolder) - + "/" + contactId + "/edit", contactId); + openContactWindow(URLForFolderID(currentContactFolder) + + "/" + contactId + "/edit", contactId); - return false; + return false; } function onContactSelectionChange(event) { - var rows = this.getSelectedRowsId(); + var rows = this.getSelectedRowsId(); - if (rows.length == 1) { - var node = $(rows[0]); - loadContact(node.getAttribute('id')); - } - else if (rows.length > 1) { - $('contactView').update(); - } + if (rows.length == 1) { + var node = $(rows[0]); + loadContact(node.getAttribute('id')); + } + else if (rows.length > 1) { + $('contactView').update(); + } } function onMenuEditContact(event) { - var contactId = document.menuTarget.getAttribute('id'); + var contactId = document.menuTarget.getAttribute('id'); - openContactWindow(URLForFolderID(currentContactFolder) - + "/" + contactId + "/edit", contactId); + openContactWindow(URLForFolderID(currentContactFolder) + + "/" + contactId + "/edit", contactId); } function onMenuWriteToContact(event) { - var contactId = document.menuTarget.getAttribute('id'); + var contactId = document.menuTarget.getAttribute('id'); - openMailComposeWindow(ApplicationBaseURL + currentContactFolder - + "/" + contactId + "/write"); + openMailComposeWindow(ApplicationBaseURL + currentContactFolder + + "/" + contactId + "/write"); - if (document.body.hasClassName("popup")) - window.close(); + if (document.body.hasClassName("popup")) + window.close(); } function onMenuAIMContact(event) { - var contactRow = $(document.menuTarget.getAttribute('id')); - var aimCell = contactRow.down('td', 2); + var contactRow = $(document.menuTarget.getAttribute('id')); + var aimCell = contactRow.down('td', 2); - window.location.href = "aim:goim?ScreenName=" + aimCell.firstChild.nodeValue; + window.location.href = "aim:goim?ScreenName=" + aimCell.firstChild.nodeValue; } function onMenuDeleteContact(event) { - uixDeleteSelectedContacts(this); + uixDeleteSelectedContacts(this); } function onToolbarEditSelectedContacts(event) { - var contactsList = $('contactsList'); - var rows = contactsList.getSelectedRowsId(); + var contactsList = $('contactsList'); + var rows = contactsList.getSelectedRowsId(); - if (rows.length == 0) { - window.alert(labels["Please select a contact."]); - return false; - } + if (rows.length == 0) { + window.alert(labels["Please select a contact."]); + return false; + } - for (var i = 0; i < rows.length; i++) { - openContactWindow(URLForFolderID(currentContactFolder) - + "/" + rows[i] + "/edit", rows[i]); - } + for (var i = 0; i < rows.length; i++) { + openContactWindow(URLForFolderID(currentContactFolder) + + "/" + rows[i] + "/edit", rows[i]); + } - return false; + return false; } function onToolbarWriteToSelectedContacts(event) { - var contactsList = $('contactsList'); - var rows = contactsList.getSelectedRowsId(); - var rowsWithEmail = 0; + var contactsList = $('contactsList'); + var rows = contactsList.getSelectedRowsId(); + var rowsWithEmail = 0; - if (rows.length == 0) { - openMailComposeWindow(ApplicationBaseURL + "Mail/compose"); - return false; - } + if (rows.length == 0) { + openMailComposeWindow(ApplicationBaseURL + "Mail/compose"); + return false; + } - for (var i = 0; i < rows.length; i++) { - var emailCell = $(rows[i]).down('td', 1); - if (emailCell.firstChild) { // .nodeValue is the contact email address - rowsWithEmail++; - openMailComposeWindow(ApplicationBaseURL + currentContactFolder - + "/" + rows[i] + "/write"); - } - } + for (var i = 0; i < rows.length; i++) { + var emailCell = $(rows[i]).down('td', 1); + if (emailCell.firstChild) { // .nodeValue is the contact email address + rowsWithEmail++; + openMailComposeWindow(ApplicationBaseURL + currentContactFolder + + "/" + rows[i] + "/write"); + } + } - if (rowsWithEmail == 0) { - window.alert(labels["The selected contact has no email address."]); - } - else if (document.body.hasClassName("popup")) - window.close(); + if (rowsWithEmail == 0) { + window.alert(labels["The selected contact has no email address."]); + } + else if (document.body.hasClassName("popup")) + window.close(); - return false; + return false; } function uixDeleteSelectedContacts(sender) { - var failCount = 0; - var contactsList = $('contactsList'); - var rows = contactsList.getSelectedRowsId(); + var failCount = 0; + var contactsList = $('contactsList'); + var rows = contactsList.getSelectedRowsId(); - if (rows.length == 0) { - window.alert(labels["Please select a contact."]); - return false; - } + if (rows.length == 0) { + window.alert(labels["Please select a contact."]); + return false; + } - var contactView = $('contactView'); + var contactView = $('contactView'); - for (var i = 0; i < rows.length; i++) { - var url, http, rowElem; + for (var i = 0; i < rows.length; i++) { + var url, http, rowElem; - /* send AJAX request (synchronously) */ + /* send AJAX request (synchronously) */ - url = (URLForFolderID(currentContactFolder) + "/" - + rows[i] + "/delete"); - http = createHTTPClient(); - http.open("POST", url, false /* not async */); - http.send(""); - http.setRequestHeader("Content-Length", 0); - if (http.status != 200) { /* request failed */ - failCount++; + url = (URLForFolderID(currentContactFolder) + "/" + + rows[i] + "/delete"); + http = createHTTPClient(); + http.open("POST", url, false /* not async */); + http.send(""); + http.setRequestHeader("Content-Length", 0); + if (http.status != 200) { /* request failed */ + failCount++; + http = null; + continue; + } http = null; - continue; - } - http = null; - /* remove from page */ + /* remove from page */ - /* line-through would be nicer, but hiding is OK too */ - rowElem = $(rows[i]); - rowElem.parentNode.removeChild(rowElem); - } + /* line-through would be nicer, but hiding is OK too */ + rowElem = $(rows[i]); + rowElem.parentNode.removeChild(rowElem); + } - if (failCount > 0) - alert(labels["You cannot delete the selected contact(s)."]); - else - contactView.update(); + if (failCount > 0) + alert(labels["You cannot delete the selected contact(s)."]); + else + contactView.update(); - return false; + return false; } function newEmailTo(sender) { - var mailto = sanitizeMailTo(sender.parentNode.parentNode.menuTarget.innerHTML); + var mailto = sanitizeMailTo(sender.parentNode.parentNode.menuTarget.innerHTML); - if (mailto.length > 0) - openMailComposeWindow("compose?mailto=" + mailto); + if (mailto.length > 0) + openMailComposeWindow("compose?mailto=" + mailto); - return false; /* stop following the link */ + return false; /* stop following the link */ } function onHeaderClick(event) { @@ -468,9 +468,9 @@ function onHeaderClick(event) { } function newContact(sender) { - openContactWindow(URLForFolderID(currentContactFolder) + "/newcontact"); + openContactWindow(URLForFolderID(currentContactFolder) + "/newcontact"); - return false; /* stop following the link */ + return false; /* stop following the link */ } function onFolderSelectionChange(event) { @@ -478,9 +478,9 @@ function onFolderSelectionChange(event) { var nodes = folderList.getSelectedNodes(); if (event) { - var node = getTarget(event); - if (node.tagName == 'UL') - return; + var node = getTarget(event); + if (node.tagName == 'UL') + return; } $("contactView").update(); @@ -499,7 +499,7 @@ function onFolderSelectionChange(event) { } function refreshCurrentFolder() { - openContactsFolder(currentContactFolder, true); + openContactsFolder(currentContactFolder, true); } function onConfirmContactSelection(event) { @@ -524,7 +524,7 @@ function onConfirmContactSelection(event) { var cname = '' + rows[i].getAttribute("contactname"); var email = '' + rows[i].cells[1].innerHTML; window.opener.addContact(tag, currentContactFolderName + '/' + cname, - cid, cname, email); + cid, cname, email); } if (selector && selector.changeNotification @@ -590,13 +590,13 @@ function appendAddressBook(name, folder) { } function newFolderCallback(http) { - if (http.readyState == 4 - && http.status == 201) { - var name = http.callbackData; - appendAddressBook(name, "/" + name); - } - else - log ("ajax problem 4:" + http.status); + if (http.readyState == 4 + && http.status == 201) { + var name = http.callbackData; + appendAddressBook(name, "/" + name); + } + else + log ("ajax problem 4:" + http.status); } function newUserFolderCallback(folderData) { @@ -620,89 +620,89 @@ function onFolderUnsubscribeCB(folderId) { } function onAddressBookRemove(event) { - var selector = $("contactFolders"); - var nodes = selector.getSelectedNodes(); - if (nodes.length > 0) { - nodes[0].deselect(); - var folderId = nodes[0].getAttribute("id"); - var folderIdElements = folderId.split("_"); - if (folderIdElements.length > 1) - unsubscribeFromFolder(folderId, onFolderUnsubscribeCB, folderId); - else { - var abId = folderIdElements[0].substr(1); - deletePersonalAddressBook(abId); - var personal = $("/personal"); - personal.selectElement(); - onFolderSelectionChange(); - } - } - - preventDefault(event); + var selector = $("contactFolders"); + var nodes = selector.getSelectedNodes(); + if (nodes.length > 0) { + nodes[0].deselect(); + var folderId = nodes[0].getAttribute("id"); + var folderIdElements = folderId.split("_"); + if (folderIdElements.length > 1) + unsubscribeFromFolder(folderId, onFolderUnsubscribeCB, folderId); + else { + var abId = folderIdElements[0].substr(1); + deletePersonalAddressBook(abId); + var personal = $("/personal"); + personal.selectElement(); + onFolderSelectionChange(); + } + } + + preventDefault(event); } function deletePersonalAddressBook(folderId) { - var label - = labels["Are you sure you want to delete the selected address book?"]; - if (window.confirm(label)) { - if (document.deletePersonalABAjaxRequest) { - document.deletePersonalABAjaxRequest.aborted = true; - document.deletePersonalABAjaxRequest.abort(); - } - var url = ApplicationBaseURL + "/" + folderId + "/deleteFolder"; - document.deletePersonalABAjaxRequest - = triggerAjaxRequest(url, deletePersonalAddressBookCallback, - folderId); - } + var label + = labels["Are you sure you want to delete the selected address book?"]; + if (window.confirm(label)) { + if (document.deletePersonalABAjaxRequest) { + document.deletePersonalABAjaxRequest.aborted = true; + document.deletePersonalABAjaxRequest.abort(); + } + var url = ApplicationBaseURL + "/" + folderId + "/deleteFolder"; + document.deletePersonalABAjaxRequest + = triggerAjaxRequest(url, deletePersonalAddressBookCallback, + folderId); + } } function deletePersonalAddressBookCallback(http) { - if (http.readyState == 4) { - if (isHttpStatus204(http.status)) { - var ul = $("contactFolders"); + if (http.readyState == 4) { + if (isHttpStatus204(http.status)) { + var ul = $("contactFolders"); - var children = ul.childNodesWithTag("li"); - var i = 0; - var done = false; - while (!done && i < children.length) { - var currentFolderId = children[i].getAttribute("id").substr(1); - if (currentFolderId == http.callbackData) { - ul.removeChild(children[i]); - done = true; - } - else - i++; + var children = ul.childNodesWithTag("li"); + var i = 0; + var done = false; + while (!done && i < children.length) { + var currentFolderId = children[i].getAttribute("id").substr(1); + if (currentFolderId == http.callbackData) { + ul.removeChild(children[i]); + done = true; + } + else + i++; + } } - } - document.deletePersonalABAjaxRequest = null; - } - else - log ("ajax problem 5: " + http.status); + document.deletePersonalABAjaxRequest = null; + } + else + log ("ajax problem 5: " + http.status); } function configureDragHandles() { - var handle = $("dragHandle"); - if (handle) { - handle.addInterface(SOGoDragHandlesInterface); - handle.leftBlock=$("contactFoldersList"); - handle.rightBlock=$("rightPanel"); - handle.leftMargin = 100; - } - - handle = $("rightDragHandle"); - if (handle) { - handle.addInterface(SOGoDragHandlesInterface); - handle.upperBlock=$("contactsListContent"); - handle.lowerBlock=$("contactView"); - } + var handle = $("dragHandle"); + if (handle) { + handle.addInterface(SOGoDragHandlesInterface); + handle.leftBlock=$("contactFoldersList"); + handle.rightBlock=$("rightPanel"); + handle.leftMargin = 100; + } + + handle = $("rightDragHandle"); + if (handle) { + handle.addInterface(SOGoDragHandlesInterface); + handle.upperBlock=$("contactsListContent"); + handle.lowerBlock=$("contactView"); + } } function lookupDeniedFolders() { - var list = $("contactFolders").childNodesWithTag("li"); - for (var i = 0; i < list.length; i++) { - var folderID = list[i].getAttribute("id"); - var url = URLForFolderID(folderID) + "/canAccessContent"; - triggerAjaxRequest(url, deniedFoldersLookupCallback, folderID); - } + var list = $("contactFolders").childNodesWithTag("li"); + for (var i = 0; i < list.length; i++) { + var folderID = list[i].getAttribute("id"); + var url = URLForFolderID(folderID) + "/canAccessContent"; + triggerAjaxRequest(url, deniedFoldersLookupCallback, folderID); + } } function deniedFoldersLookupCallback(http) { @@ -710,44 +710,44 @@ function deniedFoldersLookupCallback(http) { var denied = ! isHttpStatus204(http.status); var entry = $(http.callbackData); if (denied) - entry.addClassName("denied"); + entry.addClassName("denied"); else - entry.removeClassName("denied"); + entry.removeClassName("denied"); } } function configureAbToolbar() { - var toolbar = $("abToolbar"); - var links = toolbar.childNodesWithTag("a"); - Event.observe(links[0], "click", onAddressBookNew, false); - Event.observe(links[1], "click", onAddressBookAdd, false); - Event.observe(links[2], "click", onAddressBookRemove, false); + var toolbar = $("abToolbar"); + var links = toolbar.childNodesWithTag("a"); + Event.observe(links[0], "click", onAddressBookNew, false); + Event.observe(links[1], "click", onAddressBookAdd, false); + Event.observe(links[2], "click", onAddressBookRemove, false); } function configureContactFolders() { - var contactFolders = $("contactFolders"); - if (contactFolders) { - contactFolders.observe("mousedown", listRowMouseDownHandler); - contactFolders.observe("click", onFolderSelectionChange); - var lis = contactFolders.childNodesWithTag("li"); - for (var i = 0; i < lis.length; i++) - setEventsOnContactFolder(lis[i]); + var contactFolders = $("contactFolders"); + if (contactFolders) { + contactFolders.observe("mousedown", listRowMouseDownHandler); + contactFolders.observe("click", onFolderSelectionChange); + var lis = contactFolders.childNodesWithTag("li"); + for (var i = 0; i < lis.length; i++) + setEventsOnContactFolder(lis[i]); - lookupDeniedFolders(); + lookupDeniedFolders(); - var personalFolder = $("/personal"); - personalFolder.selectElement(); - openContactsFolder("/personal"); - } + var personalFolder = $("/personal"); + personalFolder.selectElement(); + openContactsFolder("/personal"); + } } function setEventsOnContactFolder(folder) { - var node = $(folder); + var node = $(folder); - node.observe("mousedown", listRowMouseDownHandler); - node.observe("click", onRowClick); - Event.observe(node, "contextmenu", - onContactFoldersContextMenu.bindAsEventListener(node)); + node.observe("mousedown", listRowMouseDownHandler); + node.observe("click", onRowClick); + Event.observe(node, "contextmenu", + onContactFoldersContextMenu.bindAsEventListener(node)); } function onMenuModify(event) { @@ -779,80 +779,80 @@ function folderRenameCallback(http) { } function onMenuSharing(event) { - if ($(this).hasClassName("disabled")) - return; + if ($(this).hasClassName("disabled")) + return; var folders = $("contactFolders"); var selected = folders.getSelectedNodes()[0]; var owner = selected.getAttribute("owner"); if (owner == "nobody") - window.alert(clabels["The user rights cannot be" - + " edited for this object!"]); + window.alert(clabels["The user rights cannot be" + + " edited for this object!"]); else { - var title = this.innerHTML; - var url = URLForFolderID(selected.getAttribute("id")); + var title = this.innerHTML; + var url = URLForFolderID(selected.getAttribute("id")); - openAclWindow(url + "/acls", title); + openAclWindow(url + "/acls", title); } } function onContactFoldersMenuPrepareVisibility() { - var folders = $("contactFolders"); - var selected = folders.getSelectedNodes(); - - if (selected.length > 0) { - var folderOwner = selected[0].getAttribute("owner"); - var modifyOption = $(this).down("ul").childElements().first(); - var sharingOption = $(this).down("ul").childElements().last(); - // Disable the "Sharing" and "Modify" options when address book - // is not owned by user - if (folderOwner == UserLogin || IsSuperUser) { - modifyOption.removeClassName("disabled"); - sharingOption.removeClassName("disabled"); - } - else { - modifyOption.addClassName("disabled"); - sharingOption.addClassName("disabled"); - } - } + var folders = $("contactFolders"); + var selected = folders.getSelectedNodes(); + + if (selected.length > 0) { + var folderOwner = selected[0].getAttribute("owner"); + var modifyOption = $(this).down("ul").childElements().first(); + var sharingOption = $(this).down("ul").childElements().last(); + // Disable the "Sharing" and "Modify" options when address book + // is not owned by user + if (folderOwner == UserLogin || IsSuperUser) { + modifyOption.removeClassName("disabled"); + sharingOption.removeClassName("disabled"); + } + else { + modifyOption.addClassName("disabled"); + sharingOption.addClassName("disabled"); + } + } } function onContactMenuPrepareVisibility() { - var contactId = document.menuTarget.getAttribute('id'); - var contactRow = $(contactId); - var elements = $(this).down("ul").childElements(); - - var writeOption = elements[2]; - var emailCell = contactRow.down('td', 1); - if (emailCell.firstChild) - writeOption.removeClassName("disabled"); - else - writeOption.addClassName("disabled"); + var contactId = document.menuTarget.getAttribute('id'); + var contactRow = $(contactId); + var elements = $(this).down("ul").childElements(); + + var writeOption = elements[2]; + var emailCell = contactRow.down('td', 1); + if (emailCell.firstChild) + writeOption.removeClassName("disabled"); + else + writeOption.addClassName("disabled"); - var aimOption = elements[3]; - var aimCell = contactRow.down('td', 2); - if (aimCell.firstChild) - aimOption.removeClassName("disabled"); - else - aimOption.addClassName("disabled"); + var aimOption = elements[3]; + var aimCell = contactRow.down('td', 2); + if (aimCell.firstChild) + aimOption.removeClassName("disabled"); + else + aimOption.addClassName("disabled"); } function getMenus() { var menus = {}; menus["contactFoldersMenu"] = new Array(onMenuModify, "-", null, - null, "-", null, "-", - onMenuSharing); + null, "-", null, "-", + onMenuSharing); menus["contactMenu"] = new Array(onMenuEditContact, "-", - onMenuWriteToContact, onMenuAIMContact, - "-", onMenuDeleteContact); + onMenuWriteToContact, onMenuAIMContact, + "-", onMenuDeleteContact); menus["searchMenu"] = new Array(setSearchCriteria); var contactFoldersMenu = $("contactFoldersMenu"); if (contactFoldersMenu) - contactFoldersMenu.prepareVisibility = onContactFoldersMenuPrepareVisibility; + contactFoldersMenu.prepareVisibility = onContactFoldersMenuPrepareVisibility; var contactMenu = $("contactMenu"); if (contactMenu) - contactMenu.prepareVisibility = onContactMenuPrepareVisibility; + contactMenu.prepareVisibility = onContactMenuPrepareVisibility; return menus; } @@ -862,29 +862,26 @@ function configureSelectionButtons() { if (container) { var buttons = container.childNodesWithTag("input"); for (var i = 0; i < buttons.length; i++) - Event.observe(buttons[i], "click", - onConfirmContactSelection.bindAsEventListener(buttons[i])); + Event.observe(buttons[i], "click", + onConfirmContactSelection.bindAsEventListener(buttons[i])); } } function initContacts(event) { - if (!document.body.hasClassName("popup")) { - configureAbToolbar(); - } - else - configureSelectionButtons(); - + if (document.body.hasClassName("popup")) + configureSelectionButtons(); + configureAbToolbar(); configureContactFolders(); -// initDnd(); + // initDnd(); var table = $("contactsList"); if (table) { - // Initialize contacts table - table.multiselect = true; - Event.observe(table, "mousedown", - onContactSelectionChange.bindAsEventListener(table)); - configureSortableTableHeaders(table); - TableKit.Resizable.init(table, {'trueResize' : true, 'keepWidth' : true}); + // Initialize contacts table + table.multiselect = true; + Event.observe(table, "mousedown", + onContactSelectionChange.bindAsEventListener(table)); + configureSortableTableHeaders(table); + TableKit.Resizable.init(table, {'trueResize' : true, 'keepWidth' : true}); } // Default sort options diff --git a/UI/WebServerResources/SchedulerUI.js b/UI/WebServerResources/SchedulerUI.js index 305bd123..ea68fdf8 100644 --- a/UI/WebServerResources/SchedulerUI.js +++ b/UI/WebServerResources/SchedulerUI.js @@ -703,9 +703,134 @@ function refreshCalendarEventsCallback(http) { // log("refresh calendar events: " + data.length); var dateTuples = new Array(); for (var i = 0; i < data.length; i++) { - drawCalendarEvent(data[i], - http.callbackData["startDate"], - http.callbackData["endDate"]); + var dates = drawCalendarEvent(data[i], + http.callbackData["startDate"], + http.callbackData["endDate"]); + dates.each(function(tuple) { + if (tuple[3] == 0) tuple[3] = 96; + dateTuples.push(tuple); + }); + } + + var c = { + div: 0, + day: 1, + start: 2, + end: 3, + siblingsCount: 4, + siblingsPosition: 5, + siblingsMaxCount: 6 + }; + for (var i = 0; i < dateTuples.length; i++) { + if (dateTuples[i].length < 6) { + dateTuples[i][c.siblingsCount] = 1; + dateTuples[i][c.siblingsPosition] = 0; + } + for (var j = 0; j < dateTuples.length; j++) { + if (j == i) continue; + if (dateTuples[i][c.day] == dateTuples[j][c.day]) { + // Same day + if (dateTuples[j][c.start] > dateTuples[i][c.start] && + dateTuples[j][c.start] < dateTuples[i][c.end] || + + dateTuples[j][c.start] == dateTuples[i][c.start] && + dateTuples[j][c.end] < dateTuples[i][c.end] || + + dateTuples[j][c.start] == dateTuples[i][c.start] && + dateTuples[j][c.end] == dateTuples[i][c.end] && + i < j) { + // Same period + if (dateTuples[j].length < 6) { + dateTuples[j][c.siblingsCount] = 2; + dateTuples[j][c.siblingsPosition] = dateTuples[i][c.siblingsPosition] + 1; + } + else { + dateTuples[j][c.siblingsCount]++; + dateTuples[j][c.siblingsPosition]++; + } + dateTuples[i][c.siblingsCount]++; + } + } + } + } + + // Second loop; adjust total number of siblings for each event + for (var i = 0; i < dateTuples.length; i++) { + //log (i + " " + dateTuples[i].inspect()); + var maxCount = 0; + for (var j = 0; j < dateTuples.length; j++) { + if (j == i) continue; + if (dateTuples[i][c.day] == dateTuples[j][c.day]) { + // Same day + if (dateTuples[j][c.start] > dateTuples[i][c.start] && + dateTuples[j][c.start] < dateTuples[i][c.end] || + + dateTuples[j][c.start] == dateTuples[i][c.start] && + dateTuples[j][c.end] < dateTuples[i][c.end] ){ + // Same period + if (dateTuples[j][c.siblingsCount] > maxCount) + maxCount = dateTuples[j][c.siblingsCount]; + } + } + } + if (maxCount > 0) { + dateTuples[i][c.siblingsCount] = maxCount; + dateTuples[i][c.siblingsMaxCount] = maxCount; + } + } + + // Third loop; adjust position and total number of siblings for each event + for (var i = 0; i < dateTuples.length; i++) { + //log (i + " " + dateTuples[i].inspect()); + for (var j = 0; j < dateTuples.length; j++) { + if (j == i) continue; + if (dateTuples[i][c.day] == dateTuples[j][c.day]) { + // Same day + if (dateTuples[j][c.start] > dateTuples[i][c.start] && + dateTuples[j][c.start] < dateTuples[i][c.end] || + + dateTuples[j][c.start] == dateTuples[i][c.start] && + dateTuples[j][c.end] < dateTuples[i][c.end] || + + dateTuples[j][c.start] == dateTuples[i][c.start] && + dateTuples[j][c.end] == dateTuples[i][c.end] && + i < j) { + // Overlapping period + if (dateTuples[j][c.siblingsPosition] == dateTuples[i][c.siblingsPosition]) { + // Same position + dateTuples[j][c.siblingsPosition]--; // not very clever + } + if (dateTuples[j].length < 7 || + dateTuples[j][c.siblingsMaxCount] < dateTuples[i][c.siblingsMaxCount]) + dateTuples[j][c.siblingsMaxCount] = dateTuples[i][c.siblingsMaxCount]; + } + } + } + if (dateTuples[i].length < 7) + dateTuples[i][c.siblingsMaxCount] = dateTuples[i][c.siblingsCount]; + } + + // Final loop; draw the events + //log ("[div, day, start index, end index, siblings count, siblings position, siblings max count]"); + for (var i = 0; i < dateTuples.length; i++) { + //log (i + " " + dateTuples[i].inspect()); + + var base = dateTuples[i][c.siblingsCount] * dateTuples[i][c.siblingsMaxCount]; + var length = 1; + var maxLength = 1 * dateTuples[i][c.siblingsMaxCount]; + + for (var j = dateTuples[i][c.siblingsCount]; + j < maxLength; + j += dateTuples[i][c.siblingsCount]) { } + + if (j > maxLength) { + j -= dateTuples[i][c.siblingsCount]; + } + + var width = 100 * j / base; + var left = width * dateTuples[i][c.siblingsPosition]; + dateTuples[i][0].setStyle({ width: width + "%", + left: left + "%" }); } } scrollDayView(http.callbackData["scrollEvent"]); @@ -715,6 +840,8 @@ function refreshCalendarEventsCallback(http) { } function drawCalendarEvent(eventData, sd, ed) { + var dateTuples = new Array(); + var viewStartDate = sd.asDate(); var viewEndDate = ed.asDate(); @@ -744,7 +871,7 @@ function drawCalendarEvent(eventData, sd, ed) { if (days[i].earlierDate(viewStartDate) == viewStartDate && days[i].laterDate(viewEndDate) == viewEndDate) { var starts; - + // log("day: " + days[i]); if (i == 0) { var quarters = (startDate.getUTCHours() * 4 @@ -775,6 +902,10 @@ function drawCalendarEvent(eventData, sd, ed) { eventDiv.siblings = siblings; if (eventData[9].length > 0) eventDiv.addClassName(eventData[9]); // event owner status + //eventDiv.setStyle({ width: '50%' }); + if (currentView != "monthview" && + eventData[7] == 0) // not "all day" + dateTuples.push(new Array(eventDiv, days[i].getDayString(), starts, ends)); var dayString = days[i].getDayString(); // log("day: " + dayString); var parentDiv = null; @@ -817,6 +948,8 @@ function drawCalendarEvent(eventData, sd, ed) { if (parentDiv) parentDiv.appendChild(eventDiv); } + + return dateTuples; } function eventClass(cname) { @@ -929,7 +1062,7 @@ function calendarDisplayCallback(http) { function assignCalendar(name) { if (typeof(skycalendar) != "undefined") { var node = $(name); - + node.calendar = new skycalendar(node); node.calendar.setCalendarPage(ResourcesURL + "/skycalendar.html"); var dateFormat = node.getAttribute("dateFormat"); @@ -939,11 +1072,11 @@ function assignCalendar(name) { } function popupCalendar(node) { - var nodeId = $(node).readAttribute("inputId"); - var input = $(nodeId); - input.calendar.popup(); + var nodeId = $(node).readAttribute("inputId"); + var input = $(nodeId); + input.calendar.popup(); - return false; + return false; } function onEventContextMenu(event) { diff --git a/UI/WebServerResources/UIxAppointmentEditor.js b/UI/WebServerResources/UIxAppointmentEditor.js index c444e8b3..815f93a7 100644 --- a/UI/WebServerResources/UIxAppointmentEditor.js +++ b/UI/WebServerResources/UIxAppointmentEditor.js @@ -88,8 +88,8 @@ function validateAptEditor() { start = parseInt(document.forms[0]['startTime_time_minute'].value); end = parseInt(document.forms[0]['endTime_time_minute'].value); if (start > end) { - alert(labels.validate_endbeforestart); - return false; + alert(labels.validate_endbeforestart); + return false; } } } @@ -406,17 +406,17 @@ function getMenus() { } function onAppointmentEditorLoad() { - assignCalendar('startTime_date'); - assignCalendar('endTime_date'); - - var widgets = {'start': {'date': $("startTime_date"), - 'hour': $("startTime_time_hour"), - 'minute': $("startTime_time_minute")}, - 'end': {'date': $("endTime_date"), - 'hour': $("endTime_time_hour"), - 'minute': $("endTime_time_minute")}}; - initTimeWidgets(widgets); - initializeAttendeesHref(); + assignCalendar('startTime_date'); + assignCalendar('endTime_date'); + + var widgets = {'start': {'date': $("startTime_date"), + 'hour': $("startTime_time_hour"), + 'minute': $("startTime_time_minute")}, + 'end': {'date': $("endTime_date"), + 'hour': $("endTime_time_hour"), + 'minute': $("endTime_time_minute")}}; + initTimeWidgets(widgets); + initializeAttendeesHref(); } FastInit.addOnLoad(onAppointmentEditorLoad); diff --git a/UI/WebServerResources/UIxAttendeesEditor.css b/UI/WebServerResources/UIxAttendeesEditor.css index 28f3bdce..46c0fc6c 100644 --- a/UI/WebServerResources/UIxAttendeesEditor.css +++ b/UI/WebServerResources/UIxAttendeesEditor.css @@ -118,7 +118,8 @@ TABLE#freeBusyAttendees TD.attendees INPUT margin-left: 2em; } TABLE#freeBusyAttendees TR.futureAttendee INPUT -{ background-image: none; } +{ background-image: none; + color: #aaa; } SPAN.freeBusyZoneElement { display: block; diff --git a/UI/WebServerResources/UIxAttendeesEditor.js b/UI/WebServerResources/UIxAttendeesEditor.js index 655ecfff..9081c2fb 100644 --- a/UI/WebServerResources/UIxAttendeesEditor.js +++ b/UI/WebServerResources/UIxAttendeesEditor.js @@ -60,20 +60,20 @@ function onContactKeydown(event) { } function performSearch() { - if (currentField) { - if (document.contactLookupAjaxRequest) { - // Abort any pending request - document.contactLookupAjaxRequest.aborted = true; - document.contactLookupAjaxRequest.abort(); - } - if (currentField.value.trim().length > 0) { - var urlstr = ( UserFolderURL + "Contacts/contactSearch?search=" - + escape(currentField.value) ); log (urlstr); - document.contactLookupAjaxRequest = - triggerAjaxRequest(urlstr, performSearchCallback, currentField); - } - } - delayedSearch = false; + if (currentField) { + if (document.contactLookupAjaxRequest) { + // Abort any pending request + document.contactLookupAjaxRequest.aborted = true; + document.contactLookupAjaxRequest.abort(); + } + if (currentField.value.trim().length > 0) { + var urlstr = ( UserFolderURL + "Contacts/contactSearch?search=" + + escape(currentField.value) ); + document.contactLookupAjaxRequest = + triggerAjaxRequest(urlstr, performSearchCallback, currentField); + } + } + delayedSearch = false; } function performSearchCallback(http) { @@ -465,14 +465,17 @@ function synchronizeWithParent(srcWidgetName, dstWidgetName) { var srcDate = parent$(srcWidgetName + "_date"); var dstDate = $(dstWidgetName + "_date"); dstDate.value = srcDate.value; + dstDate.updateShadowValue(srcDate); var srcHour = parent$(srcWidgetName + "_time_hour"); var dstHour = $(dstWidgetName + "_time_hour"); dstHour.value = srcHour.value; + dstHour.updateShadowValue(srcHour); var srcMinute = parent$(srcWidgetName + "_time_minute"); var dstMinute = $(dstWidgetName + "_time_minute"); dstMinute.value = srcMinute.value; + dstMinute.updateShadowValue(dstMinute); } function updateParentDateFields(srcWidgetName, dstWidgetName) { @@ -489,44 +492,31 @@ function updateParentDateFields(srcWidgetName, dstWidgetName) { dstMinute.value = srcMinute.value; } -function initializeTimeWidgets() { - synchronizeWithParent("startTime", "startTime"); - synchronizeWithParent("endTime", "endTime"); - - Event.observe($("startTime_date"), "change", onTimeDateWidgetChange, false); - Event.observe($("startTime_time_hour"), "change", onTimeWidgetChange, false); - Event.observe($("startTime_time_minute"), "change", onTimeWidgetChange, false); - - Event.observe($("endTime_date"), "change", onTimeDateWidgetChange, false); - Event.observe($("endTime_time_hour"), "change", onTimeWidgetChange, false); - Event.observe($("endTime_time_minute"), "change", onTimeWidgetChange, false); -} - function onTimeWidgetChange() { redisplayFreeBusyZone(); } -function onTimeDateWidgetChange(event) { - var table = $("freeBusy"); - - var rows = table.tHead.rows; - for (var i = 0; i < rows.length; i++) { - for (var j = rows[i].cells.length - 1; j > 0; j--) { - rows[i].deleteCell(j); - } - } - - rows = table.tBodies[0].rows; - for (var i = 0; i < rows.length; i++) { - for (var j = rows[i].cells.length - 1; j > 0; j--) { - rows[i].deleteCell(j); - } - } +function onTimeDateWidgetChange() { + var table = $("freeBusyHeader"); + var rows = table.select("tr"); + for (var i = 0; i < rows.length; i++) { + for (var j = rows[i].cells.length - 1; j > -1; j--) { + rows[i].deleteCell(j); + } + } + + table = $("freeBusyData"); + rows = table.select("tr"); + for (var i = 0; i < rows.length; i++) { + for (var j = rows[i].cells.length - 1; j > -1; j--) { + rows[i].deleteCell(j); + } + } - prepareTableHeaders(); - prepareTableRows(); - redisplayFreeBusyZone(); - resetAllFreeBusys(); + prepareTableHeaders(); + prepareTableRows(); + redisplayFreeBusyZone(); + resetAllFreeBusys(); } function prepareTableHeaders() { @@ -545,20 +535,20 @@ function prepareTableHeaders() { header1.appendChild(document.createTextNode(days[i].toLocaleDateString())); rows[0].appendChild(header1); for (var hour = dayStartHour; hour < (dayEndHour + 1); hour++) { - var header2 = document.createElement("th"); - var text = hour + ":00"; - if (hour < 10) - text = "0" + text; - header2.appendChild(document.createTextNode(text)); - rows[1].appendChild(header2); - - var header3 = document.createElement("th"); - for (var span = 0; span < 4; span++) { - var spanElement = document.createElement("span"); - $(spanElement).addClassName("freeBusyZoneElement"); - header3.appendChild(spanElement); - } - rows[2].appendChild(header3); + var header2 = document.createElement("th"); + var text = hour + ":00"; + if (hour < 10) + text = "0" + text; + header2.appendChild(document.createTextNode(text)); + rows[1].appendChild(header2); + + var header3 = document.createElement("th"); + for (var span = 0; span < 4; span++) { + var spanElement = document.createElement("span"); + $(spanElement).addClassName("freeBusyZoneElement"); + header3.appendChild(spanElement); + } + rows[2].appendChild(header3); } } } @@ -600,36 +590,36 @@ function prepareAttendees() { var newDataRow = tbodyData.rows[tbodyData.rows.length - 2]; for (var i = 0; i < attendeesEditor.names.length; i++) { - var row = modelAttendee.cloneNode(true); - tbodyAttendees.insertBefore(row, newAttendeeRow); - $(row).removeClassName("attendeeModel"); - $(row).addClassName(attendeesEditor.states[i]); - var input = $(row).down("input"); - var value = ""; - if (attendeesEditor.names[i].length > 0 - && attendeesEditor.names[i] != attendeesEditor.emails[i]) - value += attendeesEditor.names[i] + " "; - value += "<" + attendeesEditor.emails[i] + ">"; - input.value = value; - if (attendeesEditor.UIDs[i].length > 0) - input.uid = attendeesEditor.UIDs[i]; - input.setAttribute("name", ""); - input.setAttribute("modified", "0"); - input.observe("blur", checkAttendee); - input.observe("keydown", onContactKeydown); + var row = modelAttendee.cloneNode(true); + tbodyAttendees.insertBefore(row, newAttendeeRow); + $(row).removeClassName("attendeeModel"); + $(row).addClassName(attendeesEditor.states[i]); + var input = $(row).down("input"); + var value = ""; + if (attendeesEditor.names[i].length > 0 + && attendeesEditor.names[i] != attendeesEditor.emails[i]) + value += attendeesEditor.names[i] + " "; + value += "<" + attendeesEditor.emails[i] + ">"; + input.value = value; + if (attendeesEditor.UIDs[i].length > 0) + input.uid = attendeesEditor.UIDs[i]; + input.setAttribute("name", ""); + input.setAttribute("modified", "0"); + input.observe("blur", checkAttendee); + input.observe("keydown", onContactKeydown); - row = modelData.cloneNode(true); - tbodyData.insertBefore(row, newDataRow); - $(row).removeClassName("dataModel"); + row = modelData.cloneNode(true); + tbodyData.insertBefore(row, newDataRow); + $(row).removeClassName("dataModel"); - displayFreeBusyForNode(input); + displayFreeBusyForNode(input); } } else { attendeesEditor.names = new Array(); attendeesEditor.UIDs = new Array(); attendeesEditor.emails = new Array(); - newAttendee(null); + //newAttendee(null); } var inputs = tableAttendees.getElementsByTagName("input"); @@ -638,18 +628,18 @@ function prepareAttendees() { } function onWindowResize(event) { - var view = $('freeBusyView'); - var attendeesCell = $$('TABLE#freeBusy TD.freeBusyAttendees').first(); - var headerDiv = $$('TABLE#freeBusy TD.freeBusyHeader DIV').first(); - var attendeesDiv = $$('TABLE#freeBusy TD.freeBusyAttendees DIV').first(); - var dataDiv = $$('TABLE#freeBusy TD.freeBusyData DIV').first(); - var width = view.getWidth() - attendeesCell.getWidth(); - var height = view.getHeight() - headerDiv.getHeight(); + var view = $('freeBusyView'); + var attendeesCell = $$('TABLE#freeBusy TD.freeBusyAttendees').first(); + var headerDiv = $$('TABLE#freeBusy TD.freeBusyHeader DIV').first(); + var attendeesDiv = $$('TABLE#freeBusy TD.freeBusyAttendees DIV').first(); + var dataDiv = $$('TABLE#freeBusy TD.freeBusyData DIV').first(); + var width = view.getWidth() - attendeesCell.getWidth(); + var height = view.getHeight() - headerDiv.getHeight(); - attendeesDiv.setStyle({ height: (height - 20) + 'px' }); - headerDiv.setStyle({ width: (width - 20) + 'px' }); - dataDiv.setStyle({ width: (width - 4) + 'px', - height: (height - 2) + 'px' }); + attendeesDiv.setStyle({ height: (height - 20) + 'px' }); + headerDiv.setStyle({ width: (width - 20) + 'px' }); + dataDiv.setStyle({ width: (width - 4) + 'px', + height: (height - 2) + 'px' }); } function onScroll(event) { @@ -662,8 +652,18 @@ function onScroll(event) { } function onFreeBusyLoadHandler() { + var widgets = {'start': {'date': $("startTime_date"), + 'hour': $("startTime_time_hour"), + 'minute': $("startTime_time_minute")}, + 'end': {'date': $("endTime_date"), + 'hour': $("endTime_time_hour"), + 'minute': $("endTime_time_minute")}}; + + synchronizeWithParent("startTime", "startTime"); + synchronizeWithParent("endTime", "endTime"); + + initTimeWidgets(widgets); initializeWindowButtons(); - initializeTimeWidgets(); prepareTableHeaders(); prepareTableRows(); redisplayFreeBusyZone(); @@ -674,3 +674,123 @@ function onFreeBusyLoadHandler() { } FastInit.addOnLoad(onFreeBusyLoadHandler); + +/* Functions related to UIxTimeDateControl widget */ + +function initTimeWidgets(widgets) { + this.timeWidgets = widgets; + + assignCalendar('startTime_date'); + assignCalendar('endTime_date'); + + Event.observe(widgets['start']['date'], "change", + this.onAdjustTime, false); + Event.observe(widgets['start']['hour'], "change", + this.onAdjustTime, false); + Event.observe(widgets['start']['minute'], "change", + this.onAdjustTime, false); + + Event.observe(widgets['end']['date'], "change", + this.onAdjustTime, false); + Event.observe(widgets['end']['hour'], "change", + this.onAdjustTime, false); + Event.observe(widgets['end']['minute'], "change", + this.onAdjustTime, false); + + var allDayLabel = $("allDay"); + if (allDayLabel) { + var input = $(allDayLabel).childNodesWithTag("input")[0]; + Event.observe(input, "change", onAllDayChanged.bindAsEventListener(input)); + if (input.checked) { + for (var type in widgets) { + widgets[type]['hour'].disabled = true; + widgets[type]['minute'].disabled = true; + } + } + } +} + +function onAdjustTime(event) { + var endDate = window.getEndDate(); + var startDate = window.getStartDate(); + if ($(this).readAttribute("id").startsWith("start")) { + // Start date was changed + var delta = window.getShadowStartDate().valueOf() - + startDate.valueOf(); + var newEndDate = new Date(endDate.valueOf() - delta); + window.setEndDate(newEndDate); + window.timeWidgets['end']['date'].updateShadowValue(); + window.timeWidgets['end']['hour'].updateShadowValue(); + window.timeWidgets['end']['minute'].updateShadowValue(); + window.timeWidgets['start']['date'].updateShadowValue(); + window.timeWidgets['start']['hour'].updateShadowValue(); + window.timeWidgets['start']['minute'].updateShadowValue(); + } + else { + // End date was changed + var delta = endDate.valueOf() - startDate.valueOf(); + if (delta < 0) { + alert(labels.validate_endbeforestart); + var oldEndDate = window.getShadowEndDate(); + window.setEndDate(oldEndDate); + + window.timeWidgets['end']['date'].updateShadowValue(); + window.timeWidgets['end']['hour'].updateShadowValue(); + window.timeWidgets['end']['minute'].updateShadowValue(); + } + } + + // Specific function for the attendees editor + onTimeDateWidgetChange(); +} + +function _getDate(which) { + var date = window.timeWidgets[which]['date'].valueAsDate(); + date.setHours( window.timeWidgets[which]['hour'].value ); + date.setMinutes( window.timeWidgets[which]['minute'].value ); + + return date; +} + +function getStartDate() { + return this._getDate('start'); +} + +function getEndDate() { + return this._getDate('end'); +} + +function _getShadowDate(which) { + var date = window.timeWidgets[which]['date'].getAttribute("shadow-value").asDate(); + var intValue = parseInt(window.timeWidgets[which]['hour'].getAttribute("shadow-value")); + date.setHours(intValue); + intValue = parseInt(window.timeWidgets[which]['minute'].getAttribute("shadow-value")); + date.setMinutes(intValue); + + return date; +} + +function getShadowStartDate() { + return this._getShadowDate('start'); +} + +function getShadowEndDate() { + return this._getShadowDate('end'); +} + +function _setDate(which, newDate) { + window.timeWidgets[which]['date'].setValueAsDate(newDate); + window.timeWidgets[which]['hour'].value = newDate.getHours(); + var minutes = newDate.getMinutes(); + if (minutes % 15) + minutes += (15 - minutes % 15); + window.timeWidgets[which]['minute'].value = minutes; +} + +function setStartDate(newStartDate) { + this._setDate('start', newStartDate); +} + +function setEndDate(newEndDate) { + this._setDate('end', newEndDate); +} diff --git a/UI/WebServerResources/UIxComponentEditor.js b/UI/WebServerResources/UIxComponentEditor.js index d44b1b89..dbd8c219 100644 --- a/UI/WebServerResources/UIxComponentEditor.js +++ b/UI/WebServerResources/UIxComponentEditor.js @@ -115,15 +115,15 @@ function onComponentEditorLoad(event) { initializePrivacyMenu(); var list = $("calendarList"); Event.observe(list, "mousedown", - onChangeCalendar.bindAsEventListener(list), - false); + onChangeCalendar.bindAsEventListener(list), + false); list.fire("mousedown"); var menuItems = $("itemPrivacyList").childNodesWithTag("li"); for (var i = 0; i < menuItems.length; i++) - Event.observe(menuItems[i], "mousedown", - onMenuSetClassification.bindAsEventListener(menuItems[i]), - false); + Event.observe(menuItems[i], "mousedown", + onMenuSetClassification.bindAsEventListener(menuItems[i]), + false); $("repeatHref").observe("click", onPopupRecurrenceWindow); $("repeatList").observe("change", onPopupRecurrenceWindow); diff --git a/UI/WebServerResources/UIxTaskEditor.js b/UI/WebServerResources/UIxTaskEditor.js index c49cc718..e56d28f2 100644 --- a/UI/WebServerResources/UIxTaskEditor.js +++ b/UI/WebServerResources/UIxTaskEditor.js @@ -180,109 +180,113 @@ function dueDayAsShortString() { } this._getDate = function(which) { - var date = window.timeWidgets[which]['date'].valueAsDate(); - date.setHours( window.timeWidgets[which]['hour'].value ); - date.setMinutes( window.timeWidgets[which]['minute'].value ); - - return date; -} - - this._getShadowDate = function(which) { - var date = window.timeWidgets[which]['date'].getAttribute("shadow-value").asDate(); - var intValue = parseInt(window.timeWidgets[which]['hour'].getAttribute("shadow-value")); - date.setHours(intValue); - intValue = parseInt(window.timeWidgets[which]['minute'].getAttribute("shadow-value")); - date.setMinutes(intValue); - // window.alert("shadow: " + date); - - return date; - } - - this.getStartDate = function() { - return this._getDate('start'); - } - - this.getDueDate = function() { - return this._getDate('due'); - } - - this.getShadowStartDate = function() { - return this._getShadowDate('start'); - } - - this.getShadowDueDate = function() { - return this._getShadowDate('due'); - } - - this._setDate = function(which, newDate) { - window.timeWidgets[which]['date'].setValueAsDate(newDate); - window.timeWidgets[which]['hour'].value = newDate.getHours(); - var minutes = newDate.getMinutes(); - if (minutes % 15) + var date = window.timeWidgets[which]['date'].valueAsDate(); + date.setHours( window.timeWidgets[which]['hour'].value ); + date.setMinutes( window.timeWidgets[which]['minute'].value ); + + return date; +}; + +this._getShadowDate = function(which) { + var date = window.timeWidgets[which]['date'].getAttribute("shadow-value").asDate(); + var intValue = parseInt(window.timeWidgets[which]['hour'].getAttribute("shadow-value")); + date.setHours(intValue); + intValue = parseInt(window.timeWidgets[which]['minute'].getAttribute("shadow-value")); + date.setMinutes(intValue); + // window.alert("shadow: " + date); + + return date; +}; + +this.getStartDate = function() { + return this._getDate('start'); +}; + +this.getDueDate = function() { + return this._getDate('due'); +}; + +this.getShadowStartDate = function() { + return this._getShadowDate('start'); +}; + +this.getShadowDueDate = function() { + return this._getShadowDate('due'); +}; + +this._setDate = function(which, newDate) { + window.timeWidgets[which]['date'].setValueAsDate(newDate); + window.timeWidgets[which]['hour'].value = newDate.getHours(); + var minutes = newDate.getMinutes(); + if (minutes % 15) minutes += (15 - minutes % 15); - window.timeWidgets[which]['minute'].value = minutes; - } - - this.setStartDate = function(newStartDate) { - this._setDate('start', newStartDate); - } - - this.setDueDate = function(newDueDate) { - // window.alert(newDueDate); - this._setDate('due', newDueDate); - } - - this.onAdjustDueTime = function(event) { - if (!window.timeWidgets['due']['date'].disabled) { - var dateDelta = (window.getStartDate().valueOf() - - window.getShadowStartDate().valueOf()); - var newDueDate = new Date(window.getDueDate().valueOf() + dateDelta); - window.setDueDate(newDueDate); - } - window.timeWidgets['start']['date'].updateShadowValue(); - window.timeWidgets['start']['hour'].updateShadowValue(); - window.timeWidgets['start']['minute'].updateShadowValue(); - } - - this.initTimeWidgets = function (widgets) { - this.timeWidgets = widgets; - - Event.observe(widgets['start']['date'], "change", this.onAdjustDueTime, false); - Event.observe(widgets['start']['hour'], "change", this.onAdjustDueTime, false); - Event.observe(widgets['start']['minute'], "change", this.onAdjustDueTime, false); - } - - function onStatusListChange(event) { - var value = $("statusList").value; - var statusTimeDate = $("statusTime_date"); - var statusPercent = $("statusPercent"); - - if (value == "WONoSelectionString") { - statusTimeDate.disabled = true; - statusPercent.disabled = true; - statusPercent.value = ""; - } - else if (value == "0") { - statusTimeDate.disabled = true; - statusPercent.disabled = false; - } - else if (value == "1") { - statusTimeDate.disabled = true; - statusPercent.disabled = false; - } - else if (value == "2") { - statusTimeDate.disabled = false; - statusPercent.disabled = false; - statusPercent.value = "100"; - } - else if (value == "3") { - statusTimeDate.disabled = true; - statusPercent.disabled = true; - } - else { - statusTimeDate.disabled = true; - } - } + window.timeWidgets[which]['minute'].value = minutes; +}; + +this.setStartDate = function(newStartDate) { + this._setDate('start', newStartDate); +}; + +this.setDueDate = function(newDueDate) { + // window.alert(newDueDate); + this._setDate('due', newDueDate); +}; + +this.onAdjustTime = function(event) { + onAdjustDueTime(event); +}; + +this.onAdjustDueTime = function(event) { + if (!window.timeWidgets['due']['date'].disabled) { + var dateDelta = (window.getStartDate().valueOf() + - window.getShadowStartDate().valueOf()); + var newDueDate = new Date(window.getDueDate().valueOf() + dateDelta); + window.setDueDate(newDueDate); + } + window.timeWidgets['start']['date'].updateShadowValue(); + window.timeWidgets['start']['hour'].updateShadowValue(); + window.timeWidgets['start']['minute'].updateShadowValue(); +}; + +this.initTimeWidgets = function (widgets) { + this.timeWidgets = widgets; + + Event.observe(widgets['start']['date'], "change", this.onAdjustDueTime, false); + Event.observe(widgets['start']['hour'], "change", this.onAdjustDueTime, false); + Event.observe(widgets['start']['minute'], "change", this.onAdjustDueTime, false); +}; + +function onStatusListChange(event) { + var value = $("statusList").value; + var statusTimeDate = $("statusTime_date"); + var statusPercent = $("statusPercent"); + + if (value == "WONoSelectionString") { + statusTimeDate.disabled = true; + statusPercent.disabled = true; + statusPercent.value = ""; + } + else if (value == "0") { + statusTimeDate.disabled = true; + statusPercent.disabled = false; + } + else if (value == "1") { + statusTimeDate.disabled = true; + statusPercent.disabled = false; + } + else if (value == "2") { + statusTimeDate.disabled = false; + statusPercent.disabled = false; + statusPercent.value = "100"; + } + else if (value == "3") { + statusTimeDate.disabled = true; + statusPercent.disabled = true; + } + else { + statusTimeDate.disabled = true; + } +} function initializeStatusLine() { var statusList = $("statusList"); @@ -290,10 +294,18 @@ function initializeStatusLine() { } function onTaskEditorLoad() { - assignCalendar('startTime_date'); - assignCalendar('dueTime_date'); - assignCalendar('statusTime_date'); - + assignCalendar('startTime_date'); + assignCalendar('dueTime_date'); + assignCalendar('statusTime_date'); + + var widgets = {'start': {'date': $("startTime_date"), + 'hour': $("startTime_time_hour"), + 'minute': $("startTime_time_minute")}, + 'due': {'date': $("dueTime_date"), + 'hour': $("dueTime_time_hour"), + 'minute': $("dueTime_time_minute")}}; + initTimeWidgets(widgets); + initializeStatusLine(); } -- 2.39.5