(web) Fix default calendar categories (reset btn)

This commit is contained in:
Francis Lachapelle committed 2019-03-07 11:22:00 -05:00
1 parent 3e0910d175
commit 97dd4fddf7
1 file changed
+43 -5
+43 -5
View File
@@ -1212,17 +1212,49 @@ static NSArray *reminderValues = nil;
return [uniqueAddressesList componentsJoinedByString: @", "]; return [uniqueAddressesList componentsJoinedByString: @", "];
} }
//
// Used internally
//
- (NSDictionary *) _localizedCategoryLabels
{
NSArray *categoryLabels, *localizedCategoryLabels;
NSDictionary *labelsDictionary;
labelsDictionary = nil;
localizedCategoryLabels = [[self labelForKey: @"calendar_category_labels"
withResourceManager: [self resourceManager]]
componentsSeparatedByString: @","];
categoryLabels = [[[self resourceManager]
stringForKey: @"calendar_category_labels"
inTableNamed: nil
withDefaultValue: @""
languages: [NSArray arrayWithObject: @"English"]]
componentsSeparatedByString: @","];
if ([localizedCategoryLabels count] == [categoryLabels count])
labelsDictionary = [NSDictionary dictionaryWithObjects: localizedCategoryLabels
forKeys: categoryLabels];
else
[self logWithFormat: @"ERROR: localizable strings calendar_category_labels is incorrect for language %@",
[[[context activeUser] userDefaults] language]];
return labelsDictionary;
}
// //
// Used by templates // Used by templates
// //
- (NSString *) defaultCalendarCategoriesColors - (NSString *) defaultCalendarCategoriesColors
{ {
NSArray *labels, *colors; NSArray *labels;
NSDictionary *localizedLabels, *colors;
NSMutableDictionary *defaultCategoriesColors; NSMutableDictionary *defaultCategoriesColors;
NSString *label, *localizedLabel, *color;
unsigned int i; unsigned int i;
labels = [[self labelForKey: @"calendar_category_labels"] componentsSeparatedByString: @","]; localizedLabels = [self _localizedCategoryLabels];
colors = [[[SOGoSystemDefaults sharedSystemDefaults] calendarCategoriesColors] allValues]; labels = [[SOGoSystemDefaults sharedSystemDefaults] calendarCategories];
colors = [[SOGoSystemDefaults sharedSystemDefaults] calendarCategoriesColors];
if ([colors count] > [labels count]) if ([colors count] > [labels count])
{ {
@@ -1232,8 +1264,14 @@ static NSArray *reminderValues = nil;
defaultCategoriesColors = [NSMutableDictionary dictionary]; defaultCategoriesColors = [NSMutableDictionary dictionary];
for (i = 0; i < [colors count] && i < [labels count]; i++) for (i = 0; i < [colors count] && i < [labels count]; i++)
{ {
[defaultCategoriesColors setObject: [colors objectAtIndex: i] label = [labels objectAtIndex: i];
forKey: [labels objectAtIndex: i]]; color = [colors objectForKey: label];
if (!(localizedLabel = [localizedLabels objectForKey: label]))
{
localizedLabel = label;
}
[defaultCategoriesColors setObject: color
forKey: localizedLabel];
} }
return [defaultCategoriesColors jsonRepresentation]; return [defaultCategoriesColors jsonRepresentation];