mirror of
				https://github.com/inventree/inventree-app.git
				synced 2025-10-31 13:25:40 +00:00 
			
		
		
		
	Improvements for profile management
This commit is contained in:
		| @@ -106,13 +106,6 @@ class UserProfileDBManager { | ||||
|     return true; | ||||
|   } | ||||
|  | ||||
|   /* | ||||
|    * Mark the particular profile as selected | ||||
|    */ | ||||
|   Future<void> selectProfile(int key) async { | ||||
|     await store.record("selected").put(await _db, key); | ||||
|   } | ||||
|  | ||||
|   /* | ||||
|    * Update the selected profile in the database. | ||||
|    * The unique integer <key> is used to determine if the profile already exists. | ||||
| @@ -196,4 +189,32 @@ class UserProfileDBManager { | ||||
|  | ||||
|     return profileList; | ||||
|   } | ||||
|  | ||||
|   /* | ||||
|    * Mark the particular profile as selected | ||||
|    */ | ||||
|   Future<void> selectProfile(int key) async { | ||||
|     await store.record("selected").put(await _db, key); | ||||
|   } | ||||
|  | ||||
|   /* | ||||
|    * Look-up and select a profile by name. | ||||
|    * Return true if the profile was selected | ||||
|    */ | ||||
|   Future<bool> selectProfileByName(String name) async { | ||||
|     var profiles = await getAllProfiles(); | ||||
|  | ||||
|     for (var prf in profiles) { | ||||
|       if (prf.name == name) { | ||||
|         int key = prf.key ?? -1; | ||||
|  | ||||
|         if (key >= 0) { | ||||
|           await selectProfile(key); | ||||
|           return true; | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     return false; | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -41,6 +41,10 @@ void main() { | ||||
|       await UserProfileDBManager().updateProfile(prf); | ||||
|     } | ||||
|  | ||||
|     // Ensure the profile is selected | ||||
|     assert(! await UserProfileDBManager().selectProfileByName("Missing Profile")); | ||||
|     assert(await UserProfileDBManager().selectProfileByName("Test Profile")); | ||||
|  | ||||
|   }); | ||||
|  | ||||
|   group("Login Tests:", () { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user