Changeset 789 for apps/iphone
- Timestamp:
- 01/26/11 13:37:09 (2 years ago)
- Location:
- apps/iphone/my.tel/trunk/Classes
- Files:
-
- 2 modified
-
ProfileRecordsViewController.h (modified) (1 diff)
-
ProfileRecordsViewController.m (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
apps/iphone/my.tel/trunk/Classes/ProfileRecordsViewController.h
r772 r789 57 57 - (void)storeTextHeader:(NSString *)newHeader; 58 58 - (void)getRecords; 59 - (void)enableRecords ;60 - (void)disableRecords ;59 - (void)enableRecordsUsingGlobal:(BOOL)isGlobal; 60 - (void)disableRecordsUsingGlobal:(BOOL)isGlobal; 61 61 62 62 - (void)updateEditButtonAndDoNothing:(NSDictionary *)parsedJson; -
apps/iphone/my.tel/trunk/Classes/ProfileRecordsViewController.m
r777 r789 275 275 if (editing) { 276 276 [self displayDisabledRecords:YES]; 277 buttonEditCount = 2;278 277 self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel 279 278 target:self … … 284 283 // Clicked "Done", not "Cancel" 285 284 // The Cancel leftBarButtonItem button was removed in didClickCancel 285 buttonEditCount = 4; 286 286 self.navigationItem.leftBarButtonItem = nil; 287 [self enableRecords ];287 [self enableRecordsUsingGlobal:NO]; 288 288 [self getRecords]; 289 289 } … … 350 350 // 1- that all enable-disable actions are done in serial order 351 351 // 2- that the user cannot re-edit the table before all is done 352 // call enableRecords , and all goes from there automatically352 // call enableRecordsUsingGlobal:NO, and all goes from there automatically 353 353 if (parsedJson) { 354 354 [[MyTelConnect sharedInstance] doNothing:parsedJson]; 355 355 } 356 356 switch (buttonEditCount) { 357 case 2: // This case should be skipped if you start by calling enableRecords 358 [self enableRecords]; 357 case 4: // This case will be skipped if you start by calling enableRecordsUsingGlobal:NO 358 [self enableRecordsUsingGlobal:NO]; 359 break; 360 case 3: 361 [self enableRecordsUsingGlobal:YES]; 362 break; 363 case 2: 364 [self disableRecordsUsingGlobal:NO]; 359 365 break; 360 366 case 1: 361 [self disableRecords ];367 [self disableRecordsUsingGlobal:YES]; 362 368 break; 363 369 case 0: … … 764 770 } 765 771 766 - (void)enableRecords {772 - (void)enableRecordsUsingGlobal:(BOOL)isGlobal { 767 773 // inputRecords = { 768 774 // domainName: "cartman.tel", … … 778 784 // }; 779 785 786 buttonEditCount--; 780 787 NSMutableArray *apiIdArray = [NSMutableArray arrayWithCapacity:[uiArray count]]; 781 788 for (NSDictionary *theRow in uiArray) { 782 if ([[theRow valueForKey:@"global"] integerValue] == 1) { 783 // We don't modify global records 784 // TODO: Show the user that global records can't be modified 789 if ([[theRow valueForKey:@"global"] integerValue] != isGlobal) { 790 // We don't modify records that are not what we're asking for: either global or profile-specific 785 791 continue; 786 792 } 787 793 if ([[theRow valueForKey:@"enabled"] integerValue] == 1) { 788 if ([[theRow valueForKey:@"terminal"] integerValue] == 1) { 789 // Only handle terminal records 790 [apiIdArray addObject:[theRow objectForKey:@"apiId"]]; 791 } 794 [apiIdArray addObject:[theRow objectForKey:@"apiId"]]; 792 795 } 793 796 } 794 797 if ([apiIdArray count] == 0) { 795 buttonEditCount--;796 798 [self performSelector:@selector(updateEditButtonAndDoNothing:) withObject:nil]; 797 799 return; … … 805 807 NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:3] retain]; 806 808 [requestData setObject:[self.delegate domain] forKey:@"domainName"]; 807 NSArray *profiles = [NSArray arrayWithObject:[self.theProfile objectForKey:@"id"]]; 809 NSArray *profiles; 810 if (isGlobal) { 811 profiles = [NSArray arrayWithObject:@"-1"]; // global profile 812 } else { 813 profiles = [NSArray arrayWithObject:[self.theProfile objectForKey:@"id"]]; 814 } 808 815 [requestData setObject:profiles forKey:@"profiles"]; 809 816 … … 813 820 [conn performLookup:TRUE]; 814 821 [requestData release]; 815 buttonEditCount--; 816 } 817 818 - (void)disableRecords { 822 } 823 824 - (void)disableRecordsUsingGlobal:(BOOL)isGlobal { 819 825 // inputRecords = { 820 826 // domainName: "cartman.tel", … … 830 836 // }; 831 837 838 buttonEditCount--; 832 839 NSMutableArray *apiIdArray = [NSMutableArray arrayWithCapacity:[uiArray count]]; 833 840 for (NSDictionary *theRow in uiArray) { 834 if ([[theRow valueForKey:@"enabled"] integerValue] == 0) { 835 if ([[theRow valueForKey:@"terminal"] integerValue] == 1) { 836 // Only handle terminal records 837 [apiIdArray addObject:[theRow objectForKey:@"apiId"]]; 838 } 841 if ([[theRow valueForKey:@"global"] integerValue] != isGlobal) { 842 // We don't modify records that are not what we're asking for: either global or profile-specific 843 continue; 844 } 845 if ([[theRow valueForKey:@"enabled"] integerValue] == 1) { 846 [apiIdArray addObject:[theRow objectForKey:@"apiId"]]; 839 847 } 840 848 } 841 849 if ([apiIdArray count] == 0) { 842 buttonEditCount--;843 850 [self performSelector:@selector(updateEditButtonAndDoNothing:) withObject:nil]; 844 851 return; … … 852 859 NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:3] retain]; 853 860 [requestData setObject:[self.delegate domain] forKey:@"domainName"]; 854 NSArray *profiles = [NSArray arrayWithObject:[self.theProfile objectForKey:@"id"]]; 861 NSArray *profiles; 862 if (isGlobal) { 863 profiles = [NSArray arrayWithObject:@"-1"]; // global profile 864 } else { 865 profiles = [NSArray arrayWithObject:[self.theProfile objectForKey:@"id"]]; 866 } 855 867 [requestData setObject:profiles forKey:@"profiles"]; 856 868 … … 860 872 [conn performLookup:TRUE]; 861 873 [requestData release]; 862 buttonEditCount--;863 874 } 864 875








