From 07445eb06965aee2279db2de61eba0a9fa4aa197 Mon Sep 17 00:00:00 2001 From: Alexandre Cloutier Date: Thu, 15 May 2014 14:44:31 -0400 Subject: [PATCH] Created a window for address book properties and add the cardDav URL --- UI/Contacts/English.lproj/Localizable.strings | 12 +- UI/Contacts/GNUmakefile | 5 +- UI/Contacts/UIxContactFolderProperties.h | 35 +++ UI/Contacts/UIxContactFolderProperties.m | 93 +++++++ UI/Contacts/product.plist | 4 + .../English.lproj/Localizable.strings | 2 +- .../ContactsUI/UIxContactFolderProperties.wox | 63 +++++ .../SchedulerUI/UIxCalendarProperties.wox | 226 +++++++++--------- UI/WebServerResources/ContactsUI.js | 50 ++-- .../UIxCalendarProperties.js | 14 ++ .../UIxContactFolderProperties.css | 40 ++++ .../UIxContactFolderProperties.js | 71 ++++++ 12 files changed, 468 insertions(+), 147 deletions(-) create mode 100644 UI/Contacts/UIxContactFolderProperties.h create mode 100644 UI/Contacts/UIxContactFolderProperties.m create mode 100644 UI/Templates/ContactsUI/UIxContactFolderProperties.wox create mode 100644 UI/WebServerResources/UIxContactFolderProperties.css create mode 100644 UI/WebServerResources/UIxContactFolderProperties.js diff --git a/UI/Contacts/English.lproj/Localizable.strings b/UI/Contacts/English.lproj/Localizable.strings index 745b31e2f..c05e0746f 100644 --- a/UI/Contacts/English.lproj/Localizable.strings +++ b/UI/Contacts/English.lproj/Localizable.strings @@ -146,7 +146,7 @@ "You cannot delete the card of \"%{0}\"." = "You cannot delete the card of \"%{0}\"."; -"Address Book Name" = "Address Book Name"; + "You cannot subscribe to a folder that you own!" = "You cannot subscribe to a folder that you own."; @@ -205,3 +205,13 @@ "A total of %{0} cards were imported in the addressbook." = "A total of %{0} cards were imported in the addressbook."; "Reload" = "Reload"; + +/* Properties window */ +"Address Book Name:" = "Address Book Name:"; +"Public Access" = "Public Access"; +"Links to this Address Book" = "Links to this Address Book"; +"Authenticated User Access" = "Authenticated User Access"; +"CardDAV URL: " = "CardDAV URL: "; +"OK" = "OK"; +"Cancel" = "Cancel"; + diff --git a/UI/Contacts/GNUmakefile b/UI/Contacts/GNUmakefile index b29b0373d..7158670d1 100644 --- a/UI/Contacts/GNUmakefile +++ b/UI/Contacts/GNUmakefile @@ -22,8 +22,9 @@ ContactsUI_OBJC_FILES = \ UIxListEditor.m \ UIxContactsListActions.m \ UIxContactFoldersView.m \ - UIxContactFolderActions.m - + UIxContactFolderActions.m \ + UIxContactFolderProperties.m + ContactsUI_RESOURCE_FILES += \ product.plist \ diff --git a/UI/Contacts/UIxContactFolderProperties.h b/UI/Contacts/UIxContactFolderProperties.h new file mode 100644 index 000000000..346ec5529 --- /dev/null +++ b/UI/Contacts/UIxContactFolderProperties.h @@ -0,0 +1,35 @@ +/* UIxContactFolderProperties.h - this file is part of SOGo + * + * Copyright (C) 2008-2014 Inverse inc. + * + * 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 + +@class NSString; + +@class SOGoContactGCSFolder; + +@interface UIxContactFolderProperties : UIxComponent +{ + SOGoContactGCSFolder *addressBook; + NSString *baseCardDAVURL, *basePublicCardDAVURL; +} + +- (NSString *) addressBookName; + +@end diff --git a/UI/Contacts/UIxContactFolderProperties.m b/UI/Contacts/UIxContactFolderProperties.m new file mode 100644 index 000000000..da875ac03 --- /dev/null +++ b/UI/Contacts/UIxContactFolderProperties.m @@ -0,0 +1,93 @@ +/* UIxContactFolderProperties.m - this file is part of SOGo + * + * Copyright (C) 2008-2014 Inverse inc. + * + * 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 "UIxContactFolderProperties.h" + +@implementation UIxContactFolderProperties + +- (id) init +{ + if ((self = [super init])) + { + addressBook = [self clientObject]; + baseCardDAVURL = nil; + basePublicCardDAVURL = nil; + } + + return self; +} + +- (void) dealloc +{ + [baseCardDAVURL release]; + [basePublicCardDAVURL release]; + [super dealloc]; +} + +- (NSString *) addressBookName +{ + return [addressBook displayName]; +} + +- (NSString *) _baseCardDAVURL +{ + NSString *davURL; + + if (!baseCardDAVURL) + { + davURL = [[addressBook realDavURL] absoluteString]; + if ([davURL hasSuffix: @"/"]) + baseCardDAVURL = [davURL substringToIndex: [davURL length] - 1]; + else + baseCardDAVURL = davURL; + [baseCardDAVURL retain]; + } + + return baseCardDAVURL; +} + +- (NSString *) cardDavURL +{ + return [NSString stringWithFormat: @"%@/", [self _baseCardDAVURL]]; +} + +- (NSString *) _basePublicCardDAVURL +{ + NSString *davURL; + + if (!basePublicCardDAVURL) + { + davURL = [[addressBook publicDavURL] absoluteString]; + if ([davURL hasSuffix: @"/"]) + basePublicCardDAVURL = [davURL substringToIndex: [davURL length] - 1]; + else + basePublicCardDAVURL = davURL; + [basePublicCardDAVURL retain]; + } + + return basePublicCardDAVURL; +} + +- (NSString *) publicCardDavURL +{ + return [NSString stringWithFormat: @"%@/", [self _basePublicCardDAVURL]]; +} + +@end diff --git a/UI/Contacts/product.plist b/UI/Contacts/product.plist index a2e2847ae..7ed3b6314 100644 --- a/UI/Contacts/product.plist +++ b/UI/Contacts/product.plist @@ -118,6 +118,10 @@ pageName = "UIxContactsUserRightsEditor"; actionName = "saveUserRights"; }; + properties = { + protectedBy = "View"; + pageName = "UIxContactFolderProperties"; + }; }; }; diff --git a/UI/Scheduler/English.lproj/Localizable.strings b/UI/Scheduler/English.lproj/Localizable.strings index 900fa9614..1309e9881 100644 --- a/UI/Scheduler/English.lproj/Localizable.strings +++ b/UI/Scheduler/English.lproj/Localizable.strings @@ -506,7 +506,7 @@ vtodo_class2 = "(Confidential task)"; "Links to this Calendar" = "Links to this Calendar"; "Authenticated User Access" = "Authenticated User Access"; -"CalDAV URL" = "CalDAV URL"; +"CalDAV URL: " = "CalDAV URL: "; "WebDAV ICS URL" = "WebDAV ICS URL"; "WebDAV XML URL" = "WebDAV XML URL"; diff --git a/UI/Templates/ContactsUI/UIxContactFolderProperties.wox b/UI/Templates/ContactsUI/UIxContactFolderProperties.wox new file mode 100644 index 000000000..7dd139840 --- /dev/null +++ b/UI/Templates/ContactsUI/UIxContactFolderProperties.wox @@ -0,0 +1,63 @@ + + + + +
+
    +
  • +
  • +
  • +
  • +
+ +
+ +
+
+ +
+ + +
+
+
+ + +
+ + + + +
+ + +
+ + + + +
+
+
+
diff --git a/UI/Templates/SchedulerUI/UIxCalendarProperties.wox b/UI/Templates/SchedulerUI/UIxCalendarProperties.wox index 510ff73b4..8451318e6 100644 --- a/UI/Templates/SchedulerUI/UIxCalendarProperties.wox +++ b/UI/Templates/SchedulerUI/UIxCalendarProperties.wox @@ -10,7 +10,7 @@ const:toolbar="none" const:popup="YES" title="title"> - + - +
+ var:value="calendarID"/>
  • -
  • -
  • -
  • + +
  • +
- - -
- -
--> +
+ +
-
-
-
-
- - -
+
+
+
+ + +
- -
-
- -
- -
+
+ +
+ +
-
-
- - - -
- -
-
-
-
-
-
-
-
- -
-
-
- -
-
- - +
+ + + +
+ +
+
+
+
+
+
+
+
+ +
+
+ +
+ +
+
+
+ + + + + + +
-
- +
diff --git a/UI/WebServerResources/ContactsUI.js b/UI/WebServerResources/ContactsUI.js index ca699b44f..e6d1a5cfe 100644 --- a/UI/WebServerResources/ContactsUI.js +++ b/UI/WebServerResources/ContactsUI.js @@ -690,6 +690,7 @@ function addListToOpener (tag, aBookId, aBookName, listId) { "tag": tag }); } + function addListToOpenerCallback (http) { var data = http.callbackData; var received = http.responseText.evalJSON (true); @@ -814,6 +815,7 @@ function onAddressBookImport(event) { div.setStyle({ top: top + "px", left: left + "px" }); div.show(); } + function hideContactsImport(event) { $("uploadDialog").hide(); } @@ -821,6 +823,7 @@ function hideContactsImport(event) { function hideImportResults () { $("uploadResults").hide(); } + function validateUploadForm () { rc = false; if ($("contactsFile").value.length) { @@ -832,6 +835,7 @@ function validateUploadForm () { } return rc; } + function uploadCompleted(response) { jQuery('#uploadCancel').show(); var btn = jQuery('#uploadSubmit'); @@ -1058,39 +1062,19 @@ function updateAddressBooksMenus() { } function onAddressBookModify(event) { - var folders = $("contactFolders"); - var selected = folders.getSelectedNodes()[0]; - if (selected.getAttribute("owner") != "nobody") { - var currentName = selected.innerHTML.unescapeHTML(); - showPromptDialog(_("Properties"), - _("Address Book Name"), - onAddressBookModifyConfirm, - currentName); - } -} - -function onAddressBookModifyConfirm() { - var folders = $("contactFolders"); - var selected = folders.getSelectedNodes()[0]; - var newName = this.value; - var currentName = this.getAttribute("previousValue"); - if (newName && newName.length > 0 - && newName != currentName) { - var url = (URLForFolderID(selected.getAttribute("id")) - + "/renameFolder?name=" + escape(newName.utf8encode())); - triggerAjaxRequest(url, folderRenameCallback, - {node: selected, name: newName}); - } - disposeDialog(); -} - -function folderRenameCallback(http) { - if (http.readyState == 4) { - if (isHttpStatus204(http.status)) { - var dict = http.callbackData; - dict["node"].innerHTML = dict["name"]; - } - } + var folders = $("contactFolders"); + var selected = folders.getSelectedNodes()[0]; + var addressBookID = selected.getAttribute("id"); + var url = ApplicationBaseURL + addressBookID + "/properties"; + var windowID = sanitizeWindowName(addressBookID + " properties"); + var width = 410; + var height = 410; + + $(function() { + var properties = window.open(url, windowID, "width="+width+",height="+height+",resizable=0"); + properties.focus(); + }).delay(0.1); + } function onMenuSharing(event) { diff --git a/UI/WebServerResources/UIxCalendarProperties.js b/UI/WebServerResources/UIxCalendarProperties.js index 27d32dbd2..a44eb9c7a 100644 --- a/UI/WebServerResources/UIxCalendarProperties.js +++ b/UI/WebServerResources/UIxCalendarProperties.js @@ -18,6 +18,20 @@ function onLoadCalendarProperties() { var okButton = $("okButton"); okButton.observe("click", onOKClick); + + Event.observe(document, "keydown", onDocumentKeydown); +} + +function onDocumentKeydown(event) { + var target = Event.element(event); + if (target.tagName == "INPUT" || target.tagName == "SELECT") { + if (event.keyCode == Event.KEY_RETURN) { + onOKClick(event); + } + } + if (event.keyCode == Event.KEY_ESC) { + onCancelClick(); + } } function onCancelClick(event) { diff --git a/UI/WebServerResources/UIxContactFolderProperties.css b/UI/WebServerResources/UIxContactFolderProperties.css new file mode 100644 index 000000000..57ef6ab28 --- /dev/null +++ b/UI/WebServerResources/UIxContactFolderProperties.css @@ -0,0 +1,40 @@ +DIV +{ clear: both; } + +FIELDSET +{ margin-bottom: 5px; + border: 1px solid #FFFFFF; + border-top: 1px solid #909090; + border-left: 1px solid #909090; } + +FIELDSET DIV +{ margin-left: 20px; + margin-right: 10px; } + +SPAN.label +{ cursor: default; + width: 55px; + text-align: right; + line-height: 2em; + float: left; + display: block; } + +SPAN.content +{ line-height: 1.5em; + vertical-align: middle; + margin-left: 4px; } + +SPAN.content INPUT.textField +{ width: 160px; } + +DIV#buttons +{ position: absolute; + bottom: 5px; + right: 5px; + padding: 10px; + padding-top: 5px; + text-align: right; } + + +LABEL +{ white-space: nowrap; } diff --git a/UI/WebServerResources/UIxContactFolderProperties.js b/UI/WebServerResources/UIxContactFolderProperties.js new file mode 100644 index 000000000..6854856c5 --- /dev/null +++ b/UI/WebServerResources/UIxContactFolderProperties.js @@ -0,0 +1,71 @@ +/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +function onLoadContactFolderProperties() { + var tabsContainer = $("propertiesTabs"); + var controller = new SOGoTabsController(); + controller.attachToTabsContainer(tabsContainer); + + var okButton = $("okButton"); + okButton.observe("click", onOKClick); + + var cancelButton = $("cancelButton"); + cancelButton.observe("click", onCancelClick); + + Event.observe(document, "keydown", onDocumentKeydown); +} + +function onOKClick(event) { + var AddressBookName = $("addressBookName"); + var folders = parent$("contactFolders"); + var selected = folders.getSelectedNodes()[0]; + + if (!AddressBookName.value.blank()) { + var newName = AddressBookName.value; + var currentName = AddressBookName.defaultValue; + if (newName && newName.length > 0 && newName != currentName) { + if (selected.getAttribute("owner") != "nobody") { + var url = (URLForFolderID(selected.getAttribute("id")) + "/renameFolder?name=" + escape(newName.utf8encode())); + triggerAjaxRequest(url, folderRenameCallback, {node: selected, name: newName}); + + } + else { + alert_("You do not own this address book"); + } + } + else + window.close(); + } + else + alert(_("Please specify an address book name.")); + Event.stop(event); +} + +function folderRenameCallback(http) { + if (http.readyState == 4) { + if (isHttpStatus204(http.status)) { + var dict = http.callbackData; + dict["node"].innerHTML = dict["name"]; + window.close(); + } + } +} + +function onCancelClick(event) { + window.close(); +} + +function onDocumentKeydown(event) { + var target = Event.element(event); + if (target.tagName == "INPUT" || target.tagName == "SELECT") { + if (event.keyCode == Event.KEY_RETURN) { + onOKClick(event); + } + } + if (event.keyCode == Event.KEY_ESC) { + onCancelClick(); + } +} + + + +document.observe("dom:loaded", onLoadContactFolderProperties);