* UI/WebServerResources/generic.js (openGenericWindow):

New method that opens a simple new window.

  * UI/WebServerResources/ContactsUI.js (onMenuRawContact):
  New callback to show the vCard content from the menu.

  * UI/WebServerResources/ContactsUI.js (onContactMenuPrepareVisibility):
  Enable the export and raw functions only on vcards contacts.

  * UI/Templates/ContactsUI/UIxContactFoldersView.wox:
  New contextual menu item: Show vCard content

  * UI/Contacts/UIxContactFolderActions.m (rawAction):
  New method that returns the raw contact data for all the contact uids provided

Monotone-Parent: f03db6cb5531dddabab4e8678d856fe593d3745d
Monotone-Revision: e853157abbabf35bc95273da8bc10b2d3b142627

Monotone-Author: jraby@inverse.ca
Monotone-Date: 2012-07-05T21:16:02
maint-2.0.2
Jean Raby 2012-07-05 21:16:02 +00:00
parent 5639ee6180
commit c4d11cd916
8 changed files with 133 additions and 1 deletions

View File

@ -1,5 +1,20 @@
2012-07-05 Jean Raby <jraby@inverse.ca>
* UI/WebServerResources/generic.js (openGenericWindow):
New method that opens a simple new window.
* UI/WebServerResources/ContactsUI.js (onMenuRawContact):
New callback to show the vCard content from the menu.
* UI/WebServerResources/ContactsUI.js (onContactMenuPrepareVisibility):
Enable the export and raw functions only on vcards contacts.
* UI/Templates/ContactsUI/UIxContactFoldersView.wox:
New contextual menu item: Show vCard content
* UI/Contacts/UIxContactFolderActions.m (rawAction):
New method that returns the raw contact data for all the contact uids provided
* UI/Contacts/UIxContactView.m (secondaryEmail):
function renamed to secondaryEmails. It now returns all addresses
instead of the first one found in the vcard.

View File

@ -195,6 +195,7 @@
"Lists can't be moved or copied." = "Lists can't be moved or copied.";
"Export" = "Export";
"Export Address Book..." = "Export Address Book...";
"Show vCard content" = "Show vCard content";
"Import Cards" = "Import Cards";
"Select a vCard or LDIF file." = "Select a vCard or LDIF file.";
"Upload" = "Upload";

View File

@ -195,6 +195,7 @@
"Lists can't be moved or copied." = "Les listes ne peuvent pas être déplacées ou copiées.";
"Export" = "Exporter";
"Export Address Book..." = "Exporter le carnet d'adresses...";
"Show vCard content" = "Afficher le contenu vCard";
"Import Cards" = "Importer des contacts";
"Select a vCard or LDIF file." = "Sélectionner un fichier. LDIF ou vCard.";
"Upload" = "Ajouter";

View File

@ -287,5 +287,51 @@
return rc;
}
- (id <WOActionResults>) rawAction
{
WORequest *request;
WOResponse *response;
NSArray *contactsId;
NSEnumerator *uids;
NSString *uid;
id currentChild;
SOGoContactGCSFolder *sourceFolder;
NSMutableString *content;
content = [NSMutableString string];
request = [context request];
response = [context response];
sourceFolder = [self clientObject];
contactsId = [request formValuesForKey: @"uid"];
if ((uids = [contactsId objectEnumerator]))
{
while ((uid = [uids nextObject]))
{
currentChild = [sourceFolder lookupName: uid
inContext: [self context]
acquire: NO];
if([currentChild isKindOfClass: [NSException class]])
continue;
[content appendFormat: [currentChild contentAsString]];
[content appendString: @"\n"];
}
}
if (![content length])
{
response = [self responseWithStatus: 404
andString: @"Contact does not exist"];
}
else
{
[response setHeader: @"text/plain; charset=utf-8"
forKey: @"content-type"];
[response appendContentString: content];
}
return response;
}
@end /* UIxContactsListView */

View File

@ -99,6 +99,11 @@
actionClass = "UIxContactFolderActions";
actionName = "export";
};
raw = {
protectedBy = "View";
actionClass = "UIxContactFolderActions";
actionName = "raw";
};
exportFolder = {
protectedBy = "View";
actionClass = "UIxContactFolderActions";

View File

@ -84,6 +84,7 @@
<li><var:string label:value="Move To" /></li>
<li><var:string label:value="Copy To" /></li>
<li><var:string label:value="Export" /></li>
<li><var:string label:value="Show vCard content" /></li>
</ul>
</div>

View File

@ -290,6 +290,20 @@ function onMenuExportContact (event) {
}
}
function onMenuRawContact (event) {
var selectedFolders = $("contactFolders").getSelectedNodes();
var canExport = (selectedFolders[0].getAttribute("owner") != "nobody");
if (canExport) {
var selectedFolderId = $(selectedFolders[0]).readAttribute("id");
var contactIds = document.menuTarget.collect(function(row) {
return row.readAttribute("id");
});
var url = ApplicationBaseURL + selectedFolderId + "/raw"
+ "?uid=" + contactIds.join("&uid=");
openGenericWindow(url);
}
}
function actionContactCallback(http) {
if (http.readyState == 4)
if (isHttpStatus204(http.status)) {
@ -1176,6 +1190,19 @@ function onContactMenuPrepareVisibility() {
deleteOption.removeClassName("disabled");
moveOption.removeClassName("disabled");
}
var exportOption = elements[10];
var rawOption = elements[11];
if ($(selectedFolder).getAttribute("owner") == "nobody") {
// public folders (ldap) cannot export or show raw contacts
exportOption.addClassName("disabled");
rawOption.addClassName("disabled");
}
else {
exportOption.removeClassName("disabled");
rawOption.removeClassName("disabled");
}
return true;
}
@ -1197,7 +1224,7 @@ getMenus = function() {
onMenuWriteToContact, onMenuAIMContact,
"-", onMenuDeleteContact, "-",
"moveContactMenu", "copyContactMenu",
onMenuExportContact);
onMenuExportContact, onMenuRawContact);
menus["searchMenu"] = new Array(setSearchCriteria, setSearchCriteria);
var contactFoldersMenu = $("contactFoldersMenu");

View File

@ -206,6 +206,42 @@ function openUserFolderSelector(callback, type) {
}
}
function openGenericWindow(url, wId) {
var div = $("popupFrame");
if (div) {
if (!div.hasClassName("small"))
div.addClassName("small");
var iframe = div.down("iframe");
iframe.src = url;
if (!wId)
wId = "genericFrame";
iframe.id = wId;;
var bgDiv = $("bgFrameDiv");
if (bgDiv) {
bgDiv.show();
}
else {
bgDiv = createElement("div", "bgFrameDiv");
document.body.appendChild(bgDiv);
}
div.show();
return div;
}
else {
if (!wId)
wId = "_blank";
else
wId = sanitizeWindowName(wId);
var w = window.open(url, wId,
"width=550,height=650,resizable=1,scrollbars=1,location=0");
w.focus();
return w;
}
}
function openContactWindow(url, wId) {
var div = $("popupFrame");
if (div) {