(fix) reworked c_ prefixes on givenname,cn,sn,o and component.

This makes it easier to map to the quick table and avoid
fields duplications.
pull/91/head
Ludovic Marcotte 2015-07-27 12:47:40 -04:00
parent dc9a0896e5
commit 40dd3e5875
11 changed files with 44 additions and 69 deletions

View File

@ -218,11 +218,6 @@ static NSArray *folderListingFields = nil;
{
NSString *data;
// c_component => tag
data = [contactRecord objectForKey: @"c_component"];
if ([data length])
[contactRecord setObject: data forKey: @"tag"];
// c_categories => categories
data = [contactRecord objectForKey: @"c_categories"];
if ([data length])
@ -235,9 +230,7 @@ static NSArray *folderListingFields = nil;
// c_cn => fn
data = [contactRecord objectForKey: @"c_cn"];
if ([data length])
[contactRecord setObject: data forKey: @"fn"];
else
if (![data length])
{
data = [contactRecord keysWithFormat: @"%{c_givenname} %{c_sn}"];
if ([data length] > 1)
@ -251,25 +244,10 @@ static NSArray *folderListingFields = nil;
}
}
// c_givenname => givenname
data = [contactRecord objectForKey: @"c_givenname"];
if ([data length])
[contactRecord setObject: data forKey: @"givenname"];
// c_sn => sn
data = [contactRecord objectForKey: @"c_sn"];
if ([data length])
[contactRecord setObject: data forKey: @"sn"];
// c_screenname => X-AIM
if (![contactRecord objectForKey: @"c_screenname"])
[contactRecord setObject: @"" forKey: @"c_screenname"];
// c_o => org
data = [contactRecord objectForKey: @"c_o"];
if ([data length])
[contactRecord setObject: data forKey: @"org"];
// c_mail => emails[]
data = [contactRecord objectForKey: @"c_mail"];
if ([data length])

View File

@ -318,12 +318,12 @@
if (data)
{
[newRecord setObject: data forKey: @"isGroup"];
[newRecord setObject: @"vlist" forKey: @"tag"];
[newRecord setObject: @"vlist" forKey: @"c_component"];
}
#warning TODO: create a custom icon for resources
else
{
[newRecord setObject: @"vcard" forKey: @"tag"];
[newRecord setObject: @"vcard" forKey: @"c_component"];
}
// c_info => note

View File

@ -351,11 +351,11 @@ static Class SOGoContactGCSEntryK = Nil;
id o;
unsigned int i, year, month, day;
[card setNWithFamily: [attributes objectForKey: @"sn"]
given: [attributes objectForKey: @"givenname"]
[card setNWithFamily: [attributes objectForKey: @"c_sn"]
given: [attributes objectForKey: @"c_givenname"]
additional: nil prefixes: nil suffixes: nil];
[card setNickname: [attributes objectForKey: @"nickname"]];
[card setFn: [attributes objectForKey: @"fn"]];
[card setFn: [attributes objectForKey: @"c_cn"]];
[card setTitle: [attributes objectForKey: @"title"]];
unsigned int seconds = [[NSString stringWithFormat: @"%@", [attributes objectForKey: @"birthday"]] intValue];
@ -416,7 +416,7 @@ static Class SOGoContactGCSEntryK = Nil;
{
units = nil;
}
[card setOrg: [attributes objectForKey: @"org"]
[card setOrg: [attributes objectForKey: @"c_org"]
units: units];
elements = [card childrenWithTag: @"tel"];
@ -509,11 +509,11 @@ static Class SOGoContactGCSEntryK = Nil;
*
* @apiParam {String} id Card ID
* @apiParam {String} pid Address book ID (card's container)
* @apiParam {String} tag Either vcard or vlist
* @apiParam {String} givenname Firstname
* @apiParam {String} c_component Either vcard or vlist
* @apiParam {String} c_givenname Firstname
* @apiParam {String} nickname Nickname
* @apiParam {String} sn Lastname
* @apiParam {String} fn Fullname
* @apiParam {String} c_sn Lastname
* @apiParam {String} c_cn Fullname
* @apiParam {String} tz Timezone
* @apiParam {String} note Note
* @apiParam {String[]} allCategories All available categories

View File

@ -747,11 +747,11 @@
*
* @apiSuccess (Success 200) {String} id Card ID
* @apiSuccess (Success 200) {String} pid Address book ID (card's container)
* @apiSuccess (Success 200) {String} tag Either vcard or vlist
* @apiSuccess (Success 200) {String} [givenname] Firstname
* @apiSuccess (Success 200) {String} c_component Either vcard or vlist
* @apiSuccess (Success 200) {String} [c_givenname] Firstname
* @apiSuccess (Success 200) {String} [nickname] Nickname
* @apiSuccess (Success 200) {String} [sn] Lastname
* @apiSuccess (Success 200) {String} [fn] Fullname
* @apiSuccess (Success 200) {String} [c_sn] Lastname
* @apiSuccess (Success 200) {String} [c_fn] Fullname
* @apiSuccess (Success 200) {String} [tz] Timezone
* @apiSuccess (Success 200) {String} [note] Note
* @apiSuccess (Success 200) {String[]} allCategories All available categories
@ -799,19 +799,19 @@
data = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[[contact container] nameInContainer], @"pid",
[contact nameInContainer], @"id",
[[card tag] lowercaseString], @"tag",
[[card tag] lowercaseString], @"c_component",
nil];
o = [card fn];
if (o) [data setObject: o forKey: @"fn"];
if (o) [data setObject: o forKey: @"c_cn"];
o = [card n];
if (o)
{
NSString *lastName = [o flattenedValueAtIndex: 0 forKey: @""];
NSString *firstName = [o flattenedValueAtIndex: 1 forKey: @""];
if ([lastName length] > 0)
[data setObject: lastName forKey: @"sn"];
[data setObject: lastName forKey: @"c_sn"];
if ([firstName length] > 0)
[data setObject: firstName forKey: @"givenname"];
[data setObject: firstName forKey: @"c_givenname"];
}
o = [card nickname];
if (o) [data setObject: o forKey: @"nickname"];
@ -833,7 +833,7 @@
o = [card workCompany];
if ([o length] > 0)
{
[data setObject: o forKey: @"org"];
[data setObject: o forKey: @"c_org"];
}
o = [card birthday];

View File

@ -162,12 +162,9 @@
* @apiSuccess (Success 200) {Object[]} [cards] Matching cards
* @apiSuccess (Success 200) {String} cards.id Card ID
* @apiSuccess (Success 200) {String} cards.c_name Card ID
* @apiSuccess (Success 200) {String} cards.tag Either vcard or vlist
* @apiSuccess (Success 200) {String} cards.c_component Either vcard or vlist
* @apiSuccess (Success 200) {String} cards.c_cn Fullname
* @apiSuccess (Success 200) {String} cards.givenname Fullname
* @apiSuccess (Success 200) {String} cards.c_givenname Firstname
* @apiSuccess (Success 200) {String} cards.sn Firstname
* @apiSuccess (Success 200) {String} cards.c_sn Lastname
* @apiSuccess (Success 200) {String} cards.c_screenname Screenname
* @apiSuccess (Success 200) {String} cards.c_o Organization name

View File

@ -208,7 +208,7 @@
if ([[references objectAtIndex: i] isKindOfClass: [NSDictionary class]])
{
currentReference = [references objectAtIndex: i];
uid = [currentReference objectForKey: @"reference"];
uid = [currentReference objectForKey: @"id"];
if (![self cardReferences: [list cardReferences]
contain: uid])
{
@ -231,7 +231,7 @@
SOGoContactGCSEntry *newContact;
workMail = [currentReference objectForKey: @"email"];
fn = [currentReference objectForKey: @"fn"];
fn = [currentReference objectForKey: @"c_cn"];
// Create a new vCard
newUID = [NSString stringWithFormat: @"%@.vcf", [co globallyUniqueObjectId]];
@ -290,7 +290,7 @@
- (void) setAttributes: (NSDictionary *) attributes
{
[list setNickname: [attributes objectForKey: @"nickname"]];
[list setFn: [attributes objectForKey: @"fn"]];
[list setFn: [attributes objectForKey: @"c_cn"]];
[list setDescription: [attributes objectForKey: @"description"]];
}

View File

@ -166,7 +166,7 @@
card = [[list cardReferences] objectAtIndex: i];
[cards addObject: [NSDictionary dictionaryWithObjectsAndKeys:
[card reference], @"reference",
[card fn], @"fn",
[card fn], @"c_cn",
[card email], @"email",
nil]];
}
@ -174,8 +174,8 @@
data = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[[co container] nameInContainer], @"pid",
[co nameInContainer], @"id",
[[list tag] lowercaseString], @"tag",
[list fn], @"fn",
[[list tag] lowercaseString], @"c_component",
[list fn], @"c_cn",
[list nickname], @"nickname",
[list description], @"description",
cards, @"refs",

View File

@ -16,7 +16,7 @@
<label>
<var:string label:value="Display"/>
</label>
<input type="text" ng-maxlength="30" ng-model="editor.card.fn"/>
<input type="text" ng-maxlength="30" ng-model="editor.card.c_cn"/>
</md-input-container>
<!-- todo: look for better reset/normalization. Semanticaly this should be a fieldset, but content doesn't flex properly du to browser styles-->
<div id="contact-identification" class="sg-fieldset" layout="row" layout-sm="column">
@ -24,13 +24,13 @@
<label>
<var:string label:value="Firstname"/>
</label>
<input type="text" ng-model="editor.card.givenname"/>
<input type="text" ng-model="editor.card.c_givenname"/>
</md-input-container>
<md-input-container flex="40">
<label>
<var:string label:value="Lastname"/>
</label>
<input type="text" ng-model="editor.card.sn"/>
<input type="text" ng-model="editor.card.c_sn"/>
</md-input-container>
<md-input-container flex="20">
<label>
@ -45,7 +45,7 @@
<label>
<var:string label:value="Organization"/>
</label>
<input type="text" ng-model="editor.card.org"/>
<input type="text" ng-model="editor.card.c_org"/>
</md-input-container>
<md-input-container>
<label>
@ -292,7 +292,7 @@
<label>
<var:string label:value="Display"/>
</label>
<input type="text" ng-maxlength="30" ng-model="editor.card.fn"/>
<input type="text" ng-maxlength="30" ng-model="editor.card.c_cn"/>
</md-input-container>
<md-input-container>

View File

@ -126,7 +126,7 @@
stateNewCard.$inject = ['$stateParams', 'stateAddressbook', 'Card'];
function stateNewCard($stateParams, stateAddressbook, Card) {
var tag = 'v' + $stateParams.contactType,
card = new Card({ pid: $stateParams.addressbookId, tag: tag });
card = new Card({ pid: $stateParams.addressbookId, c_component: tag });
stateAddressbook.selectedCard = true;
return card;
}

View File

@ -66,7 +66,7 @@
}
function notSelectedComponent(currentCard, type) {
return (currentCard && currentCard.tag == type && !currentCard.selected);
return (currentCard && currentCard.c_component == type && !currentCard.selected);
}
function unselectCards() {

View File

@ -145,7 +145,7 @@
var _this = this,
action = 'saveAsContact';
if (this.tag == 'vlist') action = 'saveAsList';
if (this.c_component == 'vlist') action = 'saveAsList';
return Card.$$resource.save([this.pid, this.id || '_new_'].join('/'),
this.$omit(),
@ -170,19 +170,19 @@
};
Card.prototype.$fullname = function() {
var fn = this.fn || '', names;
var fn = this.c_cn || '', names;
if (fn.length === 0) {
names = [];
if (this.givenname && this.givenname.length > 0)
names.push(this.givenname);
if (this.c_givenname && this.c_givenname.length > 0)
names.push(this.c_givenname);
if (this.nickname && this.nickname.length > 0)
names.push('<em>' + this.nickname + '</em>');
if (this.sn && this.sn.length > 0)
names.push(this.sn);
if (this.c_sn && this.c_sn.length > 0)
names.push(this.c_sn);
if (names.length > 0)
fn = names.join(' ');
else if (this.org && this.org.length > 0) {
fn = this.org;
else if (this.c_org && this.c_org.length > 0) {
fn = this.c_org;
}
else if (this.emails && this.emails.length > 0) {
fn = _.find(this.emails, function(i) { return i.value !== ''; }).value;
@ -265,11 +265,11 @@
};
Card.prototype.$isCard = function() {
return this.tag == 'vcard';
return this.c_component == 'vcard';
};
Card.prototype.$isList = function() {
return this.tag == 'vlist';
return this.c_component == 'vlist';
};
Card.prototype.$addOrgUnit = function(orgUnit) {
@ -408,7 +408,7 @@
email: email,
emails: [{value: email}],
reference: card.c_name,
fn: card.$fullname()
c_cn: card.$fullname()
};
this.refs[index] = new Card(ref);
};