fix: init with schemas even if no db

- ux: show reload dialog on settings save
This commit is contained in:
18alantom
2023-05-10 22:46:01 -07:00
committed by Alan
parent ee29f8d564
commit afe04cccaf
4 changed files with 26 additions and 8 deletions
+5 -1
View File
@@ -18,7 +18,11 @@ export class DatabaseManager extends DatabaseDemuxBase {
}
getSchemaMap() {
return this.db?.schemaMap ?? {};
if (this.#isInitialized) {
return this.db?.schemaMap ?? getSchemas();
}
return getSchemas();
}
async createNewDatabase(dbPath: string, countryCode: string) {
+1 -1
View File
@@ -167,7 +167,7 @@ export class Fyo {
}
getField(schemaName: string, fieldname: string) {
return this.fieldMap[schemaName][fieldname];
return this.fieldMap[schemaName]?.[fieldname];
}
async getValue(
+17 -6
View File
@@ -78,14 +78,14 @@ import FormHeader from 'src/components/FormHeader.vue';
import { handleErrorWithDialog } from 'src/errorHandling';
import { getErrorMessage } from 'src/utils';
import { evaluateHidden } from 'src/utils/doc';
import { showToast } from 'src/utils/interactive';
import { shortcutsKey } from 'src/utils/injectionKeys';
import { showDialog } from 'src/utils/interactive';
import { reloadWindow } from 'src/utils/ipcCalls';
import { docsPathMap } from 'src/utils/misc';
import { docsPathRef } from 'src/utils/refs';
import { UIGroupedFields } from 'src/utils/types';
import { computed, defineComponent, inject } from 'vue';
import CommonFormSection from '../CommonForm/CommonFormSection.vue';
import { shortcutsKey } from 'src/utils/injectionKeys';
const COMPONENT_NAME = 'Settings';
@@ -165,11 +165,22 @@ export default defineComponent({
}
this.update();
await showToast({
message: this.t`Changes will be visible on reload`,
actionText: this.t`Reload App`,
showDialog({
title: this.t`Reload Frappe Books?`,
detail: this.t`Changes made to settings will be visible on reload.`,
type: 'info',
action: reloadWindow,
buttons: [
{
label: this.t`Yes`,
isPrimary: true,
action: reloadWindow,
},
{
label: this.t`No`,
action() {},
isEscape: true,
},
],
});
},
async syncDoc(doc: Doc): Promise<void> {
+3
View File
@@ -109,6 +109,9 @@ export default defineComponent({
},
async mounted() {
this.docOrNull = getSetupWizardDoc();
if (!this.fyo.db.isConnected) {
await this.fyo.db.init();
}
if (this.fyo.store.isDevelopment) {
// @ts-ignore