The database types from the server has a int property designed for the sortOrder to ensure SQLite is first

This commit is contained in:
Warren Buckley
2023-06-01 12:25:38 +01:00
parent 05dbda7aef
commit 71d8c23697

View File

@@ -57,8 +57,24 @@ export class UmbInstallerDatabaseElement extends UmbLitElement {
if (!this._installerContext) return;
this.observe(this._installerContext.settings, (settings) => {
this._databases = settings?.databases ?? [];
// Sort the databases array if not empty and by sortOrder if it exists
if (this._databases.length > 0) {
const databasesCopy = [...this._databases];
databasesCopy.sort((a, b) => {
if (a.sortOrder === undefined) {
return -1;
}
if (b.sortOrder === undefined) {
return 1;
}
return a.sortOrder - b.sortOrder;
});
this._databases = databasesCopy;
}
// If there is an isConfigured database in the databases array then we can skip the database selection step
// and just use that.
this._preConfiguredDatabase = this._databases.find((x) => x.isConfigured);