Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions XLForm/XL/Controllers/XLFormOptionsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#import "XLForm.h"
#import "NSObject+XLFormAdditions.h"
#import "NSArray+XLFormAdditions.h"
#import "XLFormViewController.h"

#define CELL_REUSE_IDENTIFIER @"OptionCell"

Expand Down Expand Up @@ -157,6 +158,8 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
}
else if ([self.parentViewController isKindOfClass:[UINavigationController class]]){
[self.navigationController popViewControllerAnimated:YES];
XLFormViewController *vc = (XLFormViewController *)self.navigationController.topViewController;
[vc.tableView reloadData];
}
}
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
Expand Down
27 changes: 25 additions & 2 deletions XLForm/XL/Descriptors/XLFormRowDescriptor.m
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NS
id newValue = [change objectForKey:NSKeyValueChangeNewKey];
id oldValue = [change objectForKey:NSKeyValueChangeOldKey];
if ([keyPath isEqualToString:@"value"]){
[self.sectionDescriptor.formDescriptor forceEvaluate];
[self.sectionDescriptor.formDescriptor.delegate formRowDescriptorValueHasChanged:object oldValue:oldValue newValue:newValue];
if (self.onChangeBlock) {
self.onChangeBlock(oldValue, newValue, self);
Expand Down Expand Up @@ -363,7 +364,18 @@ -(BOOL)evaluateIsDisabled
self.isDirtyDisablePredicateCache = YES;
} else {
@try {
self.disablePredicateCache = @([_disabled evaluateWithObject:self substitutionVariables:self.sectionDescriptor.formDescriptor.allRowsByTag ?: @{}]);
NSMutableDictionary *d = [self.sectionDescriptor.formDescriptor.allRowsByTag mutableCopy] ?: [[NSMutableDictionary alloc] init];
for (NSString *k in [d allKeys]) {
XLFormRowDescriptor *r = [d objectForKey:k];
if (r.value == nil) {
continue;
} else if ([r.value isKindOfClass:[XLFormOptionsObject class]]) {
[d setObject:[(XLFormOptionsObject *)r.value formDisplaytext] forKey:k];
} else {
[d setObject:r.value forKey:k];
}
}
self.disablePredicateCache = @([_disabled evaluateWithObject:self substitutionVariables:[d copy]]);
}
@catch (NSException *exception) {
// predicate syntax error.
Expand Down Expand Up @@ -430,7 +442,18 @@ -(BOOL)evaluateIsHidden
self.isDirtyHidePredicateCache = YES;
} else {
@try {
self.hidePredicateCache = @([_hidden evaluateWithObject:self substitutionVariables:self.sectionDescriptor.formDescriptor.allRowsByTag ?: @{}]);
NSMutableDictionary *d = [self.sectionDescriptor.formDescriptor.allRowsByTag mutableCopy] ?: [[NSMutableDictionary alloc] init];
for (NSString *k in [d allKeys]) {
XLFormRowDescriptor *r = [d objectForKey:k];
if (r.value == nil) {
continue;
} else if ([r.value isKindOfClass:[XLFormOptionsObject class]]) {
[d setObject:[(XLFormOptionsObject *)r.value formDisplaytext] forKey:k];
} else {
[d setObject:r.value forKey:k];
}
}
self.hidePredicateCache = @([_hidden evaluateWithObject:self substitutionVariables:[d copy]]);
}
@catch (NSException *exception) {
// predicate syntax error or for has not finished loading.
Expand Down
13 changes: 12 additions & 1 deletion XLForm/XL/Descriptors/XLFormSectionDescriptor.m
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,18 @@ -(BOOL)evaluateIsHidden
self.isDirtyHidePredicateCache = YES;
} else {
@try {
self.hidePredicateCache = @([_hidden evaluateWithObject:self substitutionVariables:self.formDescriptor.allRowsByTag ?: @{}]);
NSMutableDictionary *d = [self.formDescriptor.allRowsByTag mutableCopy] ?: [[NSMutableDictionary alloc] init];
for (NSString *k in [d allKeys]) {
XLFormRowDescriptor *r = [d objectForKey:k];
if (r.value == nil) {
continue;
} else if ([r.value isKindOfClass:[XLFormOptionsObject class]]) {
[d setObject:[(XLFormOptionsObject *)r.value formDisplaytext] forKey:k];
} else {
[d setObject:r.value forKey:k];
}
}
self.hidePredicateCache = @([_hidden evaluateWithObject:self substitutionVariables:[d copy]]);
}
@catch (NSException *exception) {
// predicate syntax error.
Expand Down