(fix) JavaScript errors on Mail preferences tab

This commit is contained in:
Francis Lachapelle 2015-04-13 09:47:33 -04:00
parent 41f598c9ed
commit 4626039e5c
2 changed files with 61 additions and 54 deletions

View file

@ -800,62 +800,51 @@ static NSArray *reminderValues = nil;
// //
- (NSArray *) addressBookList - (NSArray *) addressBookList
{ {
/* We want all the SourceIDS */ NSMutableArray *folders, *localAddressBooks;
NSMutableArray *folders, *availableAddressBooksID, *availableAddressBooksName; SOGoParentFolder *contactFolder;
SOGoParentFolder *contactFolders; SOGoContactGCSFolder *addressbook;
int i, count; int i, count;
BOOL collectedAlreadyExist; BOOL collectedAlreadyExist;
contactFolders = [[[context activeUser] homeFolderInContext: context] // Fetch all addressbooks
contactFolder = [[[context activeUser] homeFolderInContext: context]
lookupName: @"Contacts" lookupName: @"Contacts"
inContext: context inContext: context
acquire: NO]; acquire: NO];
folders = [NSMutableArray arrayWithArray: [contactFolders subFolders]]; folders = [NSMutableArray arrayWithArray: [contactFolder subFolders]];
count = [folders count]-1; count = [folders count];
// Inside this loop we remove all the public or shared addressbooks // Remove all public addressbooks
for (; count >= 0; count--) for (count--; count >= 0; count--)
{ {
if (![[folders objectAtIndex: count] isKindOfClass: [SOGoContactGCSFolder class]]) if (![[folders objectAtIndex: count] isKindOfClass: [SOGoContactGCSFolder class]])
[folders removeObjectAtIndex: count]; [folders removeObjectAtIndex: count];
} }
// Parse the objects in order to have only the displayName of the addressbooks to be displayed on the preferences interface // Build list of local addressbooks
availableAddressBooksID = [NSMutableArray arrayWithCapacity: [folders count]]; localAddressBooks = [NSMutableArray arrayWithCapacity: [folders count]];
availableAddressBooksName = [NSMutableArray arrayWithCapacity: [folders count]]; count = [folders count];
count = [folders count]-1;
collectedAlreadyExist = NO; collectedAlreadyExist = NO;
for (i = 0; i <= count ; i++) for (i = 0; i < count ; i++)
{ {
[availableAddressBooksID addObject:[[folders objectAtIndex:i] realNameInContainer]]; addressbook = [folders objectAtIndex: i];
[availableAddressBooksName addObject:[[folders objectAtIndex:i] displayName]]; [localAddressBooks addObject: [NSDictionary dictionaryWithObjectsAndKeys:
[addressbook nameInContainer], @"id",
if ([[availableAddressBooksID objectAtIndex:i] isEqualToString: @"collected"]) [addressbook displayName], @"name",
nil]];
if ([[addressbook nameInContainer] isEqualToString: @"collected"])
collectedAlreadyExist = YES; collectedAlreadyExist = YES;
} }
// Create the dictionary for the next function : itemAddressBookText.
if (!addressBooksIDWithDisplayName)
{
addressBooksIDWithDisplayName = [[NSMutableDictionary alloc] initWithObjects:availableAddressBooksName
forKeys:availableAddressBooksID];
}
if (!collectedAlreadyExist) if (!collectedAlreadyExist)
{ {
[availableAddressBooksID addObject: @"collected"]; [localAddressBooks addObject: [NSDictionary dictionaryWithObjectsAndKeys:
[addressBooksIDWithDisplayName setObject: [self labelForKey: @"Collected Address Book"] forKey: @"collected"]; @"collected", @"id",
[self labelForKey: @"Collected Address Book"], @"name",
nil]];
} }
return availableAddressBooksID;
}
// return localAddressBooks;
// Used by wox template
//
- (NSString *) itemAddressBookText
{
return [addressBooksIDWithDisplayName objectForKey: item];
} }
// - (NSString *) userAddressBook // - (NSString *) userAddressBook

View file

@ -526,14 +526,16 @@
<md-checkbox <md-checkbox
ng-model="preferences.defaults.SOGoMailShowSubscribedFoldersOnly" ng-model="preferences.defaults.SOGoMailShowSubscribedFoldersOnly"
ng-true-value="1" ng-true-value="1"
ng-false-value="0"> ng-false-value="0"
label:aria-label="Show subscribed mailboxes only">
<var:string label:value="Show subscribed mailboxes only"/> <var:string label:value="Show subscribed mailboxes only"/>
</md-checkbox> </md-checkbox>
<md-checkbox <md-checkbox
ng-model="preferences.defaults.SOGoMailSortByThreads" ng-model="preferences.defaults.SOGoMailSortByThreads"
ng-true-value="1" ng-true-value="1"
ng-false-value="0"> ng-false-value="0"
label:aria-label="Sort messages by threads">
<var:string label:value="Sort messages by threads"/> <var:string label:value="Sort messages by threads"/>
</md-checkbox> </md-checkbox>
@ -541,14 +543,15 @@
<md-checkbox <md-checkbox
ng-model="preferences.defaults.SOGoMailAddOutgoingAddresses" ng-model="preferences.defaults.SOGoMailAddOutgoingAddresses"
ng-true-value="1" ng-true-value="1"
ng-false-value="0"> ng-false-value="0"
label:arial-label="When sending mail, add unknown recipients to my">
<var:string label:value="When sending mail, add unknown recipients to my"/> <var:string label:value="When sending mail, add unknown recipients to my"/>
</md-checkbox> </md-checkbox>
<md-select ng-model="preferences.defaults.SOGoSelectedAddressBook"> <md-select ng-model="preferences.defaults.SOGoSelectedAddressBook">
<var:foreach list="addressBookList" item="item"> <var:foreach list="addressBookList" item="item">
<md-option var:value="item"> <md-option var:value="item.id">
<var:string value="itemAddressBookText"/> <var:string value="item.name"/>
</md-option> </md-option>
</var:foreach> </var:foreach>
</md-select> </md-select>
@ -655,12 +658,14 @@
</md-input-container> </md-input-container>
<md-button ng-click="editMailFilter($index)" <md-button ng-click="editMailFilter($index)"
type="button" type="button"
layout="row" layout-align="end center"> layout="row" layout-align="end center"
label:aria-label="Edit Filter">
<div class="md-icon-edit md-icon-lg"><!-- edit --></div> <div class="md-icon-edit md-icon-lg"><!-- edit --></div>
</md-button> </md-button>
<md-button ng-click="removeMailFilter($index)" <md-button ng-click="removeMailFilter($index)"
type="button" type="button"
layout="row" layout-align="end center"> layout="row" layout-align="end center"
label:aria-label="Delete Filter">
<div class="md-icon-remove"><!-- delete --></div> <div class="md-icon-remove"><!-- delete --></div>
</md-button> </md-button>
</md-list-item> </md-list-item>
@ -668,7 +673,9 @@
<!-- FIXME: move up/down to be replaced by DnD? --> <!-- FIXME: move up/down to be replaced by DnD? -->
<div class="bottomToolbar"> <div class="bottomToolbar">
<md-button ng-click="addMailFilter($event)" type="button"> <md-button ng-click="addMailFilter($event)"
type="button"
label:aria-label="Create Filter">
<div class="md-icon-add"><!-- create --></div> <div class="md-icon-add"><!-- create --></div>
</md-button> </md-button>
</div> </div>
@ -690,14 +697,17 @@
</md-input-container> </md-input-container>
<md-button ng-click="removeMailLabel(key)" <md-button ng-click="removeMailLabel(key)"
type="button" type="button"
layout="row" layout-align="end center"> layout="row" layout-align="end center"
label:aria-label="Delete Label">
<div class="md-icon-remove"><!-- delete --></div> <div class="md-icon-remove"><!-- delete --></div>
</md-button> </md-button>
</md-list-item> </md-list-item>
</md-list> </md-list>
<div class="bottomToolbar"> <div class="bottomToolbar">
<md-button ng-click="addMailLabel()" type="button"> <md-button ng-click="addMailLabel()"
type="button"
label:aria-label="Create Label">
<div class="md-icon-add"><!-- create --></div> <div class="md-icon-add"><!-- create --></div>
</md-button> </md-button>
</div> </div>
@ -721,12 +731,17 @@
</md-input-container> </md-input-container>
<md-button ng-click="editMailAccount($index)" <md-button ng-click="editMailAccount($index)"
type="button" type="button"
layout="row" layout-align="end center"> layout="row"
layout-align="end center"
label:aria-label="Edit Account">
<div class="md-icon-edit md-icon-lg"><!-- edit --></div> <div class="md-icon-edit md-icon-lg"><!-- edit --></div>
</md-button> </md-button>
<md-button ng-click="removeMailAccount()" <md-button ng-click="removeMailAccount()"
ng-show="$index > 0" type="button" ng-show="$index > 0"
layout="row" layout-align="end center"> type="button"
layout="row"
layout-align="end center"
label:aria-label="Delete Account">
<div class="md-icon-remove md-icon-lg"><!-- delete --></div> <div class="md-icon-remove md-icon-lg"><!-- delete --></div>
</md-button> </md-button>
</md-list-item> </md-list-item>
@ -734,7 +749,9 @@
<var:if condition="mailAuxiliaryUserAccountsEnabled"> <var:if condition="mailAuxiliaryUserAccountsEnabled">
<div class="bottomToolbar"> <div class="bottomToolbar">
<md-button ng-click="addMailAccount()" type="button"> <md-button ng-click="addMailAccount()"
type="button"
label:aria-label="Create Account">
<div class="md-icon-add"><!-- create --></div> <div class="md-icon-add"><!-- create --></div>
</md-button> </md-button>
</div> </div>
@ -752,7 +769,8 @@
<md-checkbox <md-checkbox
ng-model="preferences.defaults.Vacation.enabled" ng-model="preferences.defaults.Vacation.enabled"
ng-true-value="1" ng-true-value="1"
ng-false-value="0"> ng-false-value="0"
label:aria-label="Enable vacation auto reply">
<var:string label:value="Enable vacation auto reply"/> <var:string label:value="Enable vacation auto reply"/>
</md-checkbox> </md-checkbox>