(fix) JavaScript errors on Mail preferences tab

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

View File

@ -526,14 +526,16 @@
<md-checkbox
ng-model="preferences.defaults.SOGoMailShowSubscribedFoldersOnly"
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"/>
</md-checkbox>
<md-checkbox
ng-model="preferences.defaults.SOGoMailSortByThreads"
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"/>
</md-checkbox>
@ -541,14 +543,15 @@
<md-checkbox
ng-model="preferences.defaults.SOGoMailAddOutgoingAddresses"
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"/>
</md-checkbox>
<md-select ng-model="preferences.defaults.SOGoSelectedAddressBook">
<var:foreach list="addressBookList" item="item">
<md-option var:value="item">
<var:string value="itemAddressBookText"/>
<md-option var:value="item.id">
<var:string value="item.name"/>
</md-option>
</var:foreach>
</md-select>
@ -655,12 +658,14 @@
</md-input-container>
<md-button ng-click="editMailFilter($index)"
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>
</md-button>
<md-button ng-click="removeMailFilter($index)"
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>
</md-button>
</md-list-item>
@ -668,7 +673,9 @@
<!-- FIXME: move up/down to be replaced by DnD? -->
<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>
</md-button>
</div>
@ -690,14 +697,17 @@
</md-input-container>
<md-button ng-click="removeMailLabel(key)"
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>
</md-button>
</md-list-item>
</md-list>
<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>
</md-button>
</div>
@ -721,12 +731,17 @@
</md-input-container>
<md-button ng-click="editMailAccount($index)"
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>
</md-button>
<md-button ng-click="removeMailAccount()"
ng-show="$index > 0" type="button"
layout="row" layout-align="end center">
ng-show="$index > 0"
type="button"
layout="row"
layout-align="end center"
label:aria-label="Delete Account">
<div class="md-icon-remove md-icon-lg"><!-- delete --></div>
</md-button>
</md-list-item>
@ -734,7 +749,9 @@
<var:if condition="mailAuxiliaryUserAccountsEnabled">
<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>
</md-button>
</div>
@ -752,7 +769,8 @@
<md-checkbox
ng-model="preferences.defaults.Vacation.enabled"
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"/>
</md-checkbox>