mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 05:26:47 +00:00
Improvements for profile management
This commit is contained in:
parent
4e14bd077c
commit
53b69d9623
@ -106,13 +106,6 @@ class UserProfileDBManager {
|
|||||||
return true;
|
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.
|
* Update the selected profile in the database.
|
||||||
* The unique integer <key> is used to determine if the profile already exists.
|
* The unique integer <key> is used to determine if the profile already exists.
|
||||||
@ -196,4 +189,32 @@ class UserProfileDBManager {
|
|||||||
|
|
||||||
return profileList;
|
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);
|
await UserProfileDBManager().updateProfile(prf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure the profile is selected
|
||||||
|
assert(! await UserProfileDBManager().selectProfileByName("Missing Profile"));
|
||||||
|
assert(await UserProfileDBManager().selectProfileByName("Test Profile"));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
group("Login Tests:", () {
|
group("Login Tests:", () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user