Răsfoiți Sursa

Modify the common editor and correct the irregular refresh mode of the background interface from the client -- 修改common editor,从客户端修正后台接口不规范的刷新方式(resolve: #14531)

Ray Zhang 4 ani în urmă
părinte
comite
a732cc03f3

+ 1 - 1
common/customUI/commoneditor/CommonEditorViewController.h

@@ -97,7 +97,7 @@
 //-(NSMutableDictionary*)create_value_map:(NSDictionary*)key_map;
 -(NSMutableDictionary*) fill_switch_subitem:(NSMutableDictionary *) switch_item subid:(NSArray*) subid source:(NSMutableDictionary*)source mapping:(NSDictionary*)mapping;
 -(NSMutableDictionary*) fill_enum_subitem:(NSMutableDictionary *) enum_item subid:(NSArray*) subid source:(NSMutableDictionary*)source mapping:(NSDictionary*)mapping;
--(void) refresh:(NSString*) trigger;
+//-(void) refresh1:(NSString*) trigger;
 -(void) handle_action_return:(NSMutableDictionary *)value indexPath :(NSIndexPath*) indexPath action:(int) action_code;
 
 // Urgency

+ 63 - 14
common/customUI/commoneditor/CommonEditorViewController.m

@@ -1338,12 +1338,25 @@
         int item_count = [[sectionjson valueForKey:@"count"] intValue];
         for(int j=0;j<item_count;j++)
         {
+            
             NSMutableDictionary * itemjson=[[sectionjson objectForKey:[NSString stringWithFormat:@"item_%d",j ]] mutableCopy];
             //             NSMutableDictionary * to_itemjson=[[to_sectionjson objectForKey:[NSString stringWithFormat:@"item_%d",j ]] mutableCopy];
             
             if([[itemjson valueForKey:@"dirty"] isEqualToString:@"true"])
             {
-                [to_sectionjson setObject:itemjson forKey:[NSString stringWithFormat:@"item_%d",j ]];
+                int toindex = -1;
+                for(int l=0;l<[to_sectionjson[@"count"] intValue];l++)
+                {
+                    NSDictionary* lobject = to_sectionjson[[NSString stringWithFormat:@"item_%d",l]];
+                    if([[lobject[@"name"] stringValue] isEqualToString:[itemjson[@"name"]stringValue]])
+                    {
+                        toindex = l;
+                        break;
+                    }
+                }
+                
+                
+                [to_sectionjson setObject:itemjson forKey:[NSString stringWithFormat:@"item_%d",toindex ]];
             }
             
         }
@@ -1351,8 +1364,11 @@
     }
     return to;
 }
-
--(void) refresh:(NSString*) trigger;
+-(void) refresh:(NSString*) trigger
+{
+    [self refresh:trigger discardDirty:false];
+}
+-(void) refresh:(NSString*) trigger discardDirty:(bool) discardDirty
 {
     
     [self.lastedit endEditing:true];
@@ -1381,8 +1397,11 @@
                 [waitalert dismissViewControllerAnimated:YES completion:^{
                     if([[editor_json valueForKey:@"result"] intValue]==2)
                     {
-                        
-                        weakself.content_data_download = [weakself CopyDirty:weakself.content_data_download to:[editor_json mutableCopy]];//[editor_json mutableCopy];
+                        if(!discardDirty)
+                        {
+                            weakself.content_data_download = [weakself CopyDirty:weakself.content_data_download to:[editor_json mutableCopy]];//[editor_json mutableCopy];
+
+                        }
                         
                         weakself.content_data_control = [weakself translate_json:weakself.content_data_download changed: weakself.changed_data];
                         
@@ -1956,6 +1975,7 @@
     {
         NSMutableDictionary* sub_action = [[item_json objectForKey:[NSString stringWithFormat:@"item_%d",subaction_tag]] mutableCopy];
         int refresh = [[sub_action valueForKey:@"refresh"] intValue];
+        bool discardDirty = [[sub_action valueForKey:@"discard_dirty"] boolValue];
         NSString* refresh_trigger = [sub_action valueForKey:@"name"];
         NSDictionary * restore_json=[sub_action objectForKeyedSubscript:@"restore"];
         
@@ -2134,7 +2154,10 @@
                 }
                 
             }
-            [self refresh:refresh_trigger] ;
+            if(!discardDirty)
+                [self refresh:refresh_trigger] ;
+            else
+                [self refresh:refresh_trigger discardDirty:true];
             return ;
         }
         
@@ -2150,6 +2173,7 @@
         
         
         int refresh = [[item_json valueForKey:@"refresh"] intValue];
+        bool discardDirty = [[item_json valueForKey:@"discard_dirty"] boolValue];
         NSString* refresh_trigger = [item_json valueForKey:@"name"];
         NSDictionary * restore_json=[item_json objectForKeyedSubscript:@"restore"];
         
@@ -2321,7 +2345,10 @@
                 }
                 
             }
+            if(!discardDirty)
             [self refresh:refresh_trigger] ;
+            else
+                [self refresh:refresh_trigger discardDirty:false];
             return ;
         }
         
@@ -2519,7 +2546,7 @@
         self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
         
         int refresh = [[item_json valueForKey:@"refresh"] intValue];
-        
+        bool discardDirty = [[item_json valueForKey:@"discard_dirty"] boolValue];
         NSDictionary * restore_json=[item_json objectForKeyedSubscript:@"restore"];
         bool partial_refresh=[[item_json valueForKey:@"partial_refresh"] boolValue];
         if(refresh==1)
@@ -2558,7 +2585,10 @@
                 }
                 
             }
-            [self refresh:refresh_trigger] ;
+            if(!discardDirty)
+                [self refresh:refresh_trigger] ;
+            else
+                [self refresh:refresh_trigger discardDirty:true];
             
         }
         else if(partial_refresh)
@@ -2671,7 +2701,7 @@
         self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
         
         int refresh = [[item_json valueForKey:@"refresh"] intValue];
-        
+        bool discardDirty = [[item_json valueForKey:@"discard_dirty"] boolValue];
         NSDictionary * restore_json=[item_json objectForKeyedSubscript:@"restore"];
         bool partial_refresh=[[item_json valueForKey:@"partial_refresh"] boolValue];
         if(refresh==1)
@@ -2710,7 +2740,10 @@
                 }
                 
             }
-            [self refresh:refresh_trigger] ;
+            if(!discardDirty)
+                [self refresh:refresh_trigger] ;
+            else
+                [self refresh:refresh_trigger discardDirty:true];
             
         }
         else if(partial_refresh)
@@ -5293,6 +5326,7 @@
     NSMutableDictionary* item_json =[((NSMutableArray*)self.content_data_control[indexPath.section])[indexPath.row] mutableCopy];
     
     int refresh = [[item_json valueForKey:@"refresh"] intValue];
+    bool discardDirty = [[item_json valueForKey:@"discard_dirty"] boolValue];
     NSString* refresh_trigger = [item_json valueForKey:@"name"];
     NSString* subid=[item_json valueForKey:@"subid"];
     
@@ -5349,7 +5383,10 @@
     
     if(refresh==1)
     {
-        [self refresh:refresh_trigger];
+        if(!discardDirty)
+            [self refresh:refresh_trigger] ;
+        else
+            [self refresh:refresh_trigger discardDirty:true];
     }
     [self.editorTable reloadData ];
 }
@@ -5366,6 +5403,7 @@
     
     
     int refresh = [[item_json valueForKey:@"refresh"] intValue];
+    bool discardDirty = [[item_json valueForKey:@"discard_dirty"] boolValue];
     
     NSString* refresh_trigger = [item_json valueForKey:@"name"];
     NSString* subid=[item_json valueForKey:@"subid"];
@@ -5452,7 +5490,10 @@
             }
             
         }
-        [self refresh:refresh_trigger] ;
+        if(!discardDirty)
+            [self refresh:refresh_trigger] ;
+        else
+            [self refresh:refresh_trigger discardDirty:true];
         return ;
     }
     
@@ -6195,6 +6236,7 @@
     NSMutableDictionary* item_json =[((NSMutableArray*)self.content_data_control[indexPath.section])[indexPath.row] mutableCopy];
     
     int refresh = [[item_json valueForKey:@"refresh"] intValue];
+    bool discardDirty = [[item_json valueForKey:@"discard_dirty"] boolValue];
     NSString* refresh_trigger = [item_json valueForKey:@"name"];
     NSString* subid=[item_json valueForKey:@"subid"];
     
@@ -6251,7 +6293,10 @@
     
     if(refresh==1)
     {
-        [self refresh:refresh_trigger];
+        if(!discardDirty)
+            [self refresh:refresh_trigger] ;
+        else
+            [self refresh:refresh_trigger discardDirty:true];
     }
 }
 
@@ -6279,6 +6324,7 @@
     NSMutableDictionary* item_json =[((NSMutableArray*)self.content_data_control[indexPath.section])[indexPath.row] mutableCopy];
     
     int refresh = [[item_json valueForKey:@"refresh"] intValue];
+    bool discardDirty = [[item_json valueForKey:@"discard_dirty"] boolValue];
     NSString* refresh_trigger = [item_json valueForKey:@"name"];
     NSString* subid=[item_json valueForKey:@"subid"];
     NSString* check=@"false";
@@ -6331,7 +6377,10 @@
     
     if(refresh==1)
     {
-        [self refresh:refresh_trigger];
+        if(!discardDirty)
+            [self refresh:refresh_trigger] ;
+        else
+            [self refresh:refresh_trigger discardDirty:true];
     }
     DebugLog(@"switch unlock");
    // [self.switchlock unlock];