mirror of
				https://github.com/inventree/inventree-app.git
				synced 2025-10-30 21:05:42 +00:00 
			
		
		
		
	Reload model data from server
This commit is contained in:
		| @@ -56,7 +56,8 @@ class InvenTreeModel { | |||||||
|       return obj; |       return obj; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   String get url{ return path.join(URL, pk.toString()); } |   // Return the API detail endpoint for this Model object | ||||||
|  |   String get url => "${URL}/${pk}/"; | ||||||
|  |  | ||||||
|   /* |   /* | ||||||
|   // Search this Model type in the database |   // Search this Model type in the database | ||||||
| @@ -79,6 +80,25 @@ class InvenTreeModel { | |||||||
|   // A map of "default" headers to use when performing a GET request |   // A map of "default" headers to use when performing a GET request | ||||||
|   Map<String, String> defaultGetFilters() { return Map<String, String>(); } |   Map<String, String> defaultGetFilters() { return Map<String, String>(); } | ||||||
|  |  | ||||||
|  |   /* | ||||||
|  |    * Reload this object, by requesting data from the server | ||||||
|  |    */ | ||||||
|  |   void reload() async { | ||||||
|  |  | ||||||
|  |     print("Reloading data from $url"); | ||||||
|  |  | ||||||
|  |     var response = await api.get(url); | ||||||
|  |  | ||||||
|  |     if (response.statusCode != 200) { | ||||||
|  |       print("Error retrieving data"); | ||||||
|  |       return; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     final Map<String, dynamic> data = json.decode(response.body); | ||||||
|  |  | ||||||
|  |     jsondata = data; | ||||||
|  |   } | ||||||
|  |  | ||||||
|   // Return the detail view for the associated pk |   // Return the detail view for the associated pk | ||||||
|   Future<InvenTreeModel> get(int pk, {Map<String, String> filters}) async { |   Future<InvenTreeModel> get(int pk, {Map<String, String> filters}) async { | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user